mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-24 08:09:13 -05:00
Merge pull request #1250 from sir-pinecone/display-group-save-errors
display group validation errors in alert modal
This commit is contained in:
commit
a09c9f08a8
2 changed files with 15 additions and 5 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue