Skip to content
This repository was archived by the owner on Apr 5, 2023. It is now read-only.
This repository was archived by the owner on Apr 5, 2023. It is now read-only.

search by group #152

@phpepe

Description

@phpepe

A nice to have feature is to be able to search by group.
Currently if you make us of "optionGroupPath", then only the results items are searchable ("optionValuePath")
I dont know coffeescript, but I solved that in my project by extending and overriding "matcher method", here is the snippet in pure JS:

App.SelectComponent = Ember.Widgets.SelectComponent.extend({
   matcher: function(searchText, item) {
     if ( this._super(searchText, item) ) {
          return true; 
     }
     var escapedSearchText, label, regex;
     if (this.get('optionGroupPath')) {
         label = Em.get(item, this.get('optionGroupPath'));
         if (label) {
             escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
             regex = new RegExp(escapedSearchText, 'i');
             return regex.test(label);
         }
     }
     return false; 
   }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions