* [bug#55370,doing,1h] reset account items.
This commit is contained in:
@@ -2247,9 +2247,14 @@ class execution extends control
|
||||
|
||||
if($execution->type == 'kanban') $this->lang->execution->copyTeamTitle = str_replace($this->lang->execution->common, $this->lang->execution->kanban, $this->lang->execution->copyTeamTitle);
|
||||
|
||||
$users = $this->loadModel('user')->getPairs('noclosed|nodeleted|devfirst', $appendUsers);
|
||||
$userItems = array();
|
||||
foreach($users as $account => $realName) $userItems[$account] = array('value' => $account, 'text' => $realName, 'keys' => $account, 'disabled' => false);
|
||||
|
||||
$this->view->title = $this->lang->execution->manageMembers . $this->lang->hyphen . $execution->name;
|
||||
$this->view->execution = $execution;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted|devfirst', $appendUsers);
|
||||
$this->view->users = $users;
|
||||
$this->view->userItems = $userItems;
|
||||
$this->view->roles = $this->user->getUserRoles(array_keys($this->view->users));
|
||||
$this->view->dept = $dept;
|
||||
$this->view->depts = $this->dept->getOptionMenu();
|
||||
|
||||
@@ -29,24 +29,9 @@ window.deleteItem = function(obj)
|
||||
if($('#teamForm .table tbody').children().length < 2) return false;
|
||||
$(obj).closest('tr').remove();
|
||||
|
||||
resetAccountItems();
|
||||
if(!currentAccount) return true;
|
||||
|
||||
let accountItems = JSON.parse(JSON.stringify(users));
|
||||
$('#teamForm [name^=account]').each(function()
|
||||
{
|
||||
if(!$(this).val()) return true;
|
||||
delete accountItems[$(this).val()];
|
||||
});
|
||||
|
||||
const userItems = [];
|
||||
for(let key in accountItems) userItems.push({text: accountItems[key], value: key});
|
||||
|
||||
$('#teamForm [name^=account]').each(function()
|
||||
{
|
||||
let $accountPicker = $(this).closest('input[name^=account]').zui('picker');
|
||||
if(typeof $accountPicker == 'undefined') return true;
|
||||
$accountPicker.render({items: userItems});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,4 +77,31 @@ window.setRole = function(roleID)
|
||||
const role = roles[account];
|
||||
const $role = $('#role' + roleID);
|
||||
$role.val(role);
|
||||
|
||||
resetAccountItems();
|
||||
}
|
||||
|
||||
function resetAccountItems()
|
||||
{
|
||||
let selectedAccounts = [];
|
||||
$('#teamForm [name^=account]').each(function()
|
||||
{
|
||||
if(!$(this).val()) return true;
|
||||
selectedAccounts.push($(this).val());
|
||||
});
|
||||
|
||||
$('#teamForm [name^=account]').each(function()
|
||||
{
|
||||
let $accountPicker = $(this).closest('input[name^=account]').zui('picker');
|
||||
if(typeof $accountPicker == 'undefined') return true;
|
||||
|
||||
let userItems = $accountPicker.options.items;
|
||||
let currentAccount = $(this).val();
|
||||
for(let key in userItems)
|
||||
{
|
||||
let disabled = selectedAccounts.includes(userItems[key].value) && userItems[key].value != currentAccount ? true : false;
|
||||
userItems[key].disabled = disabled;
|
||||
}
|
||||
$accountPicker.render({items: userItems});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace zin;
|
||||
|
||||
jsVar('users', $users);
|
||||
jsVar('roles', $roles);
|
||||
jsVar('team2Import', $team2Import);
|
||||
jsVar('executionID', $execution->id);
|
||||
@@ -92,7 +91,7 @@ foreach($teamMembers as $member)
|
||||
set::id("account{$i}"),
|
||||
set::name("account[$i]"),
|
||||
set::value($member->account),
|
||||
set::items($users),
|
||||
set::items(array_values($userItems)),
|
||||
set::maxItemsCount($config->maxCount),
|
||||
set('onchange', "setRole('{$i}')")
|
||||
)
|
||||
@@ -148,7 +147,7 @@ foreach($teamMembers as $member)
|
||||
)
|
||||
);
|
||||
|
||||
if(in_array($member->memberType, array('default', 'dept'))) unset($users[$member->account]);
|
||||
if(in_array($member->memberType, array('default', 'dept'))) $userItems[$member->account]['disabled'] = true;
|
||||
$i ++;
|
||||
}
|
||||
|
||||
@@ -165,7 +164,7 @@ h::table
|
||||
(
|
||||
set::id("account{$i}"),
|
||||
set::name("account[$i]"),
|
||||
set::items($users),
|
||||
set::items(array_values($userItems)),
|
||||
set::maxItemsCount($config->maxCount),
|
||||
set('onchange', "setRole('{$i}')")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user