* Fix bug #25147,25148.

This commit is contained in:
caoyanyi
2022-07-13 10:20:19 +08:00
parent d99ad53452
commit bbc2fdce3a
5 changed files with 27 additions and 23 deletions
+7 -5
View File
@@ -42,20 +42,20 @@ function addItem(obj)
{
var item = $('#addItem').html().replace(/%i%/g, itemIndex);
var $tr = $('<tr class="addedItem">' + item + '</tr>').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();
}
+9 -7
View File
@@ -40,22 +40,22 @@ function savePriv()
*/
function addItem(obj)
{
var item = $('#addItem').html().replace(/%i%/g, itemIndex);
var $tr = $('<tr class="addedItem">' + item + '</tr>').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 = $('<tr class="addedItem">' + item + '</tr>').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();
}
+6 -6
View File
@@ -23,9 +23,9 @@
<?php foreach($hasAccessBranches as $branch):?>
<tr>
<td><?php echo html::input("names[$i]", $branch->name, "class='form-control' readonly");?></td>
<td><?php echo html::select("mergeLevels[$i]", $lang->gitlab->branch->branchCreationLevelList, $branch->mergeAccess, "class='form-control chosen'");?></td>
<td><?php echo html::select("mergeLevels[$i]", $lang->gitlab->branch->branchCreationLevelList, $branch->mergeAccess, "class='form-control user-picker'");?></td>
<td>
<?php echo html::select("pushLevels[$i]", $lang->gitlab->branch->branchCreationLevelList, $branch->pushAccess, "class='form-control chosen'");?>
<?php echo html::select("pushLevels[$i]", $lang->gitlab->branch->branchCreationLevelList, $branch->pushAccess, "class='form-control user-picker'");?>
<?php echo html::hidden("branches[$i]", $branch->name);?>
</td>
<td class='c-actions text-center'>
@@ -40,8 +40,8 @@
<?php for($j = 0; $j < 5; $j ++):?>
<tr class='addedItem'>
<td><?php echo html::select("branches[$i]", array(''=>'') + $noAccessBranches, '', "class='form-control user-picker'");?></td>
<td><?php echo html::select("mergeLevels[$i]", $lang->gitlab->branch->branchCreationLevelList, 40, "class='form-control chosen'");?></td>
<td><?php echo html::select("pushLevels[$i]", $lang->gitlab->branch->branchCreationLevelList, 40, "class='form-control chosen'");?></td>
<td><?php echo html::select("mergeLevels[$i]", $lang->gitlab->branch->branchCreationLevelList, 40, "class='form-control user-picker'");?></td>
<td><?php echo html::select("pushLevels[$i]", $lang->gitlab->branch->branchCreationLevelList, 40, "class='form-control user-picker'");?></td>
<td class='c-actions text-center'>
<?php echo html::a('javascript:;', "<i class='icon-plus'></i>", '', "onclick='addItem(this)' class='btn btn-link'");?>
<?php echo html::a('javascript:;', "<i class='icon icon-close'></i>", '', "onclick='deleteItem(this)' class='btn btn-link'");?>
@@ -70,8 +70,8 @@
<table class='hidden'>
<tr id='addItem' class='hidden'>
<td><?php echo html::select("branches[]", array(''=>'') + $noAccessBranches, '', "class='form-control'");?></td>
<td><?php echo html::select("mergeLevels[]", $lang->gitlab->branch->branchCreationLevelList, 40, "class='form-control chosen'");?></td>
<td><?php echo html::select("pushLevels[]", $lang->gitlab->branch->branchCreationLevelList, 40, "class='form-control chosen'");?></td>
<td><?php echo html::select("mergeLevels[]", $lang->gitlab->branch->branchCreationLevelList, 40, "class='form-control'");?></td>
<td><?php echo html::select("pushLevels[]", $lang->gitlab->branch->branchCreationLevelList, 40, "class='form-control'");?></td>
<td class='c-actions text-center'>
<?php echo html::a('javascript:;', "<i class='icon-plus'></i>", '', "onclick='addItem(this)' class='btn btn-link'");?>
<?php echo html::a('javascript:;', "<i class='icon icon-close'></i>", '', "onclick='deleteItem(this)' class='btn btn-link'");?>
+3 -3
View File
@@ -22,7 +22,7 @@
<?php foreach($hasAccessTags as $tag):?>
<tr>
<td><?php echo html::input("names[$i]", $tag->name, "class='form-control' readonly");?></td>
<td><?php echo html::select("createLevels[$i]", $lang->gitlab->branch->branchCreationLevelList, $tag->createAccess, "class='form-control chosen'");?></td>
<td><?php echo html::select("createLevels[$i]", $lang->gitlab->branch->branchCreationLevelList, $tag->createAccess, "class='form-control user-picker'");?></td>
<td class='c-actions text-center'>
<?php echo html::hidden("tags[$i]", $tag->name);?>
<?php echo html::a('javascript:;', "<i class='icon-plus'></i>", '', "onclick='addItem(this)' class='btn btn-link'");?>
@@ -36,7 +36,7 @@
<?php for($j = 0; $j < 5; $j ++):?>
<tr class='addedItem'>
<td><?php echo html::select("tags[$i]", array(''=>'') + $noAccessTags, '', "class='form-control user-picker'");?></td>
<td><?php echo html::select("createLevels[$i]", $lang->gitlab->branch->branchCreationLevelList, 40, "class='form-control chosen'");?></td>
<td><?php echo html::select("createLevels[$i]", $lang->gitlab->branch->branchCreationLevelList, 40, "class='form-control user-picker'");?></td>
<td class='c-actions text-center'>
<?php echo html::a('javascript:;', "<i class='icon-plus'></i>", '', "onclick='addItem(this)' class='btn btn-link'");?>
<?php echo html::a('javascript:;', "<i class='icon icon-close'></i>", '', "onclick='deleteItem(this)' class='btn btn-link'");?>
@@ -65,7 +65,7 @@
<table class='hidden'>
<tr id='addItem' class='hidden'>
<td><?php echo html::select("tags[]", array(''=>'') + $noAccessTags, '', "class='form-control'");?></td>
<td><?php echo html::select("createLevels[]", $lang->gitlab->branch->branchCreationLevelList, 40, "class='form-control chosen'");?></td>
<td><?php echo html::select("createLevels[]", $lang->gitlab->branch->branchCreationLevelList, 40, "class='form-control'");?></td>
<td class='c-actions text-center'>
<?php echo html::a('javascript:;', "<i class='icon-plus'></i>", '', "onclick='addItem(this)' class='btn btn-link'");?>
<?php echo html::a('javascript:;', "<i class='icon icon-close'></i>", '', "onclick='deleteItem(this)' class='btn btn-link'");?>
+2 -2
View File
@@ -145,7 +145,7 @@ class repo extends control
$this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->create;
$this->view->position[] = $this->lang->repo->create;
$this->view->groups = $this->loadModel('group')->getPairs();
$this->view->users = $this->loadModel('user')->getPairs('noletter|noempty|nodeleted');
$this->view->users = $this->loadModel('user')->getPairs('noletter|noempty|nodeleted|noclosed');
$this->view->products = $products;
$this->view->productID = $productID;
$this->view->serviceHosts = $this->loadModel('gitlab')->getPairs();
@@ -202,7 +202,7 @@ class repo extends control
$this->view->repoID = $repoID;
$this->view->objectID = $objectID;
$this->view->groups = $this->loadModel('group')->getPairs();
$this->view->users = $this->loadModel('user')->getPairs('noletter|noempty|nodeleted');
$this->view->users = $this->loadModel('user')->getPairs('noletter|noempty|nodeleted|noclosed');
$this->view->products = $objectID ? $this->loadModel('product')->getProductPairsByProject($objectID) : $this->loadModel('product')->getPairs();
$this->view->serviceHosts = array('' => '') + $this->loadModel('pipeline')->getPairs($repo->SCM);