mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
a6c005e5be
no issue We weren't correctly clearing state for the "display modal" booleans when leaving screens. This meant that it was possible to end up in a state where where every time you access a screen you get the unsaved changes modal
60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
|
|
import RSVP from 'rsvp';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default AuthenticatedRoute.extend(CurrentUserSettings, {
|
|
config: service(),
|
|
settings: service(),
|
|
|
|
beforeModel() {
|
|
this._super(...arguments);
|
|
return this.get('session.user')
|
|
.then(this.transitionAuthor())
|
|
.then(this.transitionEditor());
|
|
},
|
|
|
|
model() {
|
|
return RSVP.hash({
|
|
settings: this.settings.reload(),
|
|
availableTimezones: this.get('config.availableTimezones')
|
|
});
|
|
},
|
|
|
|
setupController(controller, models) {
|
|
// reset the leave setting transition
|
|
controller.set('showLeaveSettingsModal', false);
|
|
controller.set('leaveSettingsTransition', null);
|
|
controller.set('availableTimezones', models.availableTimezones);
|
|
},
|
|
|
|
actions: {
|
|
save() {
|
|
return this.controller.send('save');
|
|
},
|
|
|
|
reloadSettings() {
|
|
return this.settings.reload();
|
|
},
|
|
|
|
willTransition(transition) {
|
|
let controller = this.controller;
|
|
let settings = this.settings;
|
|
let settingsIsDirty = settings.get('hasDirtyAttributes');
|
|
|
|
if (settingsIsDirty) {
|
|
transition.abort();
|
|
controller.send('toggleLeaveSettingsModal', transition);
|
|
return;
|
|
}
|
|
}
|
|
|
|
},
|
|
|
|
buildRouteInfoMetadata() {
|
|
return {
|
|
titleToken: 'Settings - General'
|
|
};
|
|
}
|
|
});
|