mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 08:24:05 +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;
|
var group = this;
|
||||||
group.set('disableSave', true);
|
group.set('disableSave', true);
|
||||||
|
|
||||||
return Discourse.ajax("/admin/groups/" + this.get('id'), {type: "PUT", data: {
|
return Discourse.ajax("/admin/groups/" + this.get('id'), {
|
||||||
group: {
|
type: "PUT",
|
||||||
name: this.get('name'),
|
data: {
|
||||||
usernames: this.get('usernames')
|
group: {
|
||||||
|
name: this.get('name'),
|
||||||
|
usernames: this.get('usernames')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
complete: function(){
|
||||||
|
group.set('disableSave', false);
|
||||||
}
|
}
|
||||||
}}).then(function(r){
|
}).then(null, function(e){
|
||||||
group.set('disableSave', false);
|
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"}}
|
{{userSelector usernames=usernames id="group-users" placeholderKey="admin.groups.selector_placeholder" tabindex="1" disabledBinding="automatic"}}
|
||||||
<div class='controls'>
|
<div class='controls'>
|
||||||
<button {{action save this}} {{bindAttr disabled="disableSave"}} class='btn'>{{i18n admin.customize.save}}</button>
|
|
||||||
{{#unless automatic}}
|
{{#unless automatic}}
|
||||||
|
<button {{action save this}} {{bindAttr disabled="disableSave"}} class='btn'>{{i18n admin.customize.save}}</button>
|
||||||
{{#if id}}
|
{{#if id}}
|
||||||
<a {{action destroy this}} class='delete-link'>{{i18n admin.customize.delete}}</a>
|
<a {{action destroy this}} class='delete-link'>{{i18n admin.customize.delete}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{else}}
|
||||||
|
{{i18n admin.groups.can_not_edit_automatic}}
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
</div>
|
</div>
|
||||||
{{/with}}
|
{{/with}}
|
||||||
|
@ -38,7 +40,7 @@
|
||||||
<div class='spinner'>{{i18n loading}}</div>
|
<div class='spinner'>{{i18n loading}}</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
nothing here yet
|
{{i18n admin.groups.about}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -20,9 +20,12 @@ class Admin::GroupsController < Admin::AdminController
|
||||||
can_not_modify_automatic
|
can_not_modify_automatic
|
||||||
else
|
else
|
||||||
group.usernames = params[:group][:usernames]
|
group.usernames = params[:group][:usernames]
|
||||||
group.name = params[:group][:name] if params[:name]
|
group.name = params[:group][:name] if params[:group][:name]
|
||||||
group.save!
|
if group.save
|
||||||
render json: "ok"
|
render json: "ok"
|
||||||
|
else
|
||||||
|
render_json_error group
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1042,6 +1042,8 @@ en:
|
||||||
edit: "Edit Groups"
|
edit: "Edit Groups"
|
||||||
selector_placeholder: "add users"
|
selector_placeholder: "add users"
|
||||||
name_placeholder: "Group name, no spaces, same as username rule"
|
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:
|
api:
|
||||||
title: "API"
|
title: "API"
|
||||||
|
|
|
@ -14,6 +14,11 @@ describe Group do
|
||||||
group.name = "this_is_a_name"
|
group.name = "this_is_a_name"
|
||||||
group.valid?.should be_true
|
group.valid?.should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "is invalid for non names" do
|
||||||
|
group.name = "this is_a_name"
|
||||||
|
group.valid?.should be_false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "Can update moderator/staff/admin groups correctly" do
|
it "Can update moderator/staff/admin groups correctly" do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user