Ghost/ghost/admin/app/routes/settings/navigation.js
Kevin Ansfield ca46d92086 Fix unsaved nav settings persisting across transitions
closes #5852
- resets navigation settings controller's model when transitioning away
- fixes `locationType` config setting so acceptance tests don't mess with the URL
- configure the ephemeral session store for ember-simple-auth during tests
- adds dummy env-config meta fields so acceptance tests don't fail
- adds `ember-cli-simple-auth-testing` dependency for auth testing helpers
- adds Pretender dependency to mock API requests for acceptance tests
2015-10-07 15:57:14 +01:00

39 lines
1.2 KiB
JavaScript

import AuthenticatedRoute from 'ghost/routes/authenticated';
import CurrentUserSettings from 'ghost/mixins/current-user-settings';
import styleBody from 'ghost/mixins/style-body';
export default AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'Settings - Navigation',
classNames: ['settings-view-navigation'],
beforeModel: function (transition) {
this._super(transition);
return this.get('session.user')
.then(this.transitionAuthor());
},
model: function () {
return this.store.query('setting', {type: 'blog,theme'}).then(function (records) {
return records.get('firstObject');
});
},
actions: {
save: function () {
// since shortcuts are run on the route, we have to signal to the components
// on the page that we're about to save.
$('.page-actions .btn-blue').focus();
this.get('controller').send('save');
},
willTransition: function () {
// reset the model so that our CPs re-calc and unsaved changes aren't
// persisted across transitions
this.set('controller.model', null);
return this._super(...arguments);
}
}
});