batchedit.ui.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. window.renderRowData = function($row, index, row)
  2. {
  3. let options = {required: true};
  4. if(row.type == 'stage' || row.attribute != '')
  5. {
  6. let itemList = [];
  7. let projectModel = 'stage';
  8. if(stageList[row.attribute] !== undefined) itemList = stageList;
  9. if(ipdTypeList[row.attribute] !== undefined)
  10. {
  11. itemList = ipdTypeList;
  12. projectModel = 'ipd';
  13. }
  14. const parentType = row.grade > 1 && parents[row.parent] ? parents[row.parent].attribute : '';
  15. /* If is stage, modify lifetime to attribute. */
  16. let stageItems = [];
  17. for(let key in itemList) stageItems.push({value: key, text: itemList[key]});
  18. if(stageItems.length > 0)
  19. {
  20. options.items = stageItems;
  21. options.name = 'attribute';
  22. options.disabled = row.grade > 1 && parentType != 'mix';
  23. if(projectModel == 'ipd') options.disabled = true;
  24. }
  25. $row.attr('data-parent', row.parent);
  26. $row.find('[data-name="lifetime"]').find('.picker-box').on('inited', function(e, info)
  27. {
  28. let $attribute = info[0];
  29. $attribute.render({items: stageItems, required: true, name: 'attribute[' + row.id + ']', disabled: row.grade > 1 && parentType != 'mix'});
  30. $attribute.$.setValue(row.attribute);
  31. if(typeof row != 'undefined' && typeof row.hasDeliverable != 'undefined') $attribute.render({disabled: true});
  32. $(e.target).attr('data-parent', row.parent);
  33. });
  34. }
  35. $row.find('[data-name="lifetime"]').find('.picker-box').on('inited', function(e, info) { info[0].render(options); });
  36. $row.find('[data-name="project"]').attr('data-lastselected', row.project).attr('data-execution', row.id);
  37. }
  38. window.changeProject = function(e)
  39. {
  40. const $project = $(e.target);
  41. const projectID = $project.val();
  42. const $td = $project.closest('td');
  43. const executionID = $td.data('execution');
  44. let lastSelected = $td.data('lastselected');
  45. if($td.find('[id^="syncStories"]').length == 0)
  46. {
  47. $td.append("<input type='hidden' id='syncStories" + executionID + "' name='syncStories[" + executionID + "]' value='no' />");
  48. }
  49. if(projectID != lastSelected)
  50. {
  51. zui.Modal.confirm(confirmSync).then((res) => {
  52. if(res)
  53. {
  54. $td.data("lastselected", projectID);
  55. }
  56. else
  57. {
  58. $project.zui('picker').$.changeState({value: lastSelected});
  59. }
  60. $("#syncStories" + executionID).val(res ? 'yes' : 'no');
  61. });
  62. }
  63. };
  64. window.changeAttribute = function(obj)
  65. {
  66. const $attribute = $(obj);
  67. const parentID = $attribute.closest('tr').find('input[name^=id]').val();
  68. const attribute = $attribute.val();
  69. const $children = $('[data-parent="' + parentID + '"]');
  70. if($children.length == 0) return;
  71. if(attribute != 'mix') zui.Modal.alert(noticeChangeAttr.replace('%s', stageList[attribute]));
  72. $children.each(function()
  73. {
  74. const $attributePicker = $(this).find('input[name^=attribute]').zui('picker');
  75. if(attribute == 'mix')
  76. {
  77. $attributePicker.render({disabled: false});
  78. }
  79. else
  80. {
  81. $attributePicker.render({disabled: true});
  82. $attributePicker.$.setValue(attribute);
  83. }
  84. });
  85. };