discourse/app/assets/javascripts/admin/controllers/admin-site-text-index.js.es6

39 lines
930 B
Plaintext
Raw Normal View History

let lastSearch;
let lastOverridden;
export default Ember.Controller.extend({
searching: false,
siteTexts: null,
preferred: false,
2018-06-15 23:03:24 +08:00
queryParams: ["q", "overridden"],
q: null,
overridden: null,
_performSearch() {
2018-06-15 23:03:24 +08:00
this.store
.find("site-text", this.getProperties("q", "overridden"))
.then(results => {
this.set("siteTexts", results);
})
.finally(() => this.set("searching", false));
},
actions: {
edit(siteText) {
2018-06-15 23:03:24 +08:00
this.transitionToRoute("adminSiteText.edit", siteText.get("id"));
},
search(overridden) {
if (typeof overridden === "boolean") this.set("overridden", overridden);
2018-06-15 23:03:24 +08:00
const q = this.get("q");
if (q !== lastSearch || overridden !== lastOverridden) {
2018-06-15 23:03:24 +08:00
this.set("searching", true);
Ember.run.debounce(this, this._performSearch, 400);
lastSearch = q;
lastOverridden = overridden;
}
}
}
});