Skip to content

Instantly share code, notes, and snippets.

@brandonhilkert
Created April 28, 2015 23:32
Show Gist options
  • Select an option

  • Save brandonhilkert/7f05323c0314e781132e to your computer and use it in GitHub Desktop.

Select an option

Save brandonhilkert/7f05323c0314e781132e to your computer and use it in GitHub Desktop.
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['filter', 'sort'],
filterParams: ['id', 'company_name'],
filter: {},
sort: '-id',
actions: {
search: function() {
var params = {};
this.get('queryParams').forEach(function(param){
if (param === 'filter') {
this.get('filterParams').forEach(function(filterParam){
if (this.get('filter')[filterParam]) {
if (!params['filter']) {
params['filter'] = {}
}
params['filter'][filterParam] = this.get('filter')[filterParam];
}
}, this);
} else {
params[param] = this.get(param);
}
}, this);
var results = this.store.find('account', params);
this.set('model', results);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment