2019-10-31 04:28:29 +08:00
|
|
|
import { reads } from "@ember/object/computed";
|
2019-10-24 00:30:52 +08:00
|
|
|
import Component from "@ember/component";
|
2019-07-31 03:05:08 +08:00
|
|
|
import computed from "ember-addons/ember-computed-decorators";
|
|
|
|
|
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-10-24 03:41:58 +08:00
|
|
|
@computed("fieldName")
|
|
|
|
currentEditorMode(fieldName) {
|
|
|
|
return fieldName === "css" ? "scss" : fieldName;
|
|
|
|
},
|
|
|
|
|
2019-07-31 03:05:08 +08:00
|
|
|
@computed("fieldName", "styles.html", "styles.css")
|
|
|
|
resetDisabled(fieldName) {
|
|
|
|
return (
|
|
|
|
this.get(`styles.${fieldName}`) ===
|
|
|
|
this.get(`styles.default_${fieldName}`)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
@computed("styles", "fieldName")
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|