0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Merge pull request #4547 from jaswilli/post-saving

Prevent silent failures and recover after error.
This commit is contained in:
Hannah Wolfe 2014-12-01 10:46:28 +00:00
commit 2088fed5f7
2 changed files with 14 additions and 3 deletions

View file

@ -109,6 +109,10 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
promise = Ember.RSVP.resolve(afterSave).then(function () { promise = Ember.RSVP.resolve(afterSave).then(function () {
return self.get('slugGenerator').generateSlug(title).then(function (slug) { return self.get('slugGenerator').generateSlug(title).then(function (slug) {
self.set(destination, slug); self.set(destination, slug);
}).catch(function () {
// Nothing to do (would be nice to log this somewhere though),
// but a rejected promise needs to be handled here so that a resolved
// promise is returned.
}); });
}); });

View file

@ -116,6 +116,12 @@ EditorControllerMixin = Ember.Mixin.create(MarkerManager, {
return true; return true;
} }
// if the Adapter failed to save the model isError will be true
// and we should consider the model still dirty.
if (model.get('isError')) {
return true;
}
// models created on the client always return `isDirty: true`, // models created on the client always return `isDirty: true`,
// so we need to see which properties have actually changed. // so we need to see which properties have actually changed.
if (model.get('isNew')) { if (model.get('isNew')) {
@ -182,9 +188,10 @@ EditorControllerMixin = Ember.Mixin.create(MarkerManager, {
}, },
showErrorNotification: function (prevStatus, status, errors, delay) { showErrorNotification: function (prevStatus, status, errors, delay) {
var message = this.messageMap.errors.post[prevStatus][status]; var message = this.messageMap.errors.post[prevStatus][status],
error = (errors && errors[0] && errors[0].message) || 'Unknown Error';
message += '<br />' + errors[0].message; message += '<br />' + error;
this.notifications.showError(message, {delayed: delay}); this.notifications.showError(message, {delayed: delay});
}, },
@ -257,7 +264,7 @@ EditorControllerMixin = Ember.Mixin.create(MarkerManager, {
self.set('status', prevStatus); self.set('status', prevStatus);
return Ember.RSVP.reject(errors); return self.get('model');
}); });
psmController.set('lastPromise', promise); psmController.set('lastPromise', promise);