mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 11:01:11 +08:00
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:
@ -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", {
|
||||
|
Reference in New Issue
Block a user