From bbc2fdce3a18e7d8d58c965492c827a1413bd70f Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Wed, 13 Jul 2022 10:20:19 +0800 Subject: [PATCH 1/3] * Fix bug #25147,25148. --- module/gitlab/js/managebranchpriv.js | 12 +++++++----- module/gitlab/js/managetagpriv.js | 16 +++++++++------- module/gitlab/view/managebranchpriv.html.php | 12 ++++++------ module/gitlab/view/managetagpriv.html.php | 6 +++--- module/repo/control.php | 4 ++-- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/module/gitlab/js/managebranchpriv.js b/module/gitlab/js/managebranchpriv.js index 4a8fcb1cf7..9ce313c324 100644 --- a/module/gitlab/js/managebranchpriv.js +++ b/module/gitlab/js/managebranchpriv.js @@ -42,20 +42,20 @@ function addItem(obj) { var item = $('#addItem').html().replace(/%i%/g, itemIndex); var $tr = $('' + item + '').insertAfter($(obj).closest('tr')); - var $accounts = $tr.find('select:first').addClass('user-picker').trigger('list:updated').picker({type: 'user'}); + var $branches = $tr.find('select').addClass('user-picker').trigger('list:updated').picker({type: 'user'}); itemIndex++; var disabledItems = []; $('.user-picker[name^=branches]').each(function() { - if(this === $accounts[0]) return; + if(this === $branches[0]) return; var $select = $(this); - var picker = $select.data('zui.picker'); + var picker = $select.data('zui.picker'); if(!picker) return; var selectItem = picker.getListItem(picker.getValue()); if(selectItem) disabledItems.push($.extend({}, selectItem, {disabled: true})); }); - if(disabledItems.length) $accounts.data('zui.picker').updateOptionList(disabledItems); + if(disabledItems.length) $branches.data('zui.picker').updateOptionList(disabledItems); } /** @@ -67,6 +67,8 @@ function addItem(obj) */ function deleteItem(obj) { - if($('#privForm .table-form tbody').children().length < 2) return false; + if($('#privForm .table tbody').children().length < 2) return false; + + $(obj).closest('tr').find('.picker .picker-selection-remove').click(); $(obj).closest('tr').remove(); } diff --git a/module/gitlab/js/managetagpriv.js b/module/gitlab/js/managetagpriv.js index d7ab47bfd1..8593340bad 100644 --- a/module/gitlab/js/managetagpriv.js +++ b/module/gitlab/js/managetagpriv.js @@ -40,22 +40,22 @@ function savePriv() */ function addItem(obj) { - var item = $('#addItem').html().replace(/%i%/g, itemIndex); - var $tr = $('' + item + '').insertAfter($(obj).closest('tr')); - var $accounts = $tr.find('select:first').addClass('user-picker').trigger('list:updated').picker({type: 'user'}); + var item = $('#addItem').html().replace(/%i%/g, itemIndex); + var $tr = $('' + item + '').insertAfter($(obj).closest('tr')); + var $tags = $tr.find('select').addClass('user-picker').trigger('list:updated').picker({type: 'user'}); itemIndex++; var disabledItems = []; $('.user-picker[name^=tags]').each(function() { - if(this === $accounts[0]) return; + if(this === $tags[0]) return; var $select = $(this); - var picker = $select.data('zui.picker'); + var picker = $select.data('zui.picker'); if(!picker) return; var selectItem = picker.getListItem(picker.getValue()); if(selectItem) disabledItems.push($.extend({}, selectItem, {disabled: true})); }); - if(disabledItems.length) $accounts.data('zui.picker').updateOptionList(disabledItems); + if(disabledItems.length) $tags.data('zui.picker').updateOptionList(disabledItems); } /** @@ -67,6 +67,8 @@ function addItem(obj) */ function deleteItem(obj) { - if($('#privForm .table-form tbody').children().length < 2) return false; + if($('#privForm .table tbody').children().length < 2) return false; + + $(obj).closest('tr').find('.picker .picker-selection-remove').click(); $(obj).closest('tr').remove(); } diff --git a/module/gitlab/view/managebranchpriv.html.php b/module/gitlab/view/managebranchpriv.html.php index 714a03bda1..52ea2da2e4 100644 --- a/module/gitlab/view/managebranchpriv.html.php +++ b/module/gitlab/view/managebranchpriv.html.php @@ -23,9 +23,9 @@ name, "class='form-control' readonly");?> - gitlab->branch->branchCreationLevelList, $branch->mergeAccess, "class='form-control chosen'");?> + gitlab->branch->branchCreationLevelList, $branch->mergeAccess, "class='form-control user-picker'");?> - gitlab->branch->branchCreationLevelList, $branch->pushAccess, "class='form-control chosen'");?> + gitlab->branch->branchCreationLevelList, $branch->pushAccess, "class='form-control user-picker'");?> name);?> @@ -40,8 +40,8 @@ '') + $noAccessBranches, '', "class='form-control user-picker'");?> - gitlab->branch->branchCreationLevelList, 40, "class='form-control chosen'");?> - gitlab->branch->branchCreationLevelList, 40, "class='form-control chosen'");?> + gitlab->branch->branchCreationLevelList, 40, "class='form-control user-picker'");?> + gitlab->branch->branchCreationLevelList, 40, "class='form-control user-picker'");?> ", '', "onclick='addItem(this)' class='btn btn-link'");?> ", '', "onclick='deleteItem(this)' class='btn btn-link'");?> @@ -70,8 +70,8 @@ - - + + - + - +