automatic groups should not allow you to muck with the listed users in the group
This commit is contained in:
parent
7c73140674
commit
b97d186cb5
|
@ -1,4 +1,3 @@
|
|||
<!-- work in progress, please ignore -->
|
||||
<div class='row groups'>
|
||||
<div class='content-list span6'>
|
||||
<h3>{{i18n admin.groups.edit}}</h3>
|
||||
|
@ -25,7 +24,7 @@
|
|||
{{textField value=name placeholderKey="admin.groups.name_placeholder"}}
|
||||
{{/if}}
|
||||
|
||||
{{userSelector usernames=usernames id="group-users" placeholderKey="admin.groups.selector_placeholder" tabindex="1"}}
|
||||
{{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}}
|
||||
|
|
|
@ -18,6 +18,7 @@ $.fn.autocomplete = function(options) {
|
|||
alert("only supporting one matcher at the moment");
|
||||
}
|
||||
|
||||
var disabled = options && options.disabled;
|
||||
var wrap = null;
|
||||
var autocompleteOptions = null;
|
||||
var selectedOption = null;
|
||||
|
@ -87,7 +88,7 @@ $.fn.autocomplete = function(options) {
|
|||
if (isInput) {
|
||||
var width = this.width();
|
||||
var height = this.height();
|
||||
wrap = this.wrap("<div class='ac-wrap clearfix'/>").parent();
|
||||
wrap = this.wrap("<div class='ac-wrap clearfix" + (disabled ? " disabled": "") + "'/>").parent();
|
||||
wrap.width(width);
|
||||
this.width(150);
|
||||
this.attr('name', this.attr('name') + "-renamed");
|
||||
|
|
|
@ -8,6 +8,8 @@ Discourse.UserSelector = Discourse.TextField.extend({
|
|||
$(this.get('element')).val(this.get('usernames')).autocomplete({
|
||||
template: Discourse.UserSelector.templateFunction(),
|
||||
|
||||
disabled: this.get('disabled'),
|
||||
|
||||
dataSource: function(term) {
|
||||
var exclude = selected;
|
||||
if (userSelectorView.get('excludeCurrentUser')){
|
||||
|
|
|
@ -342,15 +342,24 @@
|
|||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
div.ac-wrap.disabled {
|
||||
input {
|
||||
display:none;
|
||||
}
|
||||
.item a {
|
||||
display:none;
|
||||
}
|
||||
}
|
||||
|
||||
div.ac-wrap {
|
||||
background-color: $white;
|
||||
border: 1px solid #cccccc;
|
||||
padding: 4px 10px;
|
||||
padding: 5px 10px 0;
|
||||
@include border-radius-all(3px);
|
||||
div.item {
|
||||
float: left;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 5px;
|
||||
span {
|
||||
padding-left: 5px;
|
||||
height: 22px;
|
||||
|
@ -519,4 +528,4 @@ div.ac-wrap {
|
|||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,14 @@ class Admin::GroupsController < Admin::AdminController
|
|||
|
||||
def update
|
||||
group = Group.find(params[:id].to_i)
|
||||
render_json_error if group.automatic
|
||||
group.usernames = params[:group][:usernames]
|
||||
group.name = params[:group][:name] if params[:name]
|
||||
group.save!
|
||||
render json: "ok"
|
||||
if group.automatic
|
||||
can_not_modify_automatic
|
||||
else
|
||||
group.usernames = params[:group][:usernames]
|
||||
group.name = params[:group][:name] if params[:name]
|
||||
group.save!
|
||||
render json: "ok"
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -33,8 +36,17 @@ class Admin::GroupsController < Admin::AdminController
|
|||
|
||||
def destroy
|
||||
group = Group.find(params[:id].to_i)
|
||||
render_json_error if group.automatic
|
||||
group.destroy
|
||||
render json: "ok"
|
||||
if group.automatic
|
||||
can_not_modify_automatic
|
||||
else
|
||||
group.destroy
|
||||
render json: "ok"
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def can_not_modify_automatic
|
||||
render json: {errors: I18n.t('groups.errors.can_not_modify_automatic')}, status: 422
|
||||
end
|
||||
end
|
||||
|
|
|
@ -195,7 +195,6 @@ class ApplicationController < ActionController::Base
|
|||
user
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def render_json_error(obj)
|
||||
|
|
|
@ -56,6 +56,8 @@ en:
|
|||
private_message_abbrev: "PM"
|
||||
|
||||
groups:
|
||||
errors:
|
||||
can_not_modify_automatic: "You can not modify an automatic group"
|
||||
default_names:
|
||||
admins: "admins"
|
||||
moderators: "moderators"
|
||||
|
|
Loading…
Reference in New Issue