mirror of
https://github.com/discourse/discourse.git
synced 2024-12-16 13:46:28 +08:00
e0cc29d658
* FEATURE: themes and components split * two seperate methods to switch theme type * use strict equality operator
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
|
import { default as computed } from "ember-addons/ember-computed-decorators";
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
|
|
const COMPONENT = "component";
|
|
|
|
export default Ember.Controller.extend(ModalFunctionality, {
|
|
types: [
|
|
{ name: I18n.t("admin.customize.theme.theme"), value: "theme" },
|
|
{ name: I18n.t("admin.customize.theme.component"), value: COMPONENT }
|
|
],
|
|
selectedType: "theme",
|
|
name: I18n.t("admin.customize.new_style"),
|
|
themesController: Ember.inject.controller("adminCustomizeThemes"),
|
|
loading: false,
|
|
|
|
@computed("selectedType")
|
|
component(type) {
|
|
return type === COMPONENT;
|
|
},
|
|
|
|
actions: {
|
|
createTheme() {
|
|
this.set("loading", true);
|
|
const theme = this.store.createRecord("theme");
|
|
theme
|
|
.save({ name: this.get("name"), component: this.get("component") })
|
|
.then(() => {
|
|
this.get("themesController").send("addTheme", theme);
|
|
this.send("closeModal");
|
|
})
|
|
.catch(popupAjaxError)
|
|
.finally(() => this.set("loading", false));
|
|
}
|
|
}
|
|
});
|