Ghost/ghost/admin/controllers/editor/new.js
Felix Rieseberg beba43b8f3 Ensure editor awareness if publishing fails
closes #3667
- If the ‘save’ function on a new post fails, the local Ember model
still beliefs that the status is ‘published’, resulting in wrong
buttons. A simple catch fixes that.
2014-08-14 11:05:05 -07:00

23 lines
667 B
JavaScript

import EditorControllerMixin from 'ghost/mixins/editor-base-controller';
var EditorNewController = Ember.ObjectController.extend(EditorControllerMixin, {
actions: {
/**
* Redirect to editor after the first save
*/
save: function () {
var self = this;
this._super().then(function (model) {
if (model.get('id')) {
self.transitionToRoute('editor.edit', model);
}
}).catch(function () {
// Publishing failed
self.set('status', 'draft');
});
}
}
});
export default EditorNewController;