2019-10-24 00:30:52 +08:00
|
|
|
import Component from "@ember/component";
|
2020-05-14 04:23:41 +08:00
|
|
|
import I18n from "I18n";
|
2020-08-27 00:57:13 +08:00
|
|
|
import bootbox from "bootbox";
|
2019-11-08 05:38:28 +08:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2019-10-31 04:28:29 +08:00
|
|
|
import { reads } from "@ember/object/computed";
|
2019-07-31 03:05:08 +08:00
|
|
|
|
2019-10-24 00:30:52 +08:00
|
|
|
export default Component.extend({
|
2019-10-31 04:28:29 +08:00
|
|
|
editorId: reads("fieldName"),
|
2019-07-31 03:05:08 +08:00
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("fieldName")
|
2019-10-24 03:41:58 +08:00
|
|
|
currentEditorMode(fieldName) {
|
|
|
|
return fieldName === "css" ? "scss" : fieldName;
|
|
|
|
},
|
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("fieldName", "styles.html", "styles.css")
|
2019-07-31 03:05:08 +08:00
|
|
|
resetDisabled(fieldName) {
|
|
|
|
return (
|
|
|
|
this.get(`styles.${fieldName}`) ===
|
|
|
|
this.get(`styles.default_${fieldName}`)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("styles", "fieldName")
|
2019-07-31 03:05:08 +08:00
|
|
|
editorContents: {
|
|
|
|
get(styles, fieldName) {
|
|
|
|
return styles[fieldName];
|
|
|
|
},
|
|
|
|
set(value, styles, fieldName) {
|
|
|
|
styles.setField(fieldName, value);
|
|
|
|
return value;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
reset() {
|
|
|
|
bootbox.confirm(
|
|
|
|
I18n.t("admin.customize.email_style.reset_confirm", {
|
|
|
|
fieldName: I18n.t(`admin.customize.email_style.${this.fieldName}`),
|
|
|
|
}),
|
|
|
|
I18n.t("no_value"),
|
|
|
|
I18n.t("yes_value"),
|
|
|
|
(result) => {
|
|
|
|
if (result) {
|
|
|
|
this.styles.setField(
|
|
|
|
this.fieldName,
|
|
|
|
this.styles.get(`default_${this.fieldName}`)
|
|
|
|
);
|
|
|
|
this.notifyPropertyChange("editorContents");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
2021-05-04 19:56:10 +08:00
|
|
|
save() {
|
|
|
|
this.attrs.save();
|
|
|
|
},
|
2019-07-31 03:05:08 +08:00
|
|
|
},
|
|
|
|
});
|