2016-06-30 13:21:47 +03:00
|
|
|
import $ from 'jquery';
|
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-02-21 22:04:50 +03:00
|
|
|
import RSVP from 'rsvp';
|
2017-05-29 21:50:03 +03:00
|
|
|
import styleBody from 'ghost-admin/mixins/style-body';
|
2017-10-30 12:38:01 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2015-01-11 22:55:52 +03:00
|
|
|
|
2015-08-19 14:55:40 +03:00
|
|
|
export default AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
|
2017-10-30 12:38:01 +03:00
|
|
|
settings: service(),
|
2015-01-11 22:55:52 +03:00
|
|
|
|
2017-03-17 20:16:21 +03:00
|
|
|
titleToken: 'Settings - Design',
|
2017-02-21 22:04:50 +03:00
|
|
|
classNames: ['settings-view-design'],
|
|
|
|
|
2015-11-15 14:06:49 +03:00
|
|
|
beforeModel() {
|
|
|
|
this._super(...arguments);
|
2015-04-14 18:04:16 +03:00
|
|
|
return this.get('session.user')
|
|
|
|
.then(this.transitionAuthor());
|
2015-01-11 22:55:52 +03:00
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
model() {
|
2017-02-21 22:04:50 +03:00
|
|
|
return RSVP.hash({
|
2017-03-17 20:16:21 +03:00
|
|
|
settings: this.get('settings').reload(),
|
2017-02-21 22:04:50 +03:00
|
|
|
themes: this.get('store').findAll('theme')
|
2015-01-11 22:55:52 +03:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-01-11 01:57:43 +03:00
|
|
|
setupController(controller) {
|
2017-10-31 18:27:25 +03:00
|
|
|
// reset the leave setting transition
|
|
|
|
controller.set('leaveSettingsTransition', null);
|
2017-02-21 22:04:50 +03:00
|
|
|
controller.set('themes', this.get('store').peekAll('theme'));
|
2016-02-09 20:16:18 +03:00
|
|
|
this.get('controller').send('reset');
|
|
|
|
},
|
|
|
|
|
2015-01-14 17:46:29 +03:00
|
|
|
actions: {
|
2015-10-28 14:36:45 +03:00
|
|
|
save() {
|
2015-01-18 03:16:54 +03:00
|
|
|
// since shortcuts are run on the route, we have to signal to the components
|
|
|
|
// on the page that we're about to save.
|
2017-02-16 22:50:05 +03:00
|
|
|
$('.page-actions .gh-btn-blue').focus();
|
2015-01-18 03:16:54 +03:00
|
|
|
|
2015-01-14 17:46:29 +03:00
|
|
|
this.get('controller').send('save');
|
2015-10-05 09:07:44 +03:00
|
|
|
},
|
|
|
|
|
2017-10-31 18:27:25 +03:00
|
|
|
willTransition(transition) {
|
|
|
|
let controller = this.get('controller');
|
|
|
|
let modelIsDirty = controller.get('dirtyAttributes');
|
|
|
|
|
|
|
|
if (modelIsDirty) {
|
|
|
|
transition.abort();
|
|
|
|
controller.send('toggleLeaveSettingsModal', transition);
|
|
|
|
return;
|
|
|
|
}
|
2017-02-21 22:04:50 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
activateTheme(theme) {
|
2017-03-03 18:31:42 +03:00
|
|
|
return this.get('controller').send('activateTheme', theme);
|
2015-01-14 17:46:29 +03:00
|
|
|
}
|
2015-01-11 22:55:52 +03:00
|
|
|
}
|
|
|
|
});
|