2016-04-13 15:16:37 -04:00
|
|
|
let lastSearch;
|
2016-11-02 16:22:52 -04:00
|
|
|
let lastOverridden;
|
2016-04-13 15:16:37 -04:00
|
|
|
|
2015-11-23 16:45:05 -05:00
|
|
|
export default Ember.Controller.extend({
|
|
|
|
searching: false,
|
|
|
|
siteTexts: null,
|
|
|
|
preferred: false,
|
2015-11-30 15:22:58 -05:00
|
|
|
queryParams: ['q', 'overridden'],
|
2015-11-23 16:45:05 -05:00
|
|
|
|
2016-11-02 16:22:52 -04:00
|
|
|
q: null,
|
|
|
|
overridden: null,
|
2015-11-23 16:45:05 -05:00
|
|
|
|
|
|
|
_performSearch() {
|
2015-11-30 15:22:58 -05:00
|
|
|
this.store.find('site-text', this.getProperties('q', 'overridden')).then(results => {
|
2015-11-23 16:45:05 -05:00
|
|
|
this.set('siteTexts', results);
|
|
|
|
}).finally(() => this.set('searching', false));
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
edit(siteText) {
|
|
|
|
this.transitionToRoute('adminSiteText.edit', siteText.get('id'));
|
|
|
|
},
|
|
|
|
|
2016-07-08 02:37:24 -04:00
|
|
|
search(overridden) {
|
2016-11-02 16:22:52 -04:00
|
|
|
this.set('overridden', overridden);
|
|
|
|
|
2016-04-13 15:16:37 -04:00
|
|
|
const q = this.get('q');
|
2016-11-02 16:22:52 -04:00
|
|
|
if (q !== lastSearch || overridden !== lastOverridden) {
|
2016-04-13 15:16:37 -04:00
|
|
|
this.set('searching', true);
|
|
|
|
Ember.run.debounce(this, this._performSearch, 400);
|
|
|
|
lastSearch = q;
|
2016-11-02 16:22:52 -04:00
|
|
|
lastOverridden = overridden;
|
2016-04-13 15:16:37 -04:00
|
|
|
}
|
2015-11-23 16:45:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|