mirror of
https://github.com/discourse/discourse.git
synced 2025-09-10 21:01:33 +08:00
Use existing function to extract error message.
This commit is contained in:
parent
086d31d53b
commit
25c7450ea7
1 changed files with 3 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
||||||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||||
import DiscourseURL from 'discourse/lib/url';
|
import DiscourseURL from 'discourse/lib/url';
|
||||||
|
import { extractError } from 'discourse/lib/ajax-error';
|
||||||
|
|
||||||
// Modal for editing / creating a category
|
// Modal for editing / creating a category
|
||||||
export default Ember.Controller.extend(ModalFunctionality, {
|
export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
|
@ -73,11 +74,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
model.setProperties({slug: result.category.slug, id: result.category.id });
|
model.setProperties({slug: result.category.slug, id: result.category.id });
|
||||||
DiscourseURL.redirectTo("/c/" + Discourse.Category.slugFor(model));
|
DiscourseURL.redirectTo("/c/" + Discourse.Category.slugFor(model));
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
if (error && error.responseText) {
|
self.flash(extractError(error), 'error');
|
||||||
self.flash($.parseJSON(error.responseText).errors[0], 'error');
|
|
||||||
} else {
|
|
||||||
self.flash(I18n.t('generic_error'), 'error');
|
|
||||||
}
|
|
||||||
self.set('saving', false);
|
self.set('saving', false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -94,13 +91,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
self.send('closeModal');
|
self.send('closeModal');
|
||||||
DiscourseURL.redirectTo("/categories");
|
DiscourseURL.redirectTo("/categories");
|
||||||
}, function(error){
|
}, function(error){
|
||||||
|
self.flash(extractError(error), 'error');
|
||||||
if (error && error.responseText) {
|
|
||||||
self.flash($.parseJSON(error.responseText).errors[0]);
|
|
||||||
} else {
|
|
||||||
self.flash(I18n.t('generic_error'));
|
|
||||||
}
|
|
||||||
|
|
||||||
self.send('reopenModal');
|
self.send('reopenModal');
|
||||||
self.displayErrors([I18n.t("category.delete_error")]);
|
self.displayErrors([I18n.t("category.delete_error")]);
|
||||||
self.set('deleting', false);
|
self.set('deleting', false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue