Ghost/ghost/admin/app/routes/settings/general.js
Kevin Ansfield bb7df76af0 Refactored styleBody mixin
no issue
- removed `styleBody` mixin in favour of using Ember's `buildRouteInfoMetadata` hook and router events in the `ui` service
- refactored separate CSS classes for each unauthenticated route into a single `.unauthenticated-route` class because hiding mobile nav whilst unauthenticated was the only use for body classes
2019-05-20 14:57:21 +01:00

55 lines
1.5 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(),
titleToken: 'Settings - General',
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('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;
}
}
}
});