]> source.dussan.org Git - nextcloud-server.git/commitdiff
Extra non-available groups also in list
authorVincent Petry <pvince81@owncloud.com>
Wed, 24 Aug 2016 08:03:07 +0000 (10:03 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Mon, 29 Aug 2016 11:34:28 +0000 (13:34 +0200)
settings/js/users/users.js

index 7922cd9c65650d9b3a2a9b7a2a7afea70ef8dca5..f24bf82209b196db70b7f580d8609c1bcc3d0f35 100644 (file)
@@ -565,6 +565,7 @@ var UserList = {
                var placeholder = $groupsListContainer.attr('data-placeholder') || t('settings', 'no group');
                var user = UserList.getUID($td);
                var checked = $td.data('groups') || [];
+               var extraGroups = [].concat(checked);
 
                $td.find('.multiselectoptions').remove();
 
@@ -576,12 +577,25 @@ var UserList = {
                        $groupsSelect = $('<select multiple="multiple" class="subadminsselect multiselect button" title="' + placeholder + '"></select>')
                }
 
-               $.each(this.availableGroups, function (i, group) {
+               function createItem(group) {
                        if (isSubadminSelect && group === 'admin') {
                                // can't become subadmin of "admin" group
                                return;
                        }
                        $groupsSelect.append($('<option value="' + escapeHTML(group) + '">' + escapeHTML(group) + '</option>'));
+               }
+
+               $.each(this.availableGroups, function (i, group) {
+                       // some new groups might be selected but not in the available groups list yet
+                       var extraIndex = extraGroups.indexOf(group);
+                       if (extraIndex >= 0) {
+                               // remove extra group as it was found
+                               extraGroups.splice(extraIndex, 1);
+                       }
+                       createItem(group);
+               });
+               $.each(extraGroups, function (i, group) {
+                       createItem(group);
                });
 
                $td.append($groupsSelect);
@@ -779,7 +793,6 @@ $(document).ready(function () {
        });
 
        $('#newuser .groupsListContainer').on('click', function (event) {
-               var $target = $(event.target);
                event.stopPropagation();
                var $div = $(this).closest('.groups');
                UserList._triggerGroupEdit($div);