2019-10-23 12:30:52 -04:00
|
|
|
import Component from "@ember/component";
|
2020-05-13 16:23:41 -04:00
|
|
|
import I18n from "I18n";
|
2020-08-26 12:57:13 -04:00
|
|
|
import bootbox from "bootbox";
|
2019-11-07 16:38:28 -05:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2019-10-30 16:28:29 -04:00
|
|
|
import { reads } from "@ember/object/computed";
|
2019-07-30 15:05:08 -04:00
|
|
|
|
2019-10-23 12:30:52 -04:00
|
|
|
export default Component.extend({
|
2019-10-30 16:28:29 -04:00
|
|
|
editorId: reads("fieldName"),
|
2019-07-30 15:05:08 -04:00
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("fieldName")
|
2019-10-23 15:41:58 -04:00
|
|
|
currentEditorMode(fieldName) {
|
|
|
|
return fieldName === "css" ? "scss" : fieldName;
|
|
|
|
},
|
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("fieldName", "styles.html", "styles.css")
|
2019-07-30 15:05:08 -04:00
|
|
|
resetDisabled(fieldName) {
|
|
|
|
return (
|
|
|
|
this.get(`styles.${fieldName}`) ===
|
|
|
|
this.get(`styles.default_${fieldName}`)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("styles", "fieldName")
|
2019-07-30 15:05:08 -04: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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|