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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1015 B
JavaScript
Raw Normal View History

import Controller from "@ember/controller";
import discourseDebounce from "discourse-common/lib/debounce";
let lastSearch;
export default 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);
discourseDebounce(this, this._performSearch, 400);
},
search() {
const q = this.q;
if (q !== lastSearch) {
this.set("searching", true);
discourseDebounce(this, this._performSearch, 400);
lastSearch = q;
}
},
},
});