discourse/app/assets/javascripts/admin/routes/admin-customize-themes.js.es6

38 lines
900 B
Plaintext
Raw Normal View History

2018-06-15 23:03:24 +08:00
import showModal from "discourse/lib/show-modal";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default Ember.Route.extend({
model() {
2018-06-15 23:03:24 +08:00
return this.store.findAll("theme");
},
setupController(controller, model) {
this._super(controller, model);
controller.set("editingTheme", false);
},
actions: {
importModal() {
2018-06-15 23:03:24 +08:00
showModal("admin-import-theme", { admin: true });
},
addTheme(theme) {
2018-06-15 23:03:24 +08:00
const all = this.modelFor("adminCustomizeThemes");
all.pushObject(theme);
2018-06-15 23:03:24 +08:00
this.transitionTo("adminCustomizeThemes.show", theme.get("id"));
},
newTheme(obj) {
2018-06-15 23:03:24 +08:00
obj = obj || { name: I18n.t("admin.customize.new_style") };
const item = this.store.createRecord("theme");
2018-06-15 23:03:24 +08:00
item
.save(obj)
.then(() => {
this.send("addTheme", item);
})
.catch(popupAjaxError);
}
}
});