2014-10-28 17:29:42 +03:00
|
|
|
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
2014-11-04 06:31:10 +03:00
|
|
|
import base from 'ghost/mixins/editor-base-route';
|
2014-03-10 07:44:08 +04:00
|
|
|
|
2015-06-13 17:34:09 +03:00
|
|
|
export default AuthenticatedRoute.extend(base, {
|
2014-11-25 23:56:08 +03:00
|
|
|
titleToken: 'Editor',
|
|
|
|
|
2014-05-21 17:53:00 +04:00
|
|
|
model: function () {
|
2014-07-17 09:54:32 +04:00
|
|
|
var self = this;
|
|
|
|
return this.get('session.user').then(function (user) {
|
|
|
|
return self.store.createRecord('post', {
|
|
|
|
author: user
|
|
|
|
});
|
|
|
|
});
|
2014-06-06 05:18:03 +04:00
|
|
|
},
|
|
|
|
|
2015-06-13 17:34:09 +03:00
|
|
|
renderTemplate: function (controller, model) {
|
|
|
|
this.render('editor/edit', {
|
|
|
|
controller: controller,
|
|
|
|
model: model
|
|
|
|
});
|
|
|
|
|
|
|
|
this.render('post-settings-menu', {
|
|
|
|
into: 'application',
|
|
|
|
outlet: 'settings-menu',
|
|
|
|
model: model
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-06-06 05:18:03 +04:00
|
|
|
setupController: function (controller, model) {
|
2014-10-26 02:29:58 +03:00
|
|
|
var psm = this.controllerFor('post-settings-menu');
|
|
|
|
|
|
|
|
// make sure there are no titleObserver functions hanging around
|
|
|
|
// from previous posts
|
|
|
|
psm.removeObserver('titleScratch', psm, 'titleObserver');
|
|
|
|
|
2014-12-01 22:42:35 +03:00
|
|
|
// Ensure that the PSM Image Uploader and Publish Date selector resets
|
2014-11-22 04:42:03 +03:00
|
|
|
psm.send('resetUploader');
|
2014-12-01 22:42:35 +03:00
|
|
|
psm.send('resetPubDate');
|
2014-11-22 04:42:03 +03:00
|
|
|
|
2014-11-04 06:31:10 +03:00
|
|
|
this._super(controller, model);
|
2015-07-04 21:25:55 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
willTransition: function (transition) {
|
|
|
|
// decorate the transition object so the editor.edit route
|
|
|
|
// knows this was the previous active route
|
|
|
|
transition.data.fromNew = true;
|
|
|
|
|
|
|
|
this._super(...arguments);
|
|
|
|
}
|
2014-03-10 07:44:08 +04:00
|
|
|
}
|
|
|
|
});
|