showimport.html.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. namespace zin;
  3. include $app->getModuleRoot() . 'transfer/ui/showimport.html.php';
  4. jsVar('childrenDateLimit', $childrenDateLimit);
  5. jsVar('parentTasks', $parentTasks);
  6. jsVar('tasks', $oldTasks);
  7. jsVar('jsDatas', array_values($datas));
  8. jsVar('members', $teams);
  9. jsVar('ignoreLang', $lang->project->ignore);
  10. jsVar('overParentEstStartedLang', $lang->task->overParentEsStarted);
  11. jsVar('overParentDeadlineLang', $lang->task->overParentDeadline);
  12. jsVar('overChildEstStartedLang', $lang->task->overChildEstStarted);
  13. jsVar('overChildDeadlineLang', $lang->task->overChildDeadline);
  14. jsVar('taskDateLimit', $project->taskDateLimit);
  15. jsVar('dropdownGroups', $dropdownGroups);
  16. pageJS(<<<'JAVASCRIPT'
  17. window.renderImportRowData = function($row, index, row)
  18. {
  19. if(row.execution)
  20. {
  21. const modules = dropdownGroups['module'] == undefined ? [] : (dropdownGroups['module'][row.execution] || []);
  22. const stories = dropdownGroups['story'] == undefined ? [] : (dropdownGroups['story'][row.execution] || []);
  23. const users = dropdownGroups['assignedTo'] == undefined ? [] : (dropdownGroups['assignedTo'][row.execution] || []);
  24. $row.find('[data-name="module"]').find('[id^="module"]').on('inited', function(e, info)
  25. {
  26. let $modulePicker = info[0];
  27. $modulePicker.render({items: modules});
  28. $modulePicker.$.setValue(row.module);
  29. });
  30. $row.find('[data-name="story"]').find('[id^="story"]').on('inited', function(e, info)
  31. {
  32. let $storyPicker = info[0];
  33. $storyPicker.render({items: stories});
  34. $storyPicker.$.setValue(row.story);
  35. });
  36. $row.find('[data-name="assignedTo"]').find('[id^="assignedTo"]').on('inited', function(e, info)
  37. {
  38. let $assignedToPicker = info[0];
  39. $assignedToPicker.render({items: users});
  40. $assignedToPicker.$.setValue(row.assignedTo);
  41. });
  42. }
  43. if(row.id != undefined && tasks[row.id] != undefined)
  44. {
  45. const task = tasks[row.id];
  46. $row.attr('data-parent', task.parent).attr('data-id', task.id);
  47. if(parentTasks[task.parent] != undefined && taskDateLimit == 'limit')
  48. {
  49. const parentTask = parentTasks[task.parent];
  50. $row.find('[id^="estStarted"]').on('inited', function(e, info)
  51. {
  52. if(parentTask.estStarted == '') info[0].render({disabled: true});
  53. });
  54. $row.find('[id^="deadline"]').on('inited', function(e, info)
  55. {
  56. if(parentTask.deadline == '') info[0].render({disabled: true});
  57. });
  58. }
  59. }
  60. if(row.team != undefined)
  61. {
  62. let $estimate = $row.find('.form-batch-control[data-name="estimate"]');
  63. $estimate.empty();
  64. let teams = [];
  65. for(account of row.team) teams.push({'text': members[account], 'value': account});
  66. $.each(row.team, function(index, account)
  67. {
  68. $estimate.append('<div class="input-group estimate-box"></div>')
  69. let $estimateInputGroup = $estimate.find('.input-group').last();
  70. $estimateInputGroup.append($('<div class="form-group-wrapper picker-box"></div>').picker({name: 'team[' + row.id + '][]', items: teams, defaultValue: account, required: true}));;
  71. $estimateInputGroup.append($('<input type="text" name="estimate[' + row.id + '][]" id="estimate_' + index + '" value="' + row.estimate[index] + '" class="form-control" autocomplete="off">'));
  72. });
  73. }
  74. };
  75. $(document).off('change', 'input[name^="execution"]').on('change', 'input[name^="execution"]', function()
  76. {
  77. const executionID = $(this).val();
  78. const $currentRow = $(this).closest('tr');
  79. const modules = dropdownGroups['module'] == undefined ? [] : (dropdownGroups['module'][executionID] || []);
  80. const stories = dropdownGroups['story'] == undefined ? [] : (dropdownGroups['story'][executionID] || []);
  81. const users = dropdownGroups['assignedTo'] == undefined ? [] : (dropdownGroups['assignedTo'][executionID] || []);
  82. const $modulePicker = $currentRow.find('[data-name="module"]').find('[id^="module"]').zui('picker');
  83. const $storyPicker = $currentRow.find('[data-name="story"]').find('[id^="story"]').zui('picker');
  84. const $assignedToPicker = $currentRow.find('[data-name="assignedTo"]').find('[id^="assignedTo"]').zui('picker');
  85. $modulePicker.render({items: modules});
  86. $storyPicker.render({items: stories});
  87. $assignedToPicker.render({items: users});
  88. $modulePicker.$.setValue('0');
  89. $storyPicker.$.setValue('');
  90. $assignedToPicker.$.setValue('');
  91. });
  92. $(document).off('change', 'input[name^="estStarted"], input[name^="deadline"]').on('change', 'input[name^="estStarted"], input[name^="deadline"]', function()
  93. {
  94. if(taskDateLimit != 'limit') return;
  95. const $currentRow = $(this).closest('tr');
  96. const taskID = $currentRow.attr('data-id');
  97. if(taskID == undefined) return;
  98. const parentID = tasks[taskID].parent;
  99. const field = $(this).closest('.form-batch-control').data('name');
  100. const estStarted = $currentRow.find('[name^=estStarted]').val();
  101. const deadline = $currentRow.find('[name^=deadline]').val();
  102. const parentTask = parentTasks[parentID] ? parentTasks[parentID] : {estStarted: '', deadline: ''};
  103. if(field == 'estStarted')
  104. {
  105. const $estStartedTd = $currentRow.find('td[data-name=estStarted]');
  106. $estStartedTd.find('.date-tip').remove();
  107. const $childrenEstStarted = $(this).closest('tbody').find('tr[data-parent="' + taskID + '"]').find('[name^=estStarted]');
  108. $childrenEstStarted.each(function(){$(this).zui('datePicker').render({disabled: estStarted.length == 0});});
  109. if(estStarted.length > 0)
  110. {
  111. let $datetip = $('<div class="date-tip"></div>');
  112. let parentEstStarted = typeof tasks[parentID] == 'undefined' || $(this).closest('tbody').find('[name="estStarted[' + parentID + ']"]').length == 0 ? parentTask.estStarted : $(this).closest('tbody').find('[name="estStarted[' + parentID + ']"]').val();
  113. if(parentEstStarted.length > 0 && estStarted < parentEstStarted) $datetip.append('<div class="form-tip text-danger">' + overParentEstStartedLang.replace('%s', parentEstStarted) + '</div>');
  114. let childEstStarted = childrenDateLimit[taskID] ? childrenDateLimit[taskID].estStarted : '';
  115. $childrenEstStarted.each(function()
  116. {
  117. if(childEstStarted.length == 0 || ($(this).val().length > 0 && $(this).val() < childEstStarted)) childEstStarted = $(this).val();
  118. });
  119. if(childEstStarted.length > 0 && estStarted > childEstStarted)
  120. {
  121. $datetip.append('<div class="form-tip text-warning">' + overChildEstStartedLang.replace('%s', childEstStarted) + '<span class="ignore-date ignore-child underline">' + ignoreLang + '</span></div>');
  122. $datetip.off('click', '.ignore-child').on('click', '.ignore-child', function(e){ignoreTip(e)});
  123. }
  124. $estStartedTd.append($datetip);
  125. }
  126. }
  127. if(field == 'deadline')
  128. {
  129. const $deadlineTd = $currentRow.find('td[data-name=deadline]');
  130. $deadlineTd.find('.date-tip').remove();
  131. const $childrenDeadline = $(this).closest('tbody').find('tr[data-parent="' + taskID + '"]').find('[name^=deadline]');
  132. $childrenDeadline.each(function(){$(this).zui('datePicker').render({disabled: deadline.length == 0});});
  133. if(deadline.length > 0)
  134. {
  135. let $datetip = $('<div class="date-tip"></div>');
  136. let parentDeadline = typeof tasks[parentID] == 'undefined' || $(this).closest('tbody').find('[name="deadline[' + parentID + ']"]').length == 0 ? parentTask.deadline : $(this).closest('tbody').find('[name="deadline[' + parentID + ']"]').val();
  137. if(parentDeadline.length > 0 && deadline > parentDeadline) $datetip.append('<div class="form-tip text-danger">' + overParentDeadlineLang.replace('%s', parentDeadline) + '</div>');
  138. let childDeadline = childrenDateLimit[taskID] ? childrenDateLimit[taskID].deadline : '';
  139. $childrenDeadline.each(function()
  140. {
  141. if(childDeadline.length == 0 || ($(this).val().length > 0 && $(this).val() > childDeadline)) childDeadline = $(this).val();
  142. });
  143. if(childDeadline.length > 0 && deadline < childDeadline)
  144. {
  145. $datetip.append('<div class="form-tip text-warning">' + overChildDeadlineLang.replace('%s', childDeadline) + '<span class="ignore-date ignore-child underline">' + ignoreLang + '</span></div>');
  146. $datetip.off('click', '.ignore-child').on('click', '.ignore-child', function(e){ignoreTip(e)});
  147. }
  148. $deadlineTd.append($datetip);
  149. }
  150. }
  151. });
  152. JAVASCRIPT
  153. );