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

search by group #152

Open
phpepe opened this issue Dec 10, 2014 · 1 comment
Open

search by group #152

phpepe opened this issue Dec 10, 2014 · 1 comment

Comments

@phpepe
Copy link

phpepe commented Dec 10, 2014

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; 
   }
});
@igillis
Copy link
Contributor

igillis commented Dec 30, 2014

Cool, I like this idea. Would definitely welcome a PR adding it.

Coffeescript vs JavaScript shouldn't really be an issue as they have essentially the same semantics, but we are tossing around the idea of rewriting in JS if you want to hold out for that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants