discourse/app/assets/javascripts/admin/controllers/admin-site-text-index.js.es6
Penar Musaraj 74ed72e825 DEV: Remove d-checkbox component
Replaces the last occurrence of `d-checkbox` with a regular input element.

Includes a minor refactor of admin site text search.
2019-02-21 09:54:54 -05:00

42 lines
919 B
JavaScript

let lastSearch;
export default Ember.Controller.extend({
searching: false,
siteTexts: null,
preferred: false,
queryParams: ["q", "overridden"],
q: null,
overridden: false,
_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"));
},
toggleOverridden() {
this.toggleProperty("overridden");
this.set("searching", true);
Ember.run.debounce(this, this._performSearch, 400);
},
search() {
const q = this.get("q");
if (q !== lastSearch) {
this.set("searching", true);
Ember.run.debounce(this, this._performSearch, 400);
lastSearch = q;
}
}
}
});