From 3ce45863ab646b312ad04b25fa9670bedb08497b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 2 Oct 2015 08:55:53 +0200 Subject: [PATCH] Modify the group user count when changing membership of a user --- settings/js/users/groups.js | 16 ++++++++++++---- settings/js/users/users.js | 5 +++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/settings/js/users/groups.js b/settings/js/users/groups.js index 322db6c1b4..c8d2ef7c5b 100644 --- a/settings/js/users/groups.js +++ b/settings/js/users/groups.js @@ -49,18 +49,26 @@ GroupList = { return parseInt($groupLiElement.data('usercount'), 10); }, - modEveryoneCount: function(diff) { - var $li = GroupList.getGroupLI(GroupList.everyoneGID); + modGroupCount: function(gid, diff) { + var $li = GroupList.getGroupLI(gid); var count = GroupList.getUserCount($li) + diff; GroupList.setUserCount($li, count); }, incEveryoneCount: function() { - GroupList.modEveryoneCount(1); + GroupList.modGroupCount(GroupList.everyoneGID, 1); }, decEveryoneCount: function() { - GroupList.modEveryoneCount(-1); + GroupList.modGroupCount(GroupList.everyoneGID, -1); + }, + + incGroupCount: function(gid) { + GroupList.modGroupCount(gid, 1); + }, + + decGroupCount: function(gid) { + GroupList.modGroupCount(gid, -1); }, getCurrentGID: function () { diff --git a/settings/js/users/users.js b/settings/js/users/users.js index 47d63c11b9..519fe9655d 100644 --- a/settings/js/users/users.js +++ b/settings/js/users/users.js @@ -470,6 +470,11 @@ var UserList = { UserList.availableGroups.push(groupName); } + if (response.data.action === 'add') { + GroupList.incGroupCount(groupName); + } else { + GroupList.decGroupCount(groupName); + } } if (response.data.message) { OC.Notification.show(response.data.message);