mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 09:03:45 +08:00
render error when people attempt to save an invalid group name
hide controls when we showing an automatic group
This commit is contained in:
parent
b97d186cb5
commit
0052e78bfe
|
@ -65,13 +65,20 @@ Discourse.Group = Discourse.Model.extend({
|
|||
var group = this;
|
||||
group.set('disableSave', true);
|
||||
|
||||
return Discourse.ajax("/admin/groups/" + this.get('id'), {type: "PUT", data: {
|
||||
group: {
|
||||
name: this.get('name'),
|
||||
usernames: this.get('usernames')
|
||||
return Discourse.ajax("/admin/groups/" + this.get('id'), {
|
||||
type: "PUT",
|
||||
data: {
|
||||
group: {
|
||||
name: this.get('name'),
|
||||
usernames: this.get('usernames')
|
||||
}
|
||||
},
|
||||
complete: function(){
|
||||
group.set('disableSave', false);
|
||||
}
|
||||
}}).then(function(r){
|
||||
group.set('disableSave', false);
|
||||
}).then(null, function(e){
|
||||
var message = $.parseJSON(e.responseText).errors;
|
||||
bootbox.alert(message);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,13 @@
|
|||
|
||||
{{userSelector usernames=usernames id="group-users" placeholderKey="admin.groups.selector_placeholder" tabindex="1" disabledBinding="automatic"}}
|
||||
<div class='controls'>
|
||||
<button {{action save this}} {{bindAttr disabled="disableSave"}} class='btn'>{{i18n admin.customize.save}}</button>
|
||||
{{#unless automatic}}
|
||||
<button {{action save this}} {{bindAttr disabled="disableSave"}} class='btn'>{{i18n admin.customize.save}}</button>
|
||||
{{#if id}}
|
||||
<a {{action destroy this}} class='delete-link'>{{i18n admin.customize.delete}}</a>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{i18n admin.groups.can_not_edit_automatic}}
|
||||
{{/unless}}
|
||||
</div>
|
||||
{{/with}}
|
||||
|
@ -38,7 +40,7 @@
|
|||
<div class='spinner'>{{i18n loading}}</div>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
nothing here yet
|
||||
{{i18n admin.groups.about}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -20,9 +20,12 @@ class Admin::GroupsController < Admin::AdminController
|
|||
can_not_modify_automatic
|
||||
else
|
||||
group.usernames = params[:group][:usernames]
|
||||
group.name = params[:group][:name] if params[:name]
|
||||
group.save!
|
||||
render json: "ok"
|
||||
group.name = params[:group][:name] if params[:group][:name]
|
||||
if group.save
|
||||
render json: "ok"
|
||||
else
|
||||
render_json_error group
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1042,6 +1042,8 @@ en:
|
|||
edit: "Edit Groups"
|
||||
selector_placeholder: "add users"
|
||||
name_placeholder: "Group name, no spaces, same as username rule"
|
||||
about: "Edit your group membership and names here"
|
||||
can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels"
|
||||
|
||||
api:
|
||||
title: "API"
|
||||
|
|
|
@ -14,6 +14,11 @@ describe Group do
|
|||
group.name = "this_is_a_name"
|
||||
group.valid?.should be_true
|
||||
end
|
||||
|
||||
it "is invalid for non names" do
|
||||
group.name = "this is_a_name"
|
||||
group.valid?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
it "Can update moderator/staff/admin groups correctly" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user