Merge pull request #1250 from sir-pinecone/display-group-save-errors

display group validation errors in alert modal
This commit is contained in:
Sam 2013-07-23 22:39:23 -07:00
commit a09c9f08a8
2 changed files with 15 additions and 5 deletions

View file

@ -60,13 +60,20 @@ Discourse.Group = Discourse.Model.extend({
name: this.get('name'),
usernames: this.get('usernames')
}
}}).then(function(r){
}}).then(function(resp) {
group.set('disableSave', false);
group.set('id', r.id);
group.set('id', resp.id);
}, function (error) {
group.set('disableSave', false);
if (error && error.responseText) {
bootbox.alert($.parseJSON(error.responseText).errors);
}
else {
bootbox.alert(I18n.t('generic_error'));
}
});
},
save: function(){
var group = this;
group.set('disableSave', true);

View file

@ -33,8 +33,11 @@ class Admin::GroupsController < Admin::AdminController
group = Group.new
group.name = params[:group][:name]
group.usernames = params[:group][:usernames] if params[:group][:usernames]
group.save!
render_serialized(group, BasicGroupSerializer)
if group.save
render_serialized(group, BasicGroupSerializer)
else
render_json_error group
end
end
def destroy