npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mobilecaddy-app-addon-global-search

v0.0.1

Published

AngularJS service used to look for an item in all the existing database tables and see the results in the UI, within a MobileCaddy application.

Downloads

6

Readme

MobileCaddy App Addon - Global Search

Overview

AngularJS service used to look for a word in all the existing database tables and see the results in the UI, within a MobileCaddy application.

Build Status

Installation

npm install mobilecaddy-app-addon-global-search

The installation will include the tasks of moving the relevant scripts into the correct place of your MobileCaddy application project structure. The relevant unit tests will also be included.

Configuring

You can set the configuration information of the global search, to specify if the results will be saved in localStorage or encrypted in the database, the name of the tables that will be used to search, fields to query, among other details. This can be run in the .run in the app.js file, thus it can be updated by the developer easily.

GlobalSearchService.setConfig({
    encrypted: false,
    tables: [
      {
        table: 'Account__ap',
        name: 'Accounts',
        fieldsToQuery: ['Name', 'Description'],
        fieldsToShow: ['Name', 'BillingCountry'],
        icon: 'ion-folder',
        href: '/accounts/:Id'
      },
      {
        table: 'Contact__ap',
        name: 'Contacts',
        fieldsToQuery: ['Name', 'Title'],
        fieldsToShow: ['Name', 'Email'],
        icon: 'ion-person',
        href: '/accounts/:AccountId/contacts/:Id'
      }
    ]
  });

Syntax

GlobalSearchService.setConfig({encrypted, tables});

Parameters

encrypted Optional

Whether or not to use the encrypted database to store the recently clicked on search results. If false, stored in localStorage. Defaults to false. Note: Not yet supported.

tables

Array of objects configuring each table to be included in the global search, thus;

[{
  table,          // string: Name of the mobilised table
  name,           // string: Label to be shown in search output
  fieldsToQuery,  // [string]: Array of field names to be queried
  fieldsToShow,   // [string]: Array of field names to be used in search output
  icons,          // string:  Ionicon to be used in search output
  href            // string: State URL to be used for direct record access.
}]

API

search

Calls an internal function for each table specified in the config information, that does the SOQL query to find the inputted word. Since the results are obtained asynchronously, when each call returns with a result it does a broadcast of the result so the controller can update the template appropriately.

Syntax

search(str)

Parameters

str: string. Represents the word inputted in the search box.

Returns

The tables config, as input in configuration (above)

Example

GlobalSearchService.search("test");

//In the controller the broadcast is triggered by the service when it finishes searching
$rootScope.$on('globalSearchResult', function(event, args) {
        console.log("Results of the search", args.results);
});

getRecentSearches

returns an Array of Objects representing all the results clicked after doing a global search. If encryptedStore is false then it will be obtained from localStorage.

Syntax

getRecentSearches();

Returns

An Array of Objects representing all the results clicked after doing a global search.

Example

var recentSearches = GlobalSearchService.getRecentSearches();

addRecentSearch

Adds an item to the recent searches list. It can be added to the localStorage, if encryptedStore is false, or to the encrypted database otherwise. Any repeated item will be deleted before adding the same one. Also if the max number is reached the oldest item will be deleted.

Parameters

item : object. Contains the config information of the result.

result : object. The result object that will be added.

Example

var item = {
  table: 'Account__ap',
  name: 'Accounts',
  icon: 'ion-folder',
  results: [{Id: ab1, string: 'Account 1, UK', href: '/accounts/ab1'},
            {Id: ab2, string: 'Account 2, UK', href: '/accounts/ab2'}]
};
var result = {Id: ab1, string: 'Account 1, UK', href: '/accounts/ab1'};
GlobalSearchService.addRecentSearch(item, result);