diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2015-06-19 08:29:25 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2015-06-19 08:29:25 +0200 |
commit | 6adddb3095abc447c30fb3f8c46c26507895c660 (patch) | |
tree | 43a766e7af4c844d416195f17ab463fc71fc3e79 /settings/js | |
parent | a5eb2f01a9722abfee0aba9fdfaaa723f77dd47f (diff) | |
parent | 497fe93b6c0a7de212e69ec8a343867cb4904dca (diff) | |
download | nextcloud-server-6adddb3095abc447c30fb3f8c46c26507895c660.tar.gz nextcloud-server-6adddb3095abc447c30fb3f8c46c26507895c660.zip |
Merge pull request #16889 from owncloud/group-sorting-fixes
Only sort by group name when LDAP is involved
Diffstat (limited to 'settings/js')
-rw-r--r-- | settings/js/users/groups.js | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/settings/js/users/groups.js b/settings/js/users/groups.js index 0fcca39843f..d205e915508 100644 --- a/settings/js/users/groups.js +++ b/settings/js/users/groups.js @@ -5,7 +5,8 @@ * See the COPYING-README file. */ -var $userGroupList; +var $userGroupList, + $sortGroupBy; var GroupList; GroupList = { @@ -27,6 +28,11 @@ GroupList = { }, setUserCount: function (groupLiElement, usercount) { + if ($sortGroupBy !== 1) { + // If we don't sort by group count we dont display them either + return; + } + var $groupLiElement = $(groupLiElement); if (usercount === undefined || usercount === 0 || usercount < 0) { usercount = ''; @@ -63,6 +69,33 @@ GroupList = { var lis = $userGroupList.find('.isgroup').get(); lis.sort(function (a, b) { + // "Everyone" always at the top + if ($(a).data('gid') === '_everyone') { + return -1; + } else if ($(b).data('gid') === '_everyone') { + return 1; + } + + // "admin" always as second + if ($(a).data('gid') === 'admin') { + return -1; + } else if ($(b).data('gid') === 'admin') { + return 1; + } + + if ($sortGroupBy === 1) { + // Sort by user count first + var $usersGroupA = $(a).data('usercount'), + $usersGroupB = $(b).data('usercount'); + if ($usersGroupA > 0 && $usersGroupA > $usersGroupB) { + return -1; + } + if ($usersGroupB > 0 && $usersGroupB > $usersGroupA) { + return 1; + } + } + + // Fallback or sort by group name return UserList.alphanum( $(a).find('a span').text(), $(b).find('a span').text() @@ -113,7 +146,8 @@ GroupList = { OC.generateUrl('/settings/users/groups'), { pattern: filter.getPattern(), - filterGroups: filter.filterGroups ? 1 : 0 + filterGroups: filter.filterGroups ? 1 : 0, + sortGroups: $sortGroupBy }, function (result) { @@ -271,8 +305,11 @@ GroupList = { $(document).ready( function () { $userGroupList = $('#usergrouplist'); GroupList.initDeleteHandling(); - // TODO: disabled due to performance issues - // GroupList.getEveryoneCount(); + $sortGroupBy = $userGroupList.data('sort-groups'); + if ($sortGroupBy === 1) { + // Disabled due to performance issues, when we don't need it for sorting + GroupList.getEveryoneCount(); + } // Display or hide of Create Group List Element $('#newgroup-form').hide(); |