summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-04-16 22:16:55 +0200
committerArthur Schiwon <blizzz@owncloud.com>2014-06-02 12:53:56 +0200
commitd87347e64ef90b89b1ff2b2221514b6fe1c57086 (patch)
treefef75eb9a08ce3dd5068d09154d141bed2561e46
parent3c9788d40ccdad168eefbd75ba74e9550ee3805b (diff)
downloadnextcloud-server-d87347e64ef90b89b1ff2b2221514b6fe1c57086.tar.gz
nextcloud-server-d87347e64ef90b89b1ff2b2221514b6fe1c57086.zip
update GroupList when a users is added or removed to a group
-rw-r--r--settings/js/users/groups.js16
-rw-r--r--settings/js/users/users.js10
2 files changed, 17 insertions, 9 deletions
diff --git a/settings/js/users/groups.js b/settings/js/users/groups.js
index 25b865cf18d..4c555bd4c86 100644
--- a/settings/js/users/groups.js
+++ b/settings/js/users/groups.js
@@ -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);
diff --git a/settings/js/users/users.js b/settings/js/users/users.js
index e9c85d20e95..d1cab63eaab 100644
--- a/settings/js/users/users.js
+++ b/settings/js/users/users.js
@@ -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);