2019-10-24 01:06:54 +08:00
|
|
|
import Controller from "@ember/controller";
|
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-07-31 03:05:08 +08:00
|
|
|
|
2019-10-24 01:06:54 +08:00
|
|
|
export default Controller.extend({
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("model.isSaving")
|
2019-07-31 03:05:08 +08:00
|
|
|
saveButtonText(isSaving) {
|
|
|
|
return isSaving ? I18n.t("saving") : I18n.t("admin.customize.save");
|
|
|
|
},
|
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("model.changed", "model.isSaving")
|
2019-07-31 03:05:08 +08:00
|
|
|
saveDisabled(changed, isSaving) {
|
|
|
|
return !changed || isSaving;
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
save() {
|
|
|
|
if (!this.model.saving) {
|
|
|
|
this.set("saving", true);
|
|
|
|
this.model
|
|
|
|
.update(this.model.getProperties("html", "css"))
|
|
|
|
.catch((e) => {
|
|
|
|
const msg =
|
|
|
|
e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors
|
|
|
|
? I18n.t("admin.customize.email_style.save_error_with_reason", {
|
|
|
|
error: e.jqXHR.responseJSON.errors.join(". "),
|
|
|
|
})
|
|
|
|
: I18n.t("generic_error");
|
|
|
|
bootbox.alert(msg);
|
|
|
|
})
|
|
|
|
.finally(() => this.set("model.changed", false));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|