update GroupList when a users is added or removed to a group
This commit is contained in:
parent
3c9788d40c
commit
d87347e64e
|
@ -7,15 +7,11 @@
|
|||
|
||||
var GroupList = {
|
||||
addGroup: function(gid, usercount) {
|
||||
if(usercount === undefined || usercount === 0) {
|
||||
usercount = '';
|
||||
}
|
||||
var li = $('li[data-gid]').last().clone();
|
||||
var ul = $('li[data-gid]').first().parent();
|
||||
li.attr('data-gid', gid);
|
||||
li.attr('data-usercount', usercount);
|
||||
li.find('a span').first().text(gid);
|
||||
li.find('span[class=usercount]').first().text(usercount);
|
||||
GroupList.setUserCount(li, usercount);
|
||||
|
||||
$(li).appendTo(ul);
|
||||
|
||||
|
@ -24,6 +20,14 @@
|
|||
return li;
|
||||
},
|
||||
|
||||
setUserCount: function(groupLiElement, usercount) {
|
||||
if(usercount === undefined || usercount === 0) {
|
||||
usercount = '';
|
||||
}
|
||||
groupLiElement.attr('data-usercount', usercount);
|
||||
groupLiElement.find('span[class=usercount]').first().text(usercount);
|
||||
},
|
||||
|
||||
sortGroups: function(usercount) {
|
||||
var lis = $('li[data-gid]').filterAttr('data-usercount', usercount.toString()).get();
|
||||
var ul = $(lis).first().parent();
|
||||
|
@ -93,6 +97,8 @@
|
|||
$.each(result.data, function (i, subset) {
|
||||
$.each(subset, function (index, group) {
|
||||
if($('li[data-gid="' + group.name + '"]').length > 0) {
|
||||
var li = $('li[data-gid="' + group.name + '"]');
|
||||
GroupList.setUserCount(li, group.usercount);
|
||||
return true;
|
||||
}
|
||||
var li = GroupList.addGroup(group.name, group.usercount);
|
||||
|
|
|
@ -289,10 +289,12 @@ var UserList = {
|
|||
group: group
|
||||
},
|
||||
function (response) {
|
||||
if(response.status === 'success'
|
||||
&& UserList.availableGroups.indexOf(response.data.groupname) === -1
|
||||
&& response.data.action === 'add') {
|
||||
UserList.availableGroups.push(response.data.groupname);
|
||||
if(response.status === 'success') {
|
||||
GroupList.update();
|
||||
if(UserList.availableGroups.indexOf(response.data.groupname) === -1
|
||||
&& response.data.action === 'add') {
|
||||
UserList.availableGroups.push(response.data.groupname);
|
||||
}
|
||||
}
|
||||
if(response.data.message) {
|
||||
OC.Notification.show(response.data.message);
|
||||
|
|
Loading…
Reference in New Issue