addwhitelist.ui.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. window.renderRowData = function($row, index, row)
  2. {
  3. $row.find('[data-name="account"]').find('.picker-box').on('inited', function(e, info)
  4. {
  5. /* Get selected users. */
  6. let users = [];
  7. $('.add-whitelist-panel form [name^=account]').each(function()
  8. {
  9. value = $(this).val();
  10. if(value != '') users.push(value);
  11. });
  12. let $account = info[0];
  13. let isAppend = row != undefined && row.isAppend != undefined && row.isAppend;
  14. /* Remove selected account in picker items. */
  15. items = userItems;
  16. if(isAppend || row == undefined)
  17. {
  18. items = [];
  19. $account.options.items.forEach(function(userItem)
  20. {
  21. if(!users.includes(userItem.value)) items.push(userItem);
  22. if(row != undefined && row.account == userItem.value) items.push(userItem);
  23. })
  24. }
  25. $account.render({items: items, required: row != undefined, readonly: !isAppend && row != undefined});
  26. if(row != undefined) $account.$.setValue(row.account);
  27. });
  28. }
  29. /**
  30. * Users by dept,execution,project,product or program.
  31. *
  32. * @param object $object
  33. * @access public
  34. * @return void
  35. */
  36. function setObjectUsers()
  37. {
  38. var copyID = $('input[name=object]').val();
  39. var deptID = $('input[name=dept]').val();
  40. var link = $.createLink(module, moduleMethod, 'objectID=' + objectID + '&deptID=' + deptID + '&copyID=' + copyID + '&objectType=' + objectType + '&module=' + module);
  41. if(module == 'program') link = $.createLink(module, moduleMethod, 'objectID=' + objectID + '&deptID=' + deptID + '&copyID=' + copyID + '&programID=' + programID + '&from=' + from);
  42. loadPage(link, '.panel-body');
  43. }
  44. function changeUsers()
  45. {
  46. let users = [];
  47. let $accounts = $('.add-whitelist-panel form [name^=account]');
  48. $accounts.each(function()
  49. {
  50. value = $(this).val();
  51. if(value != '') users.push(value);
  52. });
  53. if(users.length == 0) return;
  54. $accounts.each(function()
  55. {
  56. let items = [];
  57. let $this = $(this).zui('picker');
  58. let options = $this.options;
  59. let value = $this.$.state.value;
  60. if(options.readonly) return;
  61. usersPickerItems.forEach(function(userItem)
  62. {
  63. if(!users.includes(userItem.value)) items.push(userItem);
  64. if(value != '' && value == userItem.value) items.push(userItem);
  65. })
  66. $this.render({items: items});
  67. });
  68. }