track.ui.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. window.getItem = function(info)
  2. {
  3. const col = info.col;
  4. const color = info.item.color ? " style='color:" + info.item.color + "'" : '';
  5. const title = info.item.title;
  6. let titleHtml = `<span${color}>${title}</span>`;
  7. info.item.content = [];
  8. if(col.indexOf('epic') != -1 || col.indexOf('requirement') != -1 || col.indexOf('story') != -1)
  9. {
  10. let storyPriList = langStoryPriList[info.item.storyType];
  11. let storyStatusList = langStoryStatusList[info.item.storyType];
  12. let storyStageList = langStoryStageList[info.item.storyType];
  13. if(privs[info.item.storyType]) titleHtml = "<a href='" + $.createLink(info.item.storyType, 'view', `storyID=${info.item.id}`) + "' data-toggle='modal' data-size='lg'" + color + ">" + title + "</a>";
  14. info.item.title = {html: `<div class="line-clamp-2"><span class="align-sub pri-${info.item.pri}">${storyPriList[info.item.pri]}</span> ${titleHtml}</div>`}
  15. info.item.titleAttrs = {'title' : title};
  16. if(storyStatusList[info.item.status]) info.item.content.push({html: `<div class="status-${info.item.status}">${storyStatusList[info.item.status]}</div>`});
  17. info.item.content.push({html: `<div style="color:var(--color-gray-600)">${storyStageList[info.item.stage]}</div>`})
  18. }
  19. else if(col == 'project' || col == 'execution')
  20. {
  21. let delayHtml = '';
  22. if(info.item.delay > 0) delayHtml = `<span class='label danger-pale delayed nowrap'>${langProjectStatusList['delay']}</span>`;
  23. titleHtml = `<span${color} class="title">${title}</span>`;
  24. if(col == 'project' && privs['project']) titleHtml = "<a class='title' href='" + $.createLink('project', 'view', `projectID=${info.item.id}`) + "'>" + title + "</a>";
  25. if(col == 'execution' && privs['execution']) titleHtml = "<a class='title' href='" + $.createLink('execution', 'task', `executionID=${info.item.id}`) + "'>" + title + "</a>";
  26. info.item.title = [];
  27. info.item.title.push({html: `<div class="line-clamp-2">${titleHtml}</div>`});
  28. info.item.title.push({html: `<div>${delayHtml}</div>`, 'class': 'delayBox gap-x-2'});
  29. info.item.titleAttrs = {'title' : title, 'class': 'card-title flex'};
  30. info.item.content.push({html: `<div class="status-${info.item.status}">${langProjectStatusList[info.item.status]}</div>`});
  31. info.item.content.push({component: 'ProgressCircle', props: {percent: info.item.progress, size: 24}});
  32. }
  33. else if(col == 'task')
  34. {
  35. if(privs['task']) titleHtml = "<a href='" + $.createLink('task', 'view', `taskID=${info.item.id}`) + "' data-toggle='modal' data-size='lg'" + color + ">" + title + "</a>";
  36. if(info.item.isParent == '1') titleHtml = "<span class='label size-sm'>" + langParent + "</span> " + titleHtml;
  37. if(info.item.parent > 0 && info.item.isParent == '0') titleHtml = "<span class='label size-sm'>" + langChildren + "</span> " + titleHtml;
  38. info.item.title = {html: `<div class='line-clamp-2'><span class="align-sub pri-${info.item.pri}">${langTaskPriList[info.item.pri]}</span> ${titleHtml}</div>`}
  39. info.item.titleAttrs = {'title' : title};
  40. if(info.item.isParent == '1') info.item.content.push({html: `<span class="label cursor-pointer primary rounded-xl toggle-btn is-collapsed" data-id="${info.item.id}" onclick="toggleChildren(this, ${info.item.id})">${langChildren} <span class="toggle-icon ml-1"></span></span>`});
  41. info.item.content.push({html: `<div class="status-${info.item.status}" style='white-space:nowrap'>${langTaskStatusList[info.item.status]}</div>`});
  42. if(info.item.assignedTo) info.item.content.push({html: "<div style='white-space:nowrap'><i class='icon icon-hand-right'></i> " + (users[info.item.assignedTo] ? users[info.item.assignedTo] : info.item.assignedTo) + "</div>"});
  43. info.item.content.push({component: 'ProgressCircle', props: {percent: info.item.progress, size: 24}});
  44. }
  45. else if(col == 'bug')
  46. {
  47. if(privs['bug']) titleHtml = "<a href='" + $.createLink('bug', 'view', `bugID=${info.item.id}`) + "' data-toggle='modal' data-size='lg'" + color + ">" + title + "</a>";
  48. info.item.title = {html: `<div class="line-clamp-2"><span class="align-sub pri-${info.item.pri}">${langBugPriList[info.item.pri]}</span> ${titleHtml}</div>`}
  49. info.item.titleAttrs = {'title' : title};
  50. severity = info.item.severity;
  51. severityHtml = `<div class="severity" data-severity="${severity}"></div>`;
  52. if(!langBugSeverityList[severity] || langBugSeverityList[severity] != severity) severityHtml = `<div class='severity severity-label' data-severity="${severity}">${langBugSeverityList[severity]}</div>`;
  53. info.item.content.push({html: severityHtml});
  54. if(info.item.assignedTo) info.item.content.push({html: "<i class='icon icon-hand-right'></i> " + (users[info.item.assignedTo] ? users[info.item.assignedTo] : info.item.assignedTo)});
  55. }
  56. else if(col == 'case')
  57. {
  58. if(privs['case']) titleHtml = "<a href='" + $.createLink('testcase', 'view', `caseID=${info.item.id}`) + "' data-toggle='modal' data-size='lg'" + color + ">" + title + "</a>";
  59. info.item.title = {html: `<div class="line-clamp-2"><span class="align-sub pri-${info.item.pri}">${langCasePriList[info.item.pri]}</span> ${titleHtml}</div>`}
  60. info.item.titleAttrs = {'title' : title};
  61. info.item.content.push({html: "<div class='status-" + info.item.lastRunResult + "'>" + (langCaseResultList[info.item.lastRunResult] ? langCaseResultList[info.item.lastRunResult] : langUnexecuted) + "</div>"});
  62. info.item.content.push({html: (users[info.item.lastRunner] ? users[info.item.lastRunner] : info.item.lastRunner)});
  63. }
  64. else if(col == 'design')
  65. {
  66. info.item.titleAttrs = {'class': 'line-clamp-3', 'title' : title};
  67. if(privs['design'])
  68. {
  69. info.item.titleUrl = $.createLink('design', 'view', `id=${info.item.id}`);
  70. info.item.titleAttrs = {'class': 'line-clamp-3', 'title' : title, 'data-toggle': 'modal', 'data-size': 'lg'};
  71. }
  72. }
  73. else if(col == 'commit')
  74. {
  75. if(privs['commit']) info.item.titleUrl = $.createLink('repo', 'revision', `repoID=${info.item.repo}&objectID=0&revision=${info.item.revision}`);
  76. info.item.titleAttrs = {'class': 'line-clamp-3', 'title' : title};
  77. }
  78. }
  79. window.getLaneCol = function(lane, col)
  80. {
  81. if(mergeCells[lane.name])
  82. {
  83. if(mergeCells[lane.name][col.name]) return {laneColClass: 'lane-col-join-with-above'};
  84. return {laneColClass: 'lane-col-shrink-with-above'};
  85. }
  86. }
  87. window.getCol = function(col)
  88. {
  89. if(col.name == storyType) col.subtitle = {html: `<span class="icon ml-1 cursor-pointer orderByIcon icon-swap" title="${orderByTitle}"></span>`};
  90. }
  91. window.itemRender = function(info)
  92. {
  93. const col = info.col;
  94. if(col == 'task')
  95. {
  96. if(info.item.parent > '0' && tasks[info.item.parent] !== undefined) info.item.className.push('hidden childTask parent-' + info.item.parent);
  97. if(info.item.isParent == '1') info.item.className.push('parentTask');
  98. }
  99. if(config.rawModule == 'projectstory' && (col.indexOf('epic') != -1 || col.indexOf('requirement') != -1 || col.indexOf('story') != -1))
  100. {
  101. if(!storyIdList.includes(parseInt(info.item.id))) info.item.className.push('hidden');
  102. }
  103. }
  104. window.afterRender = function()
  105. {
  106. $orderByIcon = $('.orderByIcon');
  107. if($orderByIcon.length > 0 && !$orderByIcon.hasClass('dropdownInited'))
  108. {
  109. new zui.Dropdown($('.orderByIcon'), {menu: {items: orderByItems}});
  110. $orderByIcon.addClass('dropdownInited');
  111. }
  112. $hasSubCols = $('.kanban-header-cols .kanban-header-col.has-subs');
  113. if($hasSubCols.length > 0)
  114. {
  115. $hasSubCols.each(function()
  116. {
  117. $subCols = $(this).find(".kanban-header-sub-cols .kanban-header-col.is-sub");
  118. if($subCols.length == 1)
  119. {
  120. style = $subCols.attr('style');
  121. $subCols.parent().addClass('hidden');
  122. $(this).removeClass('has-subs').attr('style', style);
  123. }
  124. });
  125. }
  126. }
  127. window.toggleChildren = function(obj, parentID, isExpanded)
  128. {
  129. if(!isExpanded) isExpanded = false;
  130. if(isExpanded || $(obj).hasClass('is-expanded'))
  131. {
  132. $(obj).removeClass('is-expanded').addClass('is-collapsed');
  133. let $parent = $('.parent-' + parentID);
  134. $parent.addClass('hidden');
  135. if($parent.length == 0) return;
  136. let $toggleBtn = $parent.find('.toggle-btn');
  137. if($toggleBtn.length == 0) return;
  138. $toggleBtn.each(function(){ toggleChildren(this, $(this).data('id'), true); });
  139. }
  140. else
  141. {
  142. $(obj).removeClass('is-collapsed').addClass('is-expanded');
  143. $('.parent-' + parentID).removeClass('hidden')
  144. }
  145. }
  146. window.changeProduct = function(e)
  147. {
  148. if(config.rawModule == 'projectstory') loadPage($.createLink(config.rawModule, config.rawMethod, "projectID=" + projectID + "&productID=" + $(e.target).val()));
  149. }