mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
4a987bfc15
closes #2910 - create EditorController, PostSettingsMenuController - remove `posts.post` controllerName dependency on EditorRoute/NewRoute - `{{render}}` the PostSettingsMenuView with its own controller - break up properties/methods from PostsPostController into all three controllers - fix EditorRoute pagination options to now be comparable to PostsRoute - add NewController to force NewRoute to refresh editor with blank model. Identical to Editor's - EditorController and NewController are based on a shared mixin - NewView created, templateName is 'editor'
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
/* global console */
|
|
|
|
var EditorControllerMixin = Ember.Mixin.create({
|
|
//## Computed post properties
|
|
isPublished: Ember.computed.equal('status', 'published'),
|
|
isDraft: Ember.computed.equal('status', 'draft'),
|
|
/**
|
|
* By default, a post will not change its publish state.
|
|
* Only with a user-set value (via setSaveType action)
|
|
* can the post's status change.
|
|
*/
|
|
willPublish: function (key, val) {
|
|
if (val) {
|
|
return val;
|
|
}
|
|
return this.get('isPublished');
|
|
}.property('isPublished'),
|
|
|
|
actions: {
|
|
save: function () {
|
|
var status = this.get('willPublish') ? 'published' : 'draft',
|
|
self = this;
|
|
|
|
this.set('status', status);
|
|
this.get('model').save().then(function () {
|
|
console.log('saved');
|
|
self.notifications.showSuccess('Post status saved as <strong>' +
|
|
self.get('status') + '</strong>.');
|
|
}, this.notifications.showErrors);
|
|
},
|
|
|
|
setSaveType: function (newType) {
|
|
if (newType === 'publish') {
|
|
this.set('willPublish', true);
|
|
} else if (newType === 'draft') {
|
|
this.set('willPublish', false);
|
|
} else {
|
|
console.warn('Received invalid save type; ignoring.');
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
export default EditorControllerMixin;
|