diff --git a/module/execution/control.php b/module/execution/control.php index 4503528b28..d1ebc35f28 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -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(); diff --git a/module/execution/js/managemembers.ui.js b/module/execution/js/managemembers.ui.js index da08a1e43a..23d016bede 100644 --- a/module/execution/js/managemembers.ui.js +++ b/module/execution/js/managemembers.ui.js @@ -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}); + }); } diff --git a/module/execution/ui/managemembers.html.php b/module/execution/ui/managemembers.html.php index 902eee6a64..5f7af62393 100644 --- a/module/execution/ui/managemembers.html.php +++ b/module/execution/ui/managemembers.html.php @@ -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}')") )