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

pure-angular-advanced-searchbox

v1.1.77

Published

Pure angular-based advanced search

Downloads

6

Readme

Pure Angular Advanced Search Box is an implementation to add advanced searching capabilities into a reusable UI to help build parameters based off of filters, queries and operators to send off to a search API.

Features

  • Basic Search Query Input Box
  • Filters
  • Filter Selectors - Selectors for filters (Contains, Is Equal To, etc).
  • Operators - OR/AND support between filters to give more advanced searchbox functionality.
  • Grouping (In Progress)
  • Drag and Drop - Swap / Insert Before and After functionality for filters to change arrangement.
  • Validation - Validators on filters allows control over when search get's updated based on valid entries.
  • Middlewares - to modify values within filters after user input.
  • Externalized Configuration / HTML (In Progress)

TODOs

  • [ ] Add grouping around conditionals (In Progress)
  • [ ] Build query (SOLR, SQL)
  • [ ] Add UI for validation
  • [ ] Externalizing templates
  • [ ] Update Live DEMO (In Progress)
  • [ ] Add ability to only update params via ENTER key or clicking Search Button

Known Bugs

  • [x] Verified - Cannot read property 'store' of undefined - Thanks to @IbrahimHd (DONE)

Screenshots

View Demo Here

Usage

  1. Install with bower:
    • bower install pure-angular-advanced-searchbox

The bower package contains files in the dist/ directory with the following includes:

  • ui.core.js
  • ui.core.min.js
  • main.css

Files with the min suffix are minified versions to be used in production.

Load the javascript/css and declare your angular dependency:

<!-- dependency includes -->
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/lodash/lodash.js"></script>

<link rel="stylesheet" href="bower_components/components-font-awesome/css/font-awesome.css" />

<!-- pure angular advanced searchbox -->
<script src="bower_components/pure-angular-advanced-searchbox/dist/scripts/ui.core.js"></script>

<link rel="stylesheet" href="bower_components/pure-angular-advanced-searchbox/dist/styles/main.css" />
angular.module('myModule', ['paasb']);

Example Directive Usage

<paasb-search-box
  search-params="sOptions"
  paasb-search-box-filtering="sFilters"
  paasb-search-box-enable-filtering-operators="true"
  paasb-search-box-config="sConfig"
  paasb-search-box-auto-complete="sConfig"
  paasb-search-box-cache-filter="true"
  paasb-search-box-filter-selectors="sFilterSelectors"
  paasb-search-box-filter-operators="sFilterOperators"
  placeholder="Enter your query here..."
</paasb-search-box>
Description

The searchbox will return data in JSON format and look something like:

{  
   "filters":[  
      {  
         "condition":"contains",
         "value":"NK",
         "name":"vendor_abbr",
         "$$timestamp":1468518875834,
         "$$modified":1468518875834
      },
      {  
         "condition":"contains",
         "value":"Yellow",
         "name":"color",
         "$$timestamp":1468518875834,
         "$$modified":1468518875834,
         "$$operator":"AND"
      }
   ],
   "operators":[  
      "AND"
   ],
   "query":"Nike Flex"
}

##############

##############

Define the available search parameters / filters in your project:

$scope.sOptions = [];

$scope.sFilters = [
    {
      'name': 'dontFilterMe',
      'displayName': 'I don\'t want to be filtered!',
      'dontFilter': true
    },
    {
      'name': 'cpi',
      'displayName': 'CPI',
      'root': 'Product',
      'middleware': [function (val) {

        if(!isNaN(val)) {

          return (val * 2);

        }

        return val;

      }, function (val) {

        return 'value:' + val;

      }]
    }, {
      'name': 'gender',
      'displayName': 'Vendor Gender',
      'suggestedValues': 'GENDER',
      'suggestedDataPoint': 'data',
      'reloadOnCreate': true,
      'restrictedSuggestedValues': true,
      'multi': true,
      'root': 'Product'
    }, {
      'name': 'upc',
      'displayName': 'UPC',
      'child': 'Size'
    }
];

$scope.sConfig = {
    'delay': 1000, /* How long before paasb fires off a change event */
    'store': true /* Should we store our query/caching in local storage? */
    'showMagnifierAlways': false /* Should we keep magnifier or remove it when there is some sort of query/filter? */
};

$scope.sFilterOperators = [
  {
    "name": "NOT"
  },
  {
    "name": "AND",
    "selected": true
  }, {
    "name": "OR"
  }
];

$scope.sFilterSelectors = [
  {
    "name": "Test",
    "key": "test"
  },
  {
    "name": "Contains",
    "key": "contains",
    "selected": true,
    "notAllowed": [
      "restrictedSuggestedValues"
    ]
  },
  {
    "name": "Does not contain",
    "key": "doesNotContain",
    "notAllowed": [
      "restrictedSuggestedValues"
    ]
  },
  {
    "name": "Is Equal To",
    "key": "isEqualTo"
  },
  {
    "name": "Is Not Equal To",
    "key": "isNotEqualTo"
  },
  {
    "name": "Starts with",
    "key": "startsWith"
  },
  {
    "name": "Ends with",
    "key": "endsWith"
  },
  {
    "name": "Similiarity",
    "key": "similiarity"
  }
];

Available Directive Attributes

Available Events

Example:

$scope.$on('onRegisterApi', function(ev, api) {

	console.log('api!', api);

	api
		.on('onChange', function (ev, params) {

			console.log('parameters!', params);

		});

});

Available Search Filter Properties

Available Search Validations

  • Validation providers are separated with a space between them (min=3 email). If a validation provider is given that is unknown to paasb; it will be ignored. Custom validator's can be written. ** NOTE ** There is currently no UI that tell's you whether something was / or was not validated; it just works - this is currently in the process of being developed.
{
	"validation": "length=12 email"
}
  • [x] Length length=3 String Length must be exactly X characters.
  • [x] Min min=3 String Length must be at least X characters.
  • [x] Max max=6 String Length must be under X characters.
  • [x] Email email Must match a valid e-mail address format.
  • [x] Phone phone Must match a valid phone number format.
  • [x] Between between(3,6)duplicates min and max functionality.
  • [x] Numeric numeric Is this a numeric value?

Available Search Configuration Properties

<tr>
  <td>delay</td>
  <td>Would you like to provide a delay before the search parameters get updated? Default is <b>null</b>.  If no delay is provided, then automatic updates will not be triggered.</td>
  <td>number</td>
</tr>
<tr>
  <td>&lt;configName&gt;</td>
  <td>Custom configuration property that can be injected into filter parameters; useful when using constants via <b>suggestedValues</b></td>
  <td>string</td>
</tr>