From: Arthur Schiwon Date: Tue, 8 Jul 2014 18:05:51 +0000 (+0200) Subject: increase/decrease everyone count on user creation/deletion X-Git-Tag: v8.0.0alpha1~1117^2~7 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e2c935d6fb05d340164a941bc05f616e2fcbb5d7;p=nextcloud-server.git increase/decrease everyone count on user creation/deletion --- diff --git a/settings/js/users/groups.js b/settings/js/users/groups.js index c3e3d1a50c9..f74c54bbd87 100644 --- a/settings/js/users/groups.js +++ b/settings/js/users/groups.js @@ -10,6 +10,7 @@ var $userGroupList; var GroupList; GroupList = { activeGID: '', + everyoneGID: '_everyone', addGroup: function (gid, usercount) { var $li = $userGroupList.find('.isgroup:last-child').clone(); @@ -27,7 +28,7 @@ GroupList = { setUserCount: function (groupLiElement, usercount) { var $groupLiElement = $(groupLiElement); - if (usercount === undefined || usercount === 0) { + if (usercount === undefined || usercount === 0 || usercount < 0) { usercount = ''; } $groupLiElement.data('usercount', usercount); @@ -38,6 +39,20 @@ GroupList = { return parseInt($groupLiElement.data('usercount'), 10); }, + modEveryoneCount: function(diff) { + $li = GroupList.getGroupLI(GroupList.everyoneGID); + count = GroupList.getUserCount($li) + diff; + GroupList.setUserCount($li, count); + }, + + incEveryoneCount: function() { + GroupList.modEveryoneCount(1); + }, + + decEveryoneCount: function() { + GroupList.modEveryoneCount(-1); + }, + getCurrentGID: function () { return GroupList.activeGID; }, diff --git a/settings/js/users/users.js b/settings/js/users/users.js index 923dd9fcfb9..60e1e1dd31f 100644 --- a/settings/js/users/users.js +++ b/settings/js/users/users.js @@ -237,7 +237,7 @@ var UserList = { show: function(uid) { UserList.getRow(uid).show(); }, - remove: function(uid) { + markRemove: function(uid) { $tr = UserList.getRow(uid); groups = $tr.find('.groups .groupsselect').val(); for(i in groups) { @@ -251,9 +251,29 @@ var UserList = { } GroupList.setUserCount($li, newUserCount); } - + GroupList.decEveryoneCount(); + UserList.hide(uid); + }, + remove: function(uid) { UserList.getRow(uid).remove(); }, + undoRemove: function(uid) { + $tr = UserList.getRow(uid); + groups = $tr.find('.groups .groupsselect').val(); + for(i in groups) { + var gid = groups[i]; + $li = GroupList.getGroupLI(gid); + userCount = GroupList.getUserCount($li); + if(userCount == 1) { + newUserCount = ''; + } else { + newUserCount = userCount + 1; + } + GroupList.setUserCount($li, newUserCount); + } + GroupList.incEveryoneCount(); + UserList.getRow(uid).show(); + }, has: function(uid) { return UserList.getRow(uid).length > 0; }, @@ -271,14 +291,14 @@ var UserList = { initDeleteHandling: function() { //set up handler UserDeleteHandler = new DeleteHandler('removeuser.php', 'username', - UserList.hide, UserList.remove); + UserList.markRemove, UserList.remove); //configure undo OC.Notification.hide(); var msg = escapeHTML(t('settings', 'deleted {userName}', {userName: '%oid'})) + '' + escapeHTML(t('settings', 'undo')) + ''; UserDeleteHandler.setNotification(OC.Notification, 'deleteuser', msg, - UserList.show); + UserList.undoRemove); //when to mark user for delete $userListBody.on('click', '.delete', function () { @@ -482,11 +502,9 @@ $(document).ready(function () { UserList.doSort(); UserList.availableGroups = $userList.data('groups'); - UserList.scrollArea = $('#app-content'); UserList.scrollArea.scroll(function(e) {UserList._onScroll(e);}); - $userList.after($('')); $('.groupsselect').each(function (index, element) { @@ -639,6 +657,7 @@ $(document).ready(function () { UserList.add(username, username, result.data.groups, null, 'default', result.data.storageLocation, 0, true); } $('#newusername').focus(); + GroupList.incEveryoneCount(); } } ); diff --git a/settings/templates/users/part.grouplist.php b/settings/templates/users/part.grouplist.php index 588c2e6202c..c5e85fa3534 100644 --- a/settings/templates/users/part.grouplist.php +++ b/settings/templates/users/part.grouplist.php @@ -12,7 +12,7 @@ -
  • +
  • " class="isgroup"> t('Everyone')); ?>