2020-05-14 04:23:41 +08:00
|
|
|
import I18n from "I18n";
|
2019-10-24 00:39:32 +08:00
|
|
|
import Route from "@ember/routing/route";
|
2022-10-07 23:38:27 +08:00
|
|
|
import { inject as service } from "@ember/service";
|
2020-08-27 00:57:13 +08:00
|
|
|
|
2019-10-24 00:39:32 +08:00
|
|
|
export default Route.extend({
|
2022-10-07 23:38:27 +08:00
|
|
|
dialog: service(),
|
2019-07-31 03:05:08 +08:00
|
|
|
model(params) {
|
|
|
|
return {
|
|
|
|
model: this.modelFor("adminCustomizeEmailStyle"),
|
|
|
|
fieldName: params.field_name,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
|
|
|
controller.setProperties({
|
|
|
|
fieldName: model.fieldName,
|
|
|
|
model: model.model,
|
|
|
|
});
|
|
|
|
this._shouldAlertUnsavedChanges = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
willTransition(transition) {
|
|
|
|
if (
|
|
|
|
this.get("controller.model.changed") &&
|
|
|
|
this._shouldAlertUnsavedChanges &&
|
|
|
|
transition.intent.name !== this.routeName
|
|
|
|
) {
|
|
|
|
transition.abort();
|
2022-10-07 23:38:27 +08:00
|
|
|
this.dialog.confirm({
|
|
|
|
message: I18n.t("admin.customize.theme.unsaved_changes_alert"),
|
|
|
|
confirmButtonLabel: "admin.customize.theme.discard",
|
|
|
|
cancelButtonLabel: "admin.customize.theme.stay",
|
|
|
|
didConfirm: () => {
|
|
|
|
this._shouldAlertUnsavedChanges = false;
|
|
|
|
transition.retry();
|
|
|
|
},
|
|
|
|
});
|
2019-07-31 03:05:08 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|