Created
April 28, 2015 23:32
-
-
Save brandonhilkert/7f05323c0314e781132e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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