mirror of
https://github.com/discourse/discourse.git
synced 2026-08-08 20:18:23 -05:00
UX: simplifies editing email templates by always having a default (#10179)
This commit is contained in:
@@ -3,8 +3,12 @@ import discourseComputed from "discourse-common/utils/decorators";
|
||||
import Controller from "@ember/controller";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { bufferedProperty } from "discourse/mixins/buffered-content";
|
||||
import { action } from "@ember/object";
|
||||
import { inject as controller } from "@ember/controller";
|
||||
|
||||
export default Controller.extend(bufferedProperty("emailTemplate"), {
|
||||
adminCustomizeEmailTemplates: controller(),
|
||||
emailTemplate: null,
|
||||
saved: false,
|
||||
|
||||
@discourseComputed("buffered.body", "buffered.subject")
|
||||
@@ -23,35 +27,35 @@ export default Controller.extend(bufferedProperty("emailTemplate"), {
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
saveChanges() {
|
||||
this.set("saved", false);
|
||||
const buffered = this.buffered;
|
||||
this.emailTemplate
|
||||
.save(buffered.getProperties("subject", "body"))
|
||||
.then(() => {
|
||||
this.set("saved", true);
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
},
|
||||
@action
|
||||
saveChanges() {
|
||||
this.set("saved", false);
|
||||
const buffered = this.buffered;
|
||||
this.emailTemplate
|
||||
.save(buffered.getProperties("subject", "body"))
|
||||
.then(() => {
|
||||
this.set("saved", true);
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
},
|
||||
|
||||
revertChanges() {
|
||||
this.set("saved", false);
|
||||
bootbox.confirm(
|
||||
I18n.t("admin.customize.email_templates.revert_confirm"),
|
||||
result => {
|
||||
if (result) {
|
||||
this.emailTemplate
|
||||
.revert()
|
||||
.then(props => {
|
||||
const buffered = this.buffered;
|
||||
buffered.setProperties(props);
|
||||
this.commitBuffer();
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
}
|
||||
@action
|
||||
revertChanges() {
|
||||
this.set("saved", false);
|
||||
bootbox.confirm(
|
||||
I18n.t("admin.customize.email_templates.revert_confirm"),
|
||||
result => {
|
||||
if (result) {
|
||||
this.emailTemplate
|
||||
.revert()
|
||||
.then(props => {
|
||||
const buffered = this.buffered;
|
||||
buffered.setProperties(props);
|
||||
this.commitBuffer();
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { sort } from "@ember/object/computed";
|
||||
import { action } from "@ember/object";
|
||||
import Controller from "@ember/controller";
|
||||
|
||||
export default Controller.extend({
|
||||
emailTemplates: null,
|
||||
sortedTemplates: sort("emailTemplates", "titleSorting"),
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.titleSorting = ["title"];
|
||||
this.set("titleSorting", ["title"]);
|
||||
},
|
||||
|
||||
actions: {
|
||||
selectTemplate(template) {
|
||||
this.transitionToRoute("adminCustomizeEmailTemplates.edit", template);
|
||||
}
|
||||
@action
|
||||
onSelectTemplate(template) {
|
||||
this.transitionToRoute("adminCustomizeEmailTemplates.edit", template);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user