2019-11-01 13:06:50 -04:00
|
|
|
import { COMPONENTS, THEMES } from "admin/models/theme";
|
2019-11-28 00:19:01 -05:00
|
|
|
import {
|
|
|
|
empty,
|
|
|
|
filterBy,
|
|
|
|
mapBy,
|
2020-12-01 13:31:26 -05:00
|
|
|
match,
|
2019-11-28 00:19:01 -05:00
|
|
|
notEmpty,
|
|
|
|
} from "@ember/object/computed";
|
2019-10-23 13:06:54 -04:00
|
|
|
import Controller from "@ember/controller";
|
2020-02-05 11:14:42 -05:00
|
|
|
import EmberObject from "@ember/object";
|
2020-05-13 16:23:41 -04:00
|
|
|
import I18n from "I18n";
|
2018-03-04 19:04:23 -05:00
|
|
|
import ThemeSettings from "admin/models/theme-settings";
|
2020-08-26 12:57:13 -04:00
|
|
|
import bootbox from "bootbox";
|
2020-01-16 12:56:53 -05:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2017-04-12 10:52:52 -04:00
|
|
|
import { makeArray } from "discourse-common/lib/helpers";
|
2017-04-17 16:55:53 -04:00
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
2017-05-09 17:20:28 -04:00
|
|
|
import showModal from "discourse/lib/show-modal";
|
2018-08-30 15:23:15 -04:00
|
|
|
import { url } from "discourse/lib/computed";
|
2017-05-09 17:20:28 -04:00
|
|
|
|
|
|
|
const THEME_UPLOAD_VAR = 2;
|
2017-04-12 10:52:52 -04:00
|
|
|
|
2019-10-23 13:06:54 -04:00
|
|
|
export default Controller.extend({
|
2019-01-23 09:40:21 -05:00
|
|
|
downloadUrl: url("model.id", "/admin/customize/themes/%@/export"),
|
2018-09-06 14:56:00 -04:00
|
|
|
previewUrl: url("model.id", "/admin/themes/%@/preview"),
|
2019-10-30 16:28:29 -04:00
|
|
|
addButtonDisabled: empty("selectedChildThemeId"),
|
2018-10-11 08:20:04 -04:00
|
|
|
editRouteName: "adminCustomizeThemes.edit",
|
2019-11-28 00:19:01 -05:00
|
|
|
parentThemesNames: mapBy("model.parentThemes", "name"),
|
|
|
|
availableParentThemes: filterBy("allThemes", "component", false),
|
2019-12-04 01:13:41 -05:00
|
|
|
availableActiveParentThemes: filterBy("availableParentThemes", "isActive"),
|
2019-11-28 00:19:01 -05:00
|
|
|
availableThemesNames: mapBy("availableParentThemes", "name"),
|
2019-12-04 01:13:41 -05:00
|
|
|
availableActiveThemesNames: mapBy("availableActiveParentThemes", "name"),
|
|
|
|
availableActiveChildThemes: filterBy("availableChildThemes", "hasParents"),
|
|
|
|
availableComponentsNames: mapBy("availableChildThemes", "name"),
|
|
|
|
availableActiveComponentsNames: mapBy("availableActiveChildThemes", "name"),
|
|
|
|
childThemesNames: mapBy("model.childThemes", "name"),
|
2020-04-30 10:02:38 -04:00
|
|
|
extraFiles: filterBy("model.theme_fields", "target", "extra_js"),
|
2018-08-08 00:46:34 -04:00
|
|
|
|
2020-11-16 07:44:09 -05:00
|
|
|
@discourseComputed("model.component", "model.remote_theme")
|
|
|
|
showCheckboxes() {
|
|
|
|
return !this.model.component || this.model.remote_theme;
|
|
|
|
},
|
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("model.editedFields")
|
2018-09-08 09:24:11 -04:00
|
|
|
editedFieldsFormatted() {
|
2018-09-06 14:56:00 -04:00
|
|
|
const descriptions = [];
|
2018-03-05 17:26:50 -05:00
|
|
|
["common", "desktop", "mobile"].forEach((target) => {
|
2018-09-06 14:56:00 -04:00
|
|
|
const fields = this.editedFieldsForTarget(target);
|
|
|
|
if (fields.length < 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let resultString = I18n.t("admin.customize.theme." + target);
|
|
|
|
const formattedFields = fields
|
|
|
|
.map((f) => I18n.t("admin.customize.theme." + f.name + ".text"))
|
|
|
|
.join(" , ");
|
|
|
|
resultString += `: ${formattedFields}`;
|
|
|
|
descriptions.push(resultString);
|
2017-04-12 10:52:52 -04:00
|
|
|
});
|
2018-09-06 14:56:00 -04:00
|
|
|
return descriptions;
|
2017-04-12 10:52:52 -04:00
|
|
|
},
|
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("colorSchemeId", "model.color_scheme_id")
|
2017-04-12 10:52:52 -04:00
|
|
|
colorSchemeChanged(colorSchemeId, existingId) {
|
2019-11-12 04:47:42 -05:00
|
|
|
colorSchemeId = colorSchemeId === null ? null : parseInt(colorSchemeId, 10);
|
2017-04-12 10:52:52 -04:00
|
|
|
return colorSchemeId !== existingId;
|
|
|
|
},
|
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("availableChildThemes", "model.childThemes.[]", "model")
|
2018-09-06 14:56:00 -04:00
|
|
|
selectableChildThemes(available, childThemes) {
|
|
|
|
if (available) {
|
|
|
|
const themes = !childThemes
|
|
|
|
? available
|
|
|
|
: available.filter((theme) => childThemes.indexOf(theme) === -1);
|
|
|
|
return themes.length === 0 ? null : themes;
|
2017-04-12 10:52:52 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2019-11-28 00:19:01 -05:00
|
|
|
@discourseComputed("model.parentThemes.[]")
|
2019-12-04 01:13:41 -05:00
|
|
|
relativesSelectorSettingsForComponent() {
|
2020-02-05 11:14:42 -05:00
|
|
|
return EmberObject.create({
|
2019-11-28 00:19:01 -05:00
|
|
|
list_type: "compact",
|
|
|
|
type: "list",
|
|
|
|
preview: null,
|
|
|
|
anyValue: false,
|
|
|
|
setting: "parent_theme_ids",
|
|
|
|
label: I18n.t("admin.customize.theme.component_on_themes"),
|
|
|
|
choices: this.availableThemesNames,
|
|
|
|
default: this.parentThemesNames.join("|"),
|
|
|
|
value: this.parentThemesNames.join("|"),
|
2019-12-04 01:13:41 -05:00
|
|
|
defaultValues: this.availableActiveThemesNames.join("|"),
|
2019-11-28 00:19:01 -05:00
|
|
|
allThemes: this.allThemes,
|
|
|
|
setDefaultValuesLabel: I18n.t("admin.customize.theme.add_all_themes"),
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2019-12-04 01:13:41 -05:00
|
|
|
@discourseComputed("model.parentThemes.[]")
|
|
|
|
relativesSelectorSettingsForTheme() {
|
2020-02-05 11:14:42 -05:00
|
|
|
return EmberObject.create({
|
2019-12-04 01:13:41 -05:00
|
|
|
list_type: "compact",
|
|
|
|
type: "list",
|
|
|
|
preview: null,
|
|
|
|
anyValue: false,
|
|
|
|
setting: "child_theme_ids",
|
|
|
|
label: I18n.t("admin.customize.theme.included_components"),
|
|
|
|
choices: this.availableComponentsNames,
|
|
|
|
default: this.childThemesNames.join("|"),
|
|
|
|
value: this.childThemesNames.join("|"),
|
|
|
|
defaultValues: this.availableActiveComponentsNames.join("|"),
|
|
|
|
allThemes: this.allThemes,
|
|
|
|
setDefaultValuesLabel: I18n.t("admin.customize.theme.add_all"),
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("allThemes", "model.component", "model")
|
2018-09-06 14:56:00 -04:00
|
|
|
availableChildThemes(allThemes) {
|
|
|
|
if (!this.get("model.component")) {
|
|
|
|
const themeId = this.get("model.id");
|
|
|
|
return allThemes.filter(
|
|
|
|
(theme) => theme.get("id") !== themeId && theme.get("component")
|
|
|
|
);
|
2017-04-12 10:52:52 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("model.component")
|
2018-08-30 15:23:15 -04:00
|
|
|
convertKey(component) {
|
2018-08-23 21:30:00 -04:00
|
|
|
const type = component ? "component" : "theme";
|
2018-08-30 15:23:15 -04:00
|
|
|
return `admin.customize.theme.convert_${type}`;
|
|
|
|
},
|
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("model.component")
|
2018-08-30 15:23:15 -04:00
|
|
|
convertIcon(component) {
|
|
|
|
return component ? "cube" : "";
|
|
|
|
},
|
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("model.component")
|
2018-08-30 15:23:15 -04:00
|
|
|
convertTooltip(component) {
|
|
|
|
const type = component ? "component" : "theme";
|
|
|
|
return `admin.customize.theme.convert_${type}_tooltip`;
|
2018-08-23 21:30:00 -04:00
|
|
|
},
|
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("model.settings")
|
2018-03-04 19:04:23 -05:00
|
|
|
settings(settings) {
|
|
|
|
return settings.map((setting) => ThemeSettings.create(setting));
|
|
|
|
},
|
|
|
|
|
2019-10-30 16:28:29 -04:00
|
|
|
hasSettings: notEmpty("settings"),
|
2019-01-17 06:46:11 -05:00
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("model.translations")
|
2019-01-17 06:46:11 -05:00
|
|
|
translations(translations) {
|
|
|
|
return translations.map((setting) => ThemeSettings.create(setting));
|
2018-03-04 19:04:23 -05:00
|
|
|
},
|
2018-09-08 09:24:11 -04:00
|
|
|
|
2019-10-30 16:28:29 -04:00
|
|
|
hasTranslations: notEmpty("translations"),
|
2019-01-17 06:46:11 -05:00
|
|
|
|
2020-11-23 08:29:22 -05:00
|
|
|
@discourseComputed(
|
|
|
|
"model.remote_theme.local_version",
|
|
|
|
"model.remote_theme.remote_version",
|
|
|
|
"model.remote_theme.commits_behind"
|
|
|
|
)
|
|
|
|
hasOverwrittenHistory(localVersion, remoteVersion, commitsBehind) {
|
|
|
|
return localVersion !== remoteVersion && commitsBehind === -1;
|
|
|
|
},
|
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("model.remoteError", "updatingRemote")
|
2018-09-08 09:24:11 -04:00
|
|
|
showRemoteError(errorMessage, updating) {
|
|
|
|
return errorMessage && !updating;
|
|
|
|
},
|
|
|
|
|
2018-09-06 14:56:00 -04:00
|
|
|
editedFieldsForTarget(target) {
|
|
|
|
return this.get("model.editedFields").filter(
|
|
|
|
(field) => field.target === target
|
|
|
|
);
|
|
|
|
},
|
2017-04-12 10:52:52 -04:00
|
|
|
|
2018-08-30 15:23:15 -04:00
|
|
|
commitSwitchType() {
|
2019-05-27 04:15:39 -04:00
|
|
|
const model = this.model;
|
2018-08-30 15:23:15 -04:00
|
|
|
const newValue = !model.get("component");
|
|
|
|
model.set("component", newValue);
|
|
|
|
|
|
|
|
if (newValue) {
|
|
|
|
this.set("parentController.currentTab", COMPONENTS);
|
|
|
|
} else {
|
|
|
|
this.set("parentController.currentTab", THEMES);
|
|
|
|
}
|
|
|
|
|
|
|
|
model
|
|
|
|
.saveChanges("component")
|
|
|
|
.then(() => {
|
|
|
|
this.set("colorSchemeId", null);
|
|
|
|
|
|
|
|
model.setProperties({
|
|
|
|
default: false,
|
|
|
|
color_scheme_id: null,
|
|
|
|
user_selectable: false,
|
|
|
|
child_themes: [],
|
|
|
|
childThemes: [],
|
|
|
|
});
|
|
|
|
|
|
|
|
this.get("parentController.model.content").forEach((theme) => {
|
2019-10-31 13:55:01 -04:00
|
|
|
const children = makeArray(theme.get("childThemes"));
|
|
|
|
const rawChildren = makeArray(theme.get("child_themes"));
|
2018-08-30 15:23:15 -04:00
|
|
|
const index = children ? children.indexOf(model) : -1;
|
|
|
|
if (index > -1) {
|
|
|
|
children.splice(index, 1);
|
|
|
|
rawChildren.splice(index, 1);
|
|
|
|
theme.setProperties({
|
|
|
|
childThemes: children,
|
|
|
|
child_themes: rawChildren,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch(popupAjaxError);
|
|
|
|
},
|
2018-09-06 14:56:00 -04:00
|
|
|
transitionToEditRoute() {
|
|
|
|
this.transitionToRoute(
|
2019-05-27 04:15:39 -04:00
|
|
|
this.editRouteName,
|
2018-09-06 14:56:00 -04:00
|
|
|
this.get("model.id"),
|
|
|
|
"common",
|
|
|
|
"scss"
|
|
|
|
);
|
|
|
|
},
|
2019-10-30 19:18:29 -04:00
|
|
|
sourceIsHttp: match("model.remote_theme.remote_url", /^http(s)?:\/\//),
|
2020-03-17 18:27:54 -04:00
|
|
|
|
|
|
|
@discourseComputed(
|
|
|
|
"model.remote_theme.remote_url",
|
|
|
|
"model.remote_theme.branch"
|
|
|
|
)
|
|
|
|
remoteThemeLink(remoteThemeUrl, remoteThemeBranch) {
|
|
|
|
return remoteThemeBranch
|
|
|
|
? `${remoteThemeUrl.replace(/\.git$/, "")}/tree/${remoteThemeBranch}`
|
|
|
|
: remoteThemeUrl;
|
|
|
|
},
|
|
|
|
|
2021-02-10 19:20:13 -05:00
|
|
|
@discourseComputed("model.user.id", "model.default")
|
|
|
|
showConvert(userId, defaultTheme) {
|
|
|
|
return userId > 0 && !defaultTheme;
|
|
|
|
},
|
|
|
|
|
2017-04-12 10:52:52 -04:00
|
|
|
actions: {
|
|
|
|
updateToLatest() {
|
|
|
|
this.set("updatingRemote", true);
|
2019-05-27 04:15:39 -04:00
|
|
|
this.model
|
2017-04-17 16:55:53 -04:00
|
|
|
.updateToLatest()
|
|
|
|
.catch(popupAjaxError)
|
|
|
|
.finally(() => {
|
|
|
|
this.set("updatingRemote", false);
|
|
|
|
});
|
2017-04-12 10:52:52 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
checkForThemeUpdates() {
|
|
|
|
this.set("updatingRemote", true);
|
2019-05-27 04:15:39 -04:00
|
|
|
this.model
|
2017-04-17 16:55:53 -04:00
|
|
|
.checkForUpdates()
|
|
|
|
.catch(popupAjaxError)
|
|
|
|
.finally(() => {
|
|
|
|
this.set("updatingRemote", false);
|
|
|
|
});
|
2017-04-12 10:52:52 -04:00
|
|
|
},
|
|
|
|
|
2017-05-09 17:20:28 -04:00
|
|
|
addUploadModal() {
|
|
|
|
showModal("admin-add-upload", { admin: true, name: "" });
|
|
|
|
},
|
|
|
|
|
|
|
|
addUpload(info) {
|
2019-05-27 04:15:39 -04:00
|
|
|
let model = this.model;
|
2017-05-09 17:20:28 -04:00
|
|
|
model.setField("common", info.name, "", info.upload_id, THEME_UPLOAD_VAR);
|
|
|
|
model.saveChanges("theme_fields").catch((e) => popupAjaxError(e));
|
|
|
|
},
|
|
|
|
|
2017-04-12 10:52:52 -04:00
|
|
|
cancelChangeScheme() {
|
|
|
|
this.set("colorSchemeId", this.get("model.color_scheme_id"));
|
|
|
|
},
|
|
|
|
changeScheme() {
|
2019-05-27 04:15:39 -04:00
|
|
|
let schemeId = this.colorSchemeId;
|
2017-04-12 10:52:52 -04:00
|
|
|
this.set(
|
|
|
|
"model.color_scheme_id",
|
2019-11-12 04:47:42 -05:00
|
|
|
schemeId === null ? null : parseInt(schemeId, 10)
|
2017-04-12 10:52:52 -04:00
|
|
|
);
|
2019-05-27 04:15:39 -04:00
|
|
|
this.model.saveChanges("color_scheme_id");
|
2017-04-12 10:52:52 -04:00
|
|
|
},
|
|
|
|
startEditingName() {
|
|
|
|
this.set("oldName", this.get("model.name"));
|
|
|
|
this.set("editingName", true);
|
|
|
|
},
|
|
|
|
cancelEditingName() {
|
2019-05-27 04:15:39 -04:00
|
|
|
this.set("model.name", this.oldName);
|
2017-04-12 10:52:52 -04:00
|
|
|
this.set("editingName", false);
|
|
|
|
},
|
|
|
|
finishedEditingName() {
|
2019-05-27 04:15:39 -04:00
|
|
|
this.model.saveChanges("name");
|
2017-04-12 10:52:52 -04:00
|
|
|
this.set("editingName", false);
|
|
|
|
},
|
|
|
|
|
|
|
|
editTheme() {
|
2019-01-23 09:40:21 -05:00
|
|
|
if (this.get("model.remote_theme.is_git")) {
|
2017-04-12 10:52:52 -04:00
|
|
|
bootbox.confirm(
|
|
|
|
I18n.t("admin.customize.theme.edit_confirm"),
|
|
|
|
(result) => {
|
|
|
|
if (result) {
|
2018-09-06 14:56:00 -04:00
|
|
|
this.transitionToEditRoute();
|
2017-04-12 10:52:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} else {
|
2018-09-06 14:56:00 -04:00
|
|
|
this.transitionToEditRoute();
|
2017-04-12 10:52:52 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
applyDefault() {
|
2019-05-27 04:15:39 -04:00
|
|
|
const model = this.model;
|
2017-04-12 10:52:52 -04:00
|
|
|
model.saveChanges("default").then(() => {
|
|
|
|
if (model.get("default")) {
|
2019-05-27 04:15:39 -04:00
|
|
|
this.allThemes.forEach((theme) => {
|
2017-04-12 10:52:52 -04:00
|
|
|
if (theme !== model && theme.get("default")) {
|
|
|
|
theme.set("default", false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
applyUserSelectable() {
|
2019-05-27 04:15:39 -04:00
|
|
|
this.model.saveChanges("user_selectable");
|
2017-04-12 10:52:52 -04:00
|
|
|
},
|
|
|
|
|
2020-11-16 07:44:09 -05:00
|
|
|
applyAutoUpdateable() {
|
|
|
|
this.model.saveChanges("auto_update");
|
|
|
|
},
|
|
|
|
|
2017-04-12 10:52:52 -04:00
|
|
|
addChildTheme() {
|
2019-11-12 04:47:42 -05:00
|
|
|
let themeId = parseInt(this.selectedChildThemeId, 10);
|
2019-05-27 04:15:39 -04:00
|
|
|
let theme = this.allThemes.findBy("id", themeId);
|
2019-11-28 00:19:01 -05:00
|
|
|
this.model.addChildTheme(theme).then(() => this.store.findAll("theme"));
|
2017-04-12 10:52:52 -04:00
|
|
|
},
|
|
|
|
|
2017-05-09 17:20:28 -04:00
|
|
|
removeUpload(upload) {
|
2017-05-10 14:43:05 -04:00
|
|
|
return bootbox.confirm(
|
|
|
|
I18n.t("admin.customize.theme.delete_upload_confirm"),
|
|
|
|
I18n.t("no_value"),
|
|
|
|
I18n.t("yes_value"),
|
|
|
|
(result) => {
|
|
|
|
if (result) {
|
2019-05-27 04:15:39 -04:00
|
|
|
this.model.removeField(upload);
|
2017-05-10 14:43:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2017-05-09 17:20:28 -04:00
|
|
|
},
|
|
|
|
|
2017-04-12 10:52:52 -04:00
|
|
|
removeChildTheme(theme) {
|
2019-11-28 00:19:01 -05:00
|
|
|
this.model
|
|
|
|
.removeChildTheme(theme)
|
|
|
|
.then(() => this.store.findAll("theme"));
|
2017-04-12 10:52:52 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
destroy() {
|
|
|
|
return bootbox.confirm(
|
2019-05-10 14:14:12 -04:00
|
|
|
I18n.t("admin.customize.delete_confirm", {
|
|
|
|
theme_name: this.get("model.name"),
|
|
|
|
}),
|
2017-04-12 10:52:52 -04:00
|
|
|
I18n.t("no_value"),
|
|
|
|
I18n.t("yes_value"),
|
|
|
|
(result) => {
|
|
|
|
if (result) {
|
2019-05-27 04:15:39 -04:00
|
|
|
const model = this.model;
|
2019-12-09 16:43:26 -05:00
|
|
|
model.setProperties({ recentlyInstalled: false });
|
2017-04-12 10:52:52 -04:00
|
|
|
model.destroyRecord().then(() => {
|
2019-05-27 04:15:39 -04:00
|
|
|
this.allThemes.removeObject(model);
|
2017-04-12 10:52:52 -04:00
|
|
|
this.transitionToRoute("adminCustomizeThemes");
|
|
|
|
});
|
2018-06-15 11:03:24 -04:00
|
|
|
}
|
2017-04-12 10:52:52 -04:00
|
|
|
}
|
|
|
|
);
|
2018-08-23 21:30:00 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
switchType() {
|
2018-08-30 15:23:15 -04:00
|
|
|
const relatives = this.get("model.component")
|
2021-02-03 11:45:25 -05:00
|
|
|
? this.get("model.parentThemes")
|
2018-08-30 15:23:15 -04:00
|
|
|
: this.get("model.childThemes");
|
2021-02-03 11:45:25 -05:00
|
|
|
|
|
|
|
let message = I18n.t(`${this.convertKey}_alert_generic`);
|
|
|
|
|
2018-08-30 15:23:15 -04:00
|
|
|
if (relatives && relatives.length > 0) {
|
2021-02-03 11:45:25 -05:00
|
|
|
message = I18n.t(`${this.convertKey}_alert`, {
|
|
|
|
relatives: relatives
|
|
|
|
.map((relative) => relative.get("name"))
|
|
|
|
.join(", "),
|
|
|
|
});
|
2018-08-30 15:23:15 -04:00
|
|
|
}
|
2021-02-03 11:45:25 -05:00
|
|
|
|
|
|
|
bootbox.confirm(
|
|
|
|
message,
|
|
|
|
I18n.t("no_value"),
|
|
|
|
I18n.t("yes_value"),
|
|
|
|
(result) => {
|
|
|
|
if (result) {
|
|
|
|
this.commitSwitchType();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2019-07-03 04:18:11 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
enableComponent() {
|
|
|
|
this.model.set("enabled", true);
|
|
|
|
this.model
|
|
|
|
.saveChanges("enabled")
|
|
|
|
.catch(() => this.model.set("enabled", false));
|
|
|
|
},
|
|
|
|
|
|
|
|
disableComponent() {
|
|
|
|
this.model.set("enabled", false);
|
|
|
|
this.model
|
|
|
|
.saveChanges("enabled")
|
|
|
|
.catch(() => this.model.set("enabled", true));
|
2017-04-12 10:52:52 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|