diff --git a/module/project/js/managemembers.ui.js b/module/project/js/managemembers.ui.js index 476e47b576..d2feebe1d2 100644 --- a/module/project/js/managemembers.ui.js +++ b/module/project/js/managemembers.ui.js @@ -72,8 +72,29 @@ window.addItem = function(obj) */ window.deleteItem = function(obj) { + let currentAccount = $(obj).closest('tr').find('input[name^=account]').val(); + $(obj).closest('tr').remove(); if($('#teamForm .table tbody tr').length < 2) $('#teamForm .table tbody tr .actions-list .btn-link').eq(1).addClass('hidden'); + + 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}); + }); } /**