WIP: review uses of notifications.showErrors

issue #5409

`notifications.showErrors` was historically used to display multiple error notifications whether from validation errors or responses form the API. This usage needs to be reviewed as inline validations should handle the validation side and we should be displaying alerts for actual errors.

Eventually `notifications.showErrors` should be left unused and therefore removed.
This commit is contained in:
Kevin Ansfield 2015-07-21 18:56:17 +01:00
parent 7ab232e770
commit 61e5ebdd2f
5 changed files with 10 additions and 12 deletions

View File

@ -16,7 +16,7 @@ export default Ember.Controller.extend({
self.store.unloadAll('post');
self.store.unloadAll('tag');
}).catch(function (response) {
self.get('notifications').showErrors(response);
self.get('notifications').showAPIError(response);
});
},

View File

@ -78,6 +78,10 @@ export default Ember.Controller.extend({
}
}).catch(function (errors) {
newUser.deleteRecord();
// TODO: user model includes ValidationEngine mixin so
// save is overridden in order to validate, we probably
// want to use inline-validations here and only show an
// alert if we have an actual error
self.get('notifications').showErrors(errors);
});
}

View File

@ -12,7 +12,7 @@ export default Ember.Controller.extend({
this.get('model').save().then(function (model) {
return model;
}).catch(function (err) {
notifications.showErrors(err);
notifications.showAPIError(err);
});
},

View File

@ -33,8 +33,8 @@ export default Ember.Controller.extend(ValidationEngine, {
var credentials = this.getProperties('newPassword', 'ne2Password', 'token'),
self = this;
this.toggleProperty('submitting');
this.validate({format: false}).then(function () {
this.validate().then(function () {
self.toggleProperty('submitting');
ajax({
url: self.get('ghostPaths.url').api('authentication', 'passwordreset'),
type: 'PUT',
@ -52,9 +52,6 @@ export default Ember.Controller.extend(ValidationEngine, {
self.get('notifications').showAPIError(response);
self.toggleProperty('submitting');
});
}).catch(function (error) {
self.toggleProperty('submitting');
self.get('notifications').showErrors(error);
});
}
}

View File

@ -8,12 +8,9 @@ export default Ember.Controller.extend({
var notifications = this.get('notifications');
return this.get('model').save().then(function (model) {
notifications.closeNotifications();
return model;
}).catch(function (errors) {
notifications.closeNotifications();
notifications.showErrors(errors);
}).catch(function (error) {
notifications.showAPIError(error);
});
}
}