From ca422dc1a4a3758fe64e7b207c8a7a552377a5e5 Mon Sep 17 00:00:00 2001 From: Matt Enlow Date: Wed, 11 Jun 2014 15:36:54 -0600 Subject: [PATCH] Transition to editor.edit after saving a new post Closes #2860 - `editor-base-controller`'s `save` action returns a promise with the model after saving - `EditorNewController` will transition to `EditorEditController` upon a successful save (model has an id) - Removed a console.log in editor's save function --- core/client/controllers/editor/new.js | 19 +++++++++++++++++-- core/client/mixins/editor-base-controller.js | 6 +++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/core/client/controllers/editor/new.js b/core/client/controllers/editor/new.js index 0c5d6a07ca..13f246f69a 100644 --- a/core/client/controllers/editor/new.js +++ b/core/client/controllers/editor/new.js @@ -1,5 +1,20 @@ import EditorControllerMixin from 'ghost/mixins/editor-base-controller'; -var EditorNewController = Ember.ObjectController.extend(EditorControllerMixin); +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.transitionTo('editor.edit', model); + } + return model; + }); + } + } +}); -export default EditorNewController; +export default EditorNewController; \ No newline at end of file diff --git a/core/client/mixins/editor-base-controller.js b/core/client/mixins/editor-base-controller.js index f06722dc79..8f9ff061ff 100644 --- a/core/client/mixins/editor-base-controller.js +++ b/core/client/mixins/editor-base-controller.js @@ -22,10 +22,10 @@ var EditorControllerMixin = Ember.Mixin.create({ self = this; this.set('status', status); - this.get('model').save().then(function () { - console.log('saved'); + return this.get('model').save().then(function (model) { self.notifications.showSuccess('Post status saved as ' + - self.get('status') + '.'); + model.get('status') + '.'); + return model; }, this.notifications.showErrors); },