Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Extra non-available groups also in list
  • Loading branch information
Vincent Petry authored and blizzz committed Aug 29, 2016
commit 17964a89553b15db6edef680fba42ef89a473d98
17 changes: 15 additions & 2 deletions settings/js/users/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down