displays a message when a failure happen while creating a new category

This commit is contained in:
Régis Hanol
2013-03-14 22:25:55 +01:00
parent 4f42110e39
commit 3bf6625aa4
5 changed files with 13 additions and 6 deletions
@@ -1,7 +1,7 @@
<div class="modal-body">
<div class="modal-body">
<form>
<label>{{i18n category.name}}</label>
{{view Discourse.TextField valueBinding="view.category.name" placeholderKey="category.name_placeholder"}}
{{view Discourse.TextField valueBinding="view.category.name" placeholderKey="category.name_placeholder" maxlength="50"}}
<div class='description-controls' style="margin-bottom: 20px">
<label>{{i18n category.description}}</label>
@@ -12,7 +12,7 @@
<a href="#" {{action showCategoryTopic target="view"}}>{{i18n category.change_in_category_topic}}</a>
{{/if}}
{{else}}
{{i18n category.no_description}}
{{i18n category.no_description}}
{{#if view.category.topic_url}}
<a {{action showCategoryTopic target="view"}} href="#">{{i18n category.change_in_category_topic}}</a>
{{/if}}}
@@ -31,4 +31,4 @@
</div>
<div class="modal-footer">
<button class='btn btn-primary' {{bindAttr disabled="view.disabled"}} {{action saveCategory target="view"}}>{{view.buttonTitle}}</button>
</div>
</div>
@@ -59,7 +59,12 @@ Discourse.EditCategoryView = Discourse.ModalBodyView.extend({
_this.saveSuccess(result);
},
error: function(errors) {
// displays a generic error message when none is sent from the server
// this might happen when some "after" callbacks throws an exception server-side
if(errors.length === 0) errors.push(Em.String.i18n("category.creation_error"));
// display the errors
_this.displayErrors(errors);
// not saving anymore
_this.set('saving', false);
}
});