2016-05-24 15:06:59 +03:00
|
|
|
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
|
|
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
|
2017-10-30 12:38:01 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2014-07-31 23:36:20 +04:00
|
|
|
|
2019-05-20 16:15:46 +03:00
|
|
|
export default AuthenticatedRoute.extend(CurrentUserSettings, {
|
2018-01-11 20:43:23 +03:00
|
|
|
settings: service(),
|
|
|
|
|
2015-11-15 14:06:49 +03:00
|
|
|
beforeModel() {
|
|
|
|
this._super(...arguments);
|
2021-07-08 16:37:31 +03:00
|
|
|
this.transitionAuthor(this.session.user);
|
|
|
|
this.transitionEditor(this.session.user);
|
2014-07-31 23:36:20 +04:00
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
model() {
|
2019-03-06 16:53:54 +03:00
|
|
|
return this.settings.reload();
|
2014-11-28 14:09:45 +03:00
|
|
|
},
|
|
|
|
|
2019-12-13 20:09:06 +03:00
|
|
|
deactivate() {
|
|
|
|
this._super(...arguments);
|
|
|
|
this.controller.set('leaveSettingsTransition', null);
|
|
|
|
this.controller.set('showLeaveSettingsModal', false);
|
|
|
|
},
|
|
|
|
|
2014-11-28 14:09:45 +03:00
|
|
|
actions: {
|
2015-10-28 14:36:45 +03:00
|
|
|
save() {
|
2019-03-06 16:53:54 +03:00
|
|
|
this.controller.send('save');
|
2017-10-31 18:27:25 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
willTransition(transition) {
|
2019-03-06 16:53:54 +03:00
|
|
|
let controller = this.controller;
|
|
|
|
let settings = this.settings;
|
2017-10-31 18:27:25 +03:00
|
|
|
let modelIsDirty = settings.get('hasDirtyAttributes');
|
|
|
|
|
|
|
|
if (modelIsDirty) {
|
|
|
|
transition.abort();
|
|
|
|
controller.send('toggleLeaveSettingsModal', transition);
|
|
|
|
return;
|
|
|
|
}
|
2014-11-28 14:09:45 +03:00
|
|
|
}
|
2019-05-20 18:16:19 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
buildRouteInfoMetadata() {
|
|
|
|
return {
|
|
|
|
titleToken: 'Settings - Code injection'
|
|
|
|
};
|
2014-07-31 23:36:20 +04:00
|
|
|
}
|
|
|
|
});
|