mirror of
https://github.com/discourse/discourse.git
synced 2024-12-17 02:43:44 +08:00
52 lines
1.1 KiB
Plaintext
52 lines
1.1 KiB
Plaintext
|
import { default as computed } from 'ember-addons/ember-computed-decorators';
|
||
|
|
||
|
export default Ember.Controller.extend({
|
||
|
_q: null,
|
||
|
searching: false,
|
||
|
siteTexts: null,
|
||
|
preferred: false,
|
||
|
_overridden: null,
|
||
|
queryParams: ['q', 'overridden'],
|
||
|
|
||
|
@computed
|
||
|
overridden: {
|
||
|
set(value) {
|
||
|
if (!value || value === "false") { value = false; }
|
||
|
this._overridden = value;
|
||
|
return value;
|
||
|
},
|
||
|
get() {
|
||
|
return this._overridden;
|
||
|
}
|
||
|
},
|
||
|
|
||
|
@computed
|
||
|
q: {
|
||
|
set(value) {
|
||
|
if (Ember.isEmpty(value)) { value = null; }
|
||
|
this._q = value;
|
||
|
return value;
|
||
|
},
|
||
|
get() {
|
||
|
return this._q;
|
||
|
}
|
||
|
},
|
||
|
|
||
|
_performSearch() {
|
||
|
this.store.find('site-text', this.getProperties('q', 'overridden')).then(results => {
|
||
|
this.set('siteTexts', results);
|
||
|
}).finally(() => this.set('searching', false));
|
||
|
},
|
||
|
|
||
|
actions: {
|
||
|
edit(siteText) {
|
||
|
this.transitionToRoute('adminSiteText.edit', siteText.get('id'));
|
||
|
},
|
||
|
|
||
|
search() {
|
||
|
this.set('searching', true);
|
||
|
Ember.run.debounce(this, this._performSearch, 400);
|
||
|
}
|
||
|
}
|
||
|
});
|