kanban.html.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <?php
  2. /**
  3. * The kanban view file of execution module of ZenTaoPMS.
  4. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  5. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  6. * @author Sun Guangming <sunguangming@easycorp.ltd>
  7. * @package kanban
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. include 'header.html.php';
  12. $laneCount = 0;
  13. foreach($kanbanList as $current => $region)
  14. {
  15. foreach($region['items'] as $index => $group)
  16. {
  17. $groupID = $group['id'];
  18. $group['getLane'] = jsRaw('window.getLane');
  19. $group['getCol'] = jsRaw('window.getCol');
  20. $group['getItem'] = jsRaw('window.getItem');
  21. $group['minColWidth'] = $execution->fluidBoard == '0' ? $execution->colWidth : $execution->minColWidth;
  22. $group['maxColWidth'] = $execution->fluidBoard == '0' ? $execution->colWidth : $execution->maxColWidth;
  23. $group['colProps'] = array('actions' => jsRaw('window.getColActions'));
  24. $group['laneProps'] = array('actions' => jsRaw('window.getLaneActions'));
  25. $group['itemProps'] = array('actions' => jsRaw('window.getItemActions'));
  26. if($execution->displayCards > 0)
  27. {
  28. $group['minLaneHeight'] = $execution->displayCards * 70;
  29. $group['maxLaneHeight'] = $execution->displayCards * 70;
  30. }
  31. if(common::canModify('execution', $execution))
  32. {
  33. $group['canDrop'] = jsRaw('window.canDrop');
  34. $group['onDrop'] = jsRaw('window.onDrop');
  35. }
  36. $kanbanList[$current]['items'][$index] = $group;
  37. }
  38. $laneCount += isset($region['laneCount']) ? $region['laneCount'] : 0;
  39. }
  40. $operationMenu = array();
  41. if(common::hasPriv('kanban', 'createRegion'))
  42. {
  43. $operationMenu[] = array('text' => $lang->kanban->createRegion, 'url' => helper::createLink('kanban', 'createRegion', "kanbanID=$execution->id&from=execution"), 'data-toggle' => 'modal', 'icon' => 'plus');
  44. $operationMenu[] = array('type' => 'divider');
  45. }
  46. if($this->execution->isClickable($execution, 'edit')) $operationMenu[] = array('text' => $lang->execution->edit, 'url' => inlink('edit', "id=$execution->id"), 'data-toggle' => 'modal', 'data-size' => 'lg', 'icon' => 'edit');
  47. if($this->execution->isClickable($execution, 'start')) $operationMenu[] = array('text' => $lang->execution->start, 'url' => inlink('start', "id=$execution->id"), 'data-toggle' => 'modal', 'icon' => 'start');
  48. if($this->execution->isClickable($execution, 'putoff')) $operationMenu[] = array('text' => $lang->execution->putoff, 'url' => inlink('putoff', "id=$execution->id"), 'data-toggle' => 'modal', 'icon' => 'calendar');
  49. if($this->execution->isClickable($execution, 'suspend')) $operationMenu[] = array('text' => $lang->execution->suspend, 'url' => inlink('suspend', "id=$execution->id"), 'data-toggle' => 'modal', 'icon'=> 'pause');
  50. if($this->execution->isClickable($execution, 'close')) $operationMenu[] = array('text' => $lang->execution->close, 'url' => inlink('close', "id=$execution->id"), 'data-toggle' => 'modal', 'icon' => 'off');
  51. if($this->execution->isClickable($execution, 'activate')) $operationMenu[] = array('text' => $lang->execution->activate, 'url' => inlink('activate', "id=$execution->id"), 'data-toggle' => 'modal', 'icon' => 'off');
  52. if($this->execution->isClickable($execution, 'delete')) $operationMenu[] = array('text' => $lang->delete, 'url' => inlink('delete', "id=$execution->id&confirm=no"), 'innerClass' => 'ajax-submit', 'icon' => 'trash');
  53. $groupMenu = array();
  54. foreach($this->lang->execution->kanbanGroup as $groupKey => $groupName)
  55. {
  56. $groupMenu[] = array('text' => $groupName, 'url' => inlink('kanban', "execution=$execution->id&browseType=task&orderBy=$orderBy&groupBy=$groupKey"));
  57. }
  58. $canCreateTask = common::hasPriv('task', 'create') && common::canModify('execution', $execution);
  59. $canBatchCreateTask = common::hasPriv('task', 'batchCreate') && common::canModify('execution', $execution);
  60. $canImportTask = common::hasPriv('execution', 'importTask') && $execution->multiple && common::canModify('execution', $execution) && $this->config->vision != 'lite';
  61. $canCreateBug = $features['qa'] && common::hasPriv('bug', 'create') && common::canModify('execution', $execution) && $productID && $this->config->vision != 'lite';
  62. $canBatchCreateBug = $features['qa'] && common::hasPriv('bug', 'batchCreate') && $execution->multiple && common::canModify('execution', $execution) && $productID && $this->config->vision != 'lite';
  63. $canImportBug = $features['qa'] && common::hasPriv('execution', 'importBug') && $execution->multiple && common::canModify('execution', $execution) && $productID && $this->config->vision != 'lite';
  64. $hasBugButton = $features['qa'] && ($canCreateBug || $canBatchCreateBug);
  65. $canCreateStory = $features['story'] && common::hasPriv('story', 'create') && common::canModify('execution', $execution) && $productID && $this->config->vision != 'lite';
  66. $canBatchCreateStory = $features['story'] && common::hasPriv('story', 'batchCreate') && common::canModify('execution', $execution) && $productID && $this->config->vision != 'lite';
  67. $canLinkStory = $features['story'] && common::hasPriv('execution', 'linkStory') && !empty($execution->hasProduct) && common::canModify('execution', $execution) && $productID && $this->config->vision != 'lite';
  68. $canLinkStoryByPlan = $features['story'] && common::hasPriv('execution', 'importplanstories') && !empty($project->hasProduct) && common::canModify('execution', $execution) && $productID && $this->config->vision != 'lite';
  69. $hasStoryButton = $features['story'] && ($canCreateStory || $canBatchCreateStory || $canLinkStory || $canLinkStoryByPlan);
  70. $hasTaskButton = $canCreateTask || $canBatchCreateTask || $canImportBug;
  71. $createMenu = array();
  72. $modal = $productID ? 'modal' : false;
  73. if($canCreateStory) $createMenu[] = array('text' => $lang->story->create, 'url' => $productID ? helper::createLink('story', 'create', "productID=$productID&branch=0&moduleID=0&story=0&execution=$execution->id") : 'javascript:;', 'data-toggle' => $modal, 'data-size' => 'lg', 'data-on' => 'click', 'data-call' => 'checkProducts');
  74. if($canBatchCreateStory) $createMenu[] = array('text' => $lang->story->batchCreate, 'url' => $productID ? (count($productNames) > 1 ? '#batchCreateStory' : helper::createLink('story', 'batchCreate', "productID=$productID&branch=$branchID&moduleID=0&story=0&execution=$execution->id")) : 'javascript:;', 'data-toggle' => $modal, 'data-size' => 'lg', 'data-on' => 'click', 'data-call' => 'checkProducts');
  75. if($canLinkStory) $createMenu[] = array('text' => $lang->execution->linkStory, 'url' => $productID ? helper::createLink('execution', 'linkStory', "execution=$execution->id") : 'javascript:;', 'data-toggle' => $modal, 'data-size' => 'lg', 'data-on' => 'click', 'data-call' => 'checkProducts');
  76. if($canLinkStoryByPlan) $createMenu[] = array('text' => $lang->execution->linkStoryByPlan, 'url' => $productID ? "#linkStoryByPlan" : 'javascript:;', 'data-toggle' => $modal, 'data-size' => 'sm', 'data-on' => 'click', 'data-call' => 'checkProducts');
  77. if($hasStoryButton && $hasTaskButton) $createMenu[] = array('type' => 'divider');
  78. if($canCreateBug) $createMenu[] = array('text' => $lang->bug->create, 'url' => helper::createLink('bug', 'create', "productID=$productID&branch=0&extra=executionID=$execution->id"), 'data-toggle' => 'modal', 'data-size' => 'lg');
  79. if($canBatchCreateBug)
  80. {
  81. if(count($productNames) > 1)
  82. {
  83. $createMenu[] = array('text' => $lang->bug->batchCreate, 'url' => '#batchCreateBug', 'data-toggle' => 'modal');
  84. }
  85. else
  86. {
  87. $createMenu[] = array('text' => $lang->bug->batchCreate, 'url' => helper::createLink('bug', 'batchCreate', "productID=$productID&branch=$branchID&extra=&executionID=$execution->id"), 'data-toggle' => 'modal', 'data-size' => 'lg');
  88. }
  89. }
  90. if(($hasStoryButton or $hasBugButton) and $hasTaskButton) $createMenu[] = array('type' => 'divider');
  91. if($canCreateTask) $createMenu[] = array('text' => $lang->task->create, 'url' => helper::createLink('task', 'create', "execution=$execution->id"), 'data-toggle' => 'modal', 'data-size' => 'lg');
  92. if($canImportBug) $createMenu[] = array('text' => $lang->execution->importBug, 'url' => helper::createLink('execution', 'importBug', "execution=$execution->id"), 'data-toggle' => 'modal');
  93. if($canImportTask) $createMenu[] = array('text' => $lang->execution->importTask, 'url' => helper::createLink('execution', 'importTask', "execution=$execution->id"), 'data-toggle' => 'modal');
  94. if($canBatchCreateTask) $createMenu[] = array('text' => $lang->execution->batchCreateTask, 'url' => helper::createLink('task', 'batchCreate', "execution=$execution->id"), 'data-toggle' => 'modal', 'data-size' => 'lg');
  95. jsVar('laneCount', $laneCount);
  96. jsVar('taskToOpen', $taskToOpen);
  97. jsVar('isLimited', $isLimited);
  98. jsVar('childrenAB', $lang->task->childrenAB);
  99. jsVar('parentAB', $lang->task->parentAB);
  100. jsVar('kanbanLang', $lang->kanban);
  101. jsVar('storyLang', $lang->story);
  102. jsVar('executionLang', $lang->execution);
  103. jsVar('laneLang', $lang->kanbanlane);
  104. jsVar('cardLang', $lang->kanbancard);
  105. jsVar('ERURColumn', array_keys($lang->kanban->ERURColumn));
  106. jsVar('bugLang', $lang->bug);
  107. jsVar('taskLang', $lang->task);
  108. jsVar('executionID', $execution->id);
  109. jsVar('productID', $productID);
  110. jsVar('productCount', count($productNames));
  111. jsVar('vision', $config->vision);
  112. jsVar('groupBy', $groupBy);
  113. jsVar('browseType', $browseType);
  114. jsVar('orderBy', $orderBy);
  115. jsVar('minColWidth', $execution->fluidBoard == '0' ? $execution->colWidth : $execution->minColWidth);
  116. jsVar('maxColWidth', $execution->fluidBoard == '0' ? $execution->colWidth : $execution->maxColWidth);
  117. jsVar('priv',
  118. array(
  119. 'canCreateTask' => $canCreateTask,
  120. 'canBatchCreateTask' => $canBatchCreateTask,
  121. 'canImportBug' => $canImportBug,
  122. 'canCreateBug' => $canCreateBug,
  123. 'canBatchCreateBug' => $canBatchCreateBug,
  124. 'canCreateStory' => $canCreateStory,
  125. 'canBatchCreateStory' => $canBatchCreateStory,
  126. 'canLinkStory' => $canLinkStory,
  127. 'canLinkStoryByPlan' => $canLinkStoryByPlan,
  128. 'canViewBug' => common::hasPriv('bug', 'view'),
  129. 'canAssignBug' => common::hasPriv('bug', 'assignto') && common::canModify('execution', $execution),
  130. 'canConfirmBug' => common::hasPriv('bug', 'confirm') && common::canModify('execution', $execution),
  131. 'canResolveBug' => common::hasPriv('bug', 'resolve') && common::canModify('execution', $execution),
  132. 'canCopyBug' => common::hasPriv('bug', 'create') && common::canModify('execution', $execution),
  133. 'canEditBug' => common::hasPriv('bug', 'edit') && common::canModify('execution', $execution),
  134. 'canDeleteBug' => common::hasPriv('bug', 'delete') && common::canModify('execution', $execution),
  135. 'canActivateBug' => common::hasPriv('bug', 'activate') && common::canModify('execution', $execution),
  136. 'canViewTask' => common::hasPriv('task', 'view'),
  137. 'canAssignTask' => common::hasPriv('task', 'assignto') && common::canModify('execution', $execution),
  138. 'canFinishTask' => common::hasPriv('task', 'finish') && common::canModify('execution', $execution),
  139. 'canPauseTask' => common::hasPriv('task', 'pause') && common::canModify('execution', $execution),
  140. 'canCancelTask' => common::hasPriv('task', 'cancel') && common::canModify('execution', $execution),
  141. 'canCloseTask' => common::hasPriv('task', 'close'),
  142. 'canActivateTask' => common::hasPriv('task', 'activate') && common::canModify('execution', $execution),
  143. 'canActivateStory' => common::hasPriv('story', 'activate') && common::canModify('execution', $execution),
  144. 'canStartTask' => common::hasPriv('task', 'start') && common::canModify('execution', $execution),
  145. 'canRestartTask' => common::hasPriv('task', 'restart') && common::canModify('execution', $execution),
  146. 'canEditTask' => common::hasPriv('task', 'edit') && common::canModify('execution', $execution),
  147. 'canDeleteTask' => common::hasPriv('task', 'delete') && common::canModify('execution', $execution),
  148. 'canRecordWorkhourTask' => common::hasPriv('task', 'recordWorkhour') && common::canModify('execution', $execution),
  149. 'canToStoryBug' => common::hasPriv('story', 'create') && common::canModify('execution', $execution),
  150. 'canAssignStory' => common::hasPriv('story', 'assignto') && common::canModify('execution', $execution),
  151. 'canEditStory' => common::hasPriv('story', 'edit') && common::canModify('execution', $execution),
  152. 'canDeleteStory' => common::hasPriv('story', 'delete') && common::canModify('execution', $execution),
  153. 'canChangeStory' => common::hasPriv('story', 'change') && common::canModify('execution', $execution),
  154. 'canCloseStory' => common::hasPriv('story', 'close'),
  155. 'canUnlinkStory' => (common::hasPriv('execution', 'unlinkStory') && !empty($execution->hasProduct)) && common::canModify('execution', $execution),
  156. 'canViewStory' => common::hasPriv('execution', 'storyView')
  157. )
  158. );
  159. if(!$features['story']) unset($lang->kanban->type['story']);
  160. if(!$features['qa']) unset($lang->kanban->type['bug']);
  161. $executionItems = array();
  162. foreach($executionList as $childExecution) $executionItems[] = array('text' => $childExecution->name, 'url' => createLink('execution', 'kanban', "kanbanID={$childExecution->id}"));
  163. featureBar();
  164. $editModule = $execution->multiple ? 'execution' : 'project';
  165. $editParams = $execution->multiple ? "executionID={$execution->id}" : "projectID={$execution->project}";
  166. toolbar
  167. (
  168. $groupMenu ? dropdown
  169. (
  170. btn
  171. (
  172. setClass('ghost btn btn-default'),
  173. $this->lang->execution->kanbanGroup[$groupBy]
  174. ),
  175. set::items($groupMenu)
  176. ) : null,
  177. btnGroup(btn
  178. (
  179. set
  180. (
  181. array
  182. (
  183. 'class' => 'btn ghost btn-default',
  184. 'url' => 'javascript:$("#kanbanList").fullscreen();',
  185. 'icon' => 'fullscreen'
  186. )
  187. ),
  188. $lang->kanban->fullScreen
  189. )),
  190. $operationMenu ? dropdown
  191. (
  192. btn
  193. (
  194. setClass('ghost btn btn-default'),
  195. set::icon('cog-outline'),
  196. $lang->settings
  197. ),
  198. set::caret(false),
  199. set::items($operationMenu)
  200. ) : null,
  201. $createMenu ? dropdown
  202. (
  203. btn(setClass('primary btn btn-default'), set::icon('plus'), $lang->create),
  204. set::items($createMenu)
  205. ) : null
  206. );
  207. div
  208. (
  209. set::id('kanbanList'),
  210. zui::kanbanList
  211. (
  212. set('$replace', false),
  213. set::key('kanban'),
  214. set::items($kanbanList),
  215. set::height('calc(100vh - 120px)'),
  216. set::selectable(true),
  217. set::showLinkOnSelected(true)
  218. )
  219. );
  220. $linkStoryByPlanTips = $lang->execution->linkNormalStoryByPlanTips;
  221. $linkStoryByPlanTips = $execution->multiple ? $linkStoryByPlanTips : str_replace($lang->execution->common, $lang->projectCommon, $linkStoryByPlanTips);
  222. modal
  223. (
  224. setID('linkStoryByPlan'),
  225. setData('size', '500px'),
  226. set::modalProps(array('title' => $lang->execution->linkStoryByPlan)),
  227. div
  228. (
  229. setClass('flex-auto'),
  230. icon('info-sign', setClass('warning-pale rounded-full mr-1')),
  231. $linkStoryByPlanTips
  232. ),
  233. form
  234. (
  235. setClass('text-center', 'py-4'),
  236. set::actions(array('submit')),
  237. set::submitBtnText($lang->execution->linkStory),
  238. formGroup
  239. (
  240. set::label($lang->execution->selectStoryPlan),
  241. set::required(true),
  242. setClass('text-left'),
  243. picker
  244. (
  245. set::name('plan'),
  246. set::required(true),
  247. set::items($allPlans)
  248. )
  249. )
  250. )
  251. );
  252. modal
  253. (
  254. setID('batchCreateStory'),
  255. to::header
  256. (
  257. h4($lang->bug->product)
  258. ),
  259. setData('size', '500px'),
  260. inputGroup
  261. (
  262. setClass('mt-3'),
  263. picker
  264. (
  265. set::width(300),
  266. set::name('productName'),
  267. set::items($productNames),
  268. set::required(true),
  269. set::onchange('changeStoryProduct()')
  270. ),
  271. span
  272. (
  273. setClass('input-group-btn ml-2'),
  274. btn
  275. (
  276. setClass('primary'),
  277. setID('batchCreateStoryButton'),
  278. set::url(createLink('story', 'batchCreate', 'productID=' . key($productNames) . '&branch=moduleID=0&storyID=0&executionID=' . $executionID)),
  279. set('data-toggle', 'modal'),
  280. set('data-dismiss', 'modal'),
  281. set('data-size', 'lg'),
  282. $lang->story->batchCreate
  283. )
  284. )
  285. )
  286. );
  287. modal
  288. (
  289. setID('batchCreateBug'),
  290. set::title($lang->bug->product),
  291. setData('size', '500px'),
  292. inputGroup
  293. (
  294. setClass('mt-3'),
  295. picker
  296. (
  297. set::width(300),
  298. set::name('productName'),
  299. set::items($productNames),
  300. set::required(true),
  301. set::onchange('changeBugProduct()')
  302. ),
  303. span
  304. (
  305. setClass('input-group-btn ml-2'),
  306. btn
  307. (
  308. setClass('primary'),
  309. setID('batchCreateBugButton'),
  310. set::url(createLink('bug', 'batchCreate', 'productID=' . key($productNames) . '&branch=&executionID=' . $executionID)),
  311. set('data-toggle', 'modal'),
  312. set('data-dismiss', 'modal'),
  313. set('data-size', 'lg'),
  314. $lang->bug->batchCreate
  315. )
  316. )
  317. )
  318. );