diff --git a/core/client/app/controllers/post-settings-menu.js b/core/client/app/controllers/post-settings-menu.js
index 6cbcc80fed..e790a5127f 100644
--- a/core/client/app/controllers/post-settings-menu.js
+++ b/core/client/app/controllers/post-settings-menu.js
@@ -330,7 +330,7 @@ export default Ember.Controller.extend(SettingsMenuMixin, {
// If errors, notify and exit.
if (errMessage) {
- this.showErrors(errMessage);
+ this.get('model.errors').add('post-setting-date', errMessage);
return;
}
@@ -356,47 +356,45 @@ export default Ember.Controller.extend(SettingsMenuMixin, {
},
setMetaTitle: function (metaTitle) {
- var self = this,
- currentTitle = this.get('model.meta_title') || '';
+ var property = 'meta_title',
+ model = this.get('model'),
+ currentTitle = model.get(property) || '';
// Only update if the title has changed
if (currentTitle === metaTitle) {
return;
}
- this.set('model.meta_title', metaTitle);
+ model.set(property, metaTitle);
// If this is a new post. Don't save the model. Defer the save
// to the user pressing the save button
- if (this.get('model.isNew')) {
+ if (model.get('isNew')) {
return;
}
- this.get('model').save().catch(function (errors) {
- self.showErrors(errors);
- });
+ model.save();
},
setMetaDescription: function (metaDescription) {
- var self = this,
- currentDescription = this.get('model.meta_description') || '';
+ var property = 'meta_description',
+ model = this.get('model'),
+ currentDescription = model.get(property) || '';
// Only update if the description has changed
if (currentDescription === metaDescription) {
return;
}
- this.set('model.meta_description', metaDescription);
+ model.set(property, metaDescription);
// If this is a new post. Don't save the model. Defer the save
// to the user pressing the save button
- if (this.get('model.isNew')) {
+ if (model.get('isNew')) {
return;
}
- this.get('model').save().catch(function (errors) {
- self.showErrors(errors);
- });
+ model.save();
},
setCoverImage: function (image) {
diff --git a/core/client/app/mixins/editor-base-controller.js b/core/client/app/mixins/editor-base-controller.js
index de668f3765..0fb8b5b4bd 100644
--- a/core/client/app/mixins/editor-base-controller.js
+++ b/core/client/app/mixins/editor-base-controller.js
@@ -224,10 +224,25 @@ export default Ember.Mixin.create({
notifications.showNotification(message.htmlSafe(), {delayed: delay});
},
- showErrorNotification: function (prevStatus, status, errors, delay) {
+ showErrorAlert: function (prevStatus, status, errors, delay) {
var message = this.messageMap.errors.post[prevStatus][status],
- error = (errors && errors[0] && errors[0].message) || 'Unknown Error',
- notifications = this.get('notifications');
+ notifications = this.get('notifications'),
+ error;
+
+ function isString(str) {
+ /*global toString*/
+ return toString.call(str) === '[object String]';
+ }
+
+ if (errors && isString(errors)) {
+ error = errors;
+ } else if (errors && errors[0] && isString(errors[0])) {
+ error = errors[0];
+ } else if (errors && errors[0] && errors[0].message && isString(errors[0].message)) {
+ error = errors[0].message;
+ } else {
+ error = 'Unknown Error';
+ }
message += '
' + error;
@@ -306,7 +321,8 @@ export default Ember.Mixin.create({
});
}).catch(function (errors) {
if (!options.silent) {
- self.showErrorNotification(prevStatus, self.get('model.status'), errors);
+ errors = errors || self.get('model.errors.messages');
+ self.showErrorAlert(prevStatus, self.get('model.status'), errors);
}
self.set('model.status', prevStatus);
diff --git a/core/client/app/templates/post-settings-menu.hbs b/core/client/app/templates/post-settings-menu.hbs
index 2c9f92c06b..73a2364098 100644
--- a/core/client/app/templates/post-settings-menu.hbs
+++ b/core/client/app/templates/post-settings-menu.hbs
@@ -21,17 +21,18 @@
{{/if}}
{{gh-url-preview slug=slugValue tagName="p" classNames="description"}}
-