Improved Group Member Management on User Administration

Allows for a quick and easy group membership management on the
user-administration page. Uses the select2 UI component to
autosuggest other groups, remove existing ones and lock in automatic
groups.
This commit is contained in:
Benjamin Kampmann
2014-07-13 20:11:38 +02:00
parent 2a40c04480
commit ac3f1ba3d6
7 changed files with 96 additions and 9 deletions

View File

@ -25,6 +25,12 @@ Discourse.AdminUserIndexController = Discourse.ObjectController.extend({
primaryGroupDirty: Discourse.computed.propertyNotEqual('originalPrimaryGroupId', 'primary_group_id'),
custom_groups: function(){
return this.get("model.groups").filter(function(g){
return (!g.automatic && g.visible);
});
}.property("model.groups.[]"),
actions: {
toggleTitleEdit: function() {
this.toggleProperty('editingTitle');
@ -45,6 +51,28 @@ Discourse.AdminUserIndexController = Discourse.ObjectController.extend({
this.get('model').generateApiKey();
},
groupAdded: function(added){
var self = this;
Discourse.ajax("/admin/users/" + this.get('id') + "/groups", {
type: 'POST',
data: {group_id: added.id}
}).then(function () {
self.get('model.groups').pushObject(added);
}).catch(function() {
bootbox.alert(I18n.t('generic_error'));
});
},
groupRemoved: function(removed){
var self = this;
Discourse.ajax("/admin/users/" + this.get('id') + "/groups/" + removed.id, {
type: 'DELETE'
}).then(function () {
self.set('model.groups.[]', self.get('model.groups').rejectBy("id", removed.id));
}).catch(function() {
bootbox.alert(I18n.t('generic_error'));
});
},
savePrimaryGroup: function() {
var self = this;
Discourse.ajax("/admin/users/" + this.get('id') + "/primary_group", {