view.html.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <?php
  2. /**
  3. * The view view file of story 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 Wang Yidong <yidong@easycorp.ltd>
  7. * @package story
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. use function zin\utils\flat;
  12. include($this->app->getModuleRoot() . 'ai/ui/promptmenu.html.php');
  13. jsVar('gradeGroup', $gradeGroup);
  14. $isInModal = isInModal();
  15. $isRequirement = $story->type == 'requirement';
  16. $isStoryType = $story->type == 'story';
  17. if(empty($executionID)) $executionID = 0;
  18. $story->estimate = helper::formatHours($story->estimate);
  19. /* 版本列表。Version list. */
  20. $versions = array();
  21. for($i = $story->version; $i >= 1; $i--)
  22. {
  23. $versionItem = setting()
  24. ->text("#{$i}")
  25. ->url(inlink('view', "storyID={$story->id}&version=$i&param=0&storyType={$story->type}"));
  26. if($isInModal) $versionItem->set(array('data-load' => 'modal', 'data-target' => '.modal.show:not(.modal-hide)'));
  27. $versionItem->selected($version == $i);
  28. $versions[] = $versionItem;
  29. }
  30. /* 根据需求类型,设置要激活的导航项。Active navbar item by story type. */
  31. if($app->tab == 'product') setPageData('activeMenuID', $story->type);
  32. $canModify = true;
  33. if($app->tab == 'project' && isset($project)) $canModify = common::canModify('project', $project);
  34. if($app->tab == 'execution' && isset($execution)) $canModify = common::canModify('execution', $execution);
  35. /* 初始化头部右上方工具栏。Init detail toolbar. */
  36. $toolbar = array();
  37. if(empty($story->frozen) && !$isInModal && hasPriv($story->type, 'create') && $canModify)
  38. {
  39. $otherParam = 'storyID=&projectID=';
  40. if($app->rawModule == 'projectstory' || $app->tab == 'project') $otherParam = "storyID=&projectID={$this->session->project}";
  41. $toolbar[] = array
  42. (
  43. 'icon' => 'plus',
  44. 'type' => 'primary',
  45. 'text' => $lang->story->create,
  46. 'url' => createLink($story->type, 'create', "productID={$story->product}&branch={$story->branch}&moduleID={$story->module}&$otherParam&bugID=0&planID=0&todoID=0&extra=&storyType=$story->type"),
  47. 'data-app' => $app->tab
  48. );
  49. }
  50. /* 初始化主栏内容。Init sections in main column. */
  51. $sections = array();
  52. $sections[] = setting()
  53. ->title($lang->story->legendSpec)
  54. ->control('html')
  55. ->content(empty($story->spec) ? $lang->noDesc : $story->spec);
  56. if($this->config->vision != 'lite')
  57. {
  58. $sections[] = setting()
  59. ->title($lang->story->legendVerify)
  60. ->control('html')
  61. ->content(empty($story->verify) ? $lang->noDesc : $story->verify);
  62. }
  63. if($story->files)
  64. {
  65. $sections[] = array
  66. (
  67. 'control' => 'fileList',
  68. 'files' => $story->files,
  69. 'showDelete' => false,
  70. 'padding' => false,
  71. 'object' => $story
  72. );
  73. }
  74. /* 子需求列表。 Children list. */
  75. if($story->children)
  76. {
  77. $cols['id'] = $config->story->dtable->fieldList['id'];
  78. $cols['title'] = $config->story->dtable->fieldList['title'];
  79. $cols['pri'] = $config->story->dtable->fieldList['pri'];
  80. $cols['assignedTo'] = $config->story->dtable->fieldList['assignedTo'];
  81. $cols['estimate'] = $config->story->dtable->fieldList['estimate'];
  82. $cols['status'] = $config->story->dtable->fieldList['status'];
  83. if($this->config->vision != 'lite') $cols['stage'] = $config->story->dtable->fieldList['stage'];
  84. $cols['actions'] = $config->story->dtable->fieldList['actions'];
  85. $cols['title']['title'] = $lang->story->name;
  86. $cols['id']['checkbox'] = false;
  87. $cols['actions']['minWidth'] = 200;
  88. if($isInModal)
  89. {
  90. $cols['title']['data-toggle'] = 'modal';
  91. $cols['title']['data-size'] = 'lg';
  92. }
  93. if(!hasPriv('story', 'view')) unset($cols['title']['link']);
  94. if(($story->type == 'story' && $config->vision == 'or') || ($story->vision == 'or' && $config->vision == 'rnd')) unset($cols['actions']);
  95. foreach(array_keys($cols) as $fieldName) $cols[$fieldName]['sortType'] = false;
  96. $options = array('users' => $users);
  97. foreach($story->children as $child) $child = $this->story->formatStoryForList($child, $options, $child->type, $maxGradeGroup);
  98. $sections[] = array
  99. (
  100. 'title' => $lang->story->children,
  101. 'control' => 'dtable',
  102. 'id' => 'table-story-children',
  103. 'cols' => $cols,
  104. 'userMap' => $users,
  105. 'data' => array_values($story->children),
  106. 'onRenderCell' => jsRaw('renderChildCell')
  107. );
  108. }
  109. /* 初始化侧边栏标签页。Init tabs in sidebar. */
  110. $tabs = array();
  111. /* 基本信息。Legend basic items. */
  112. $tabs[] = setting()
  113. ->group('basic')
  114. ->title($lang->story->legendBasicInfo)
  115. ->control(array('control' => 'storyBasicInfo', 'hiddenPlan' => $config->vision == 'or' && $story->type != 'story' ? true : false))
  116. ->statusText($story->URChanged ? $lang->story->URChanged : $this->processStatus('story', $story));
  117. /* 需求一生。Legend life items. */
  118. $tabs[] = setting()
  119. ->group('basic')
  120. ->title($lang->story->legendLifeTime)
  121. ->control('storyLifeInfo');
  122. if($twins)
  123. {
  124. $tabs[] = setting()
  125. ->group('relatives')
  126. ->title($lang->story->twins)
  127. ->control('twinsStoryList')
  128. ->branches($branches)
  129. ->items($twins);
  130. }
  131. if(!in_array($config->vision, array('lite', 'or')) && $canModify)
  132. {
  133. $tabs['linkStories'] = setting()
  134. ->group('relatives')
  135. ->title($lang->story->linkStories)
  136. ->control('linkedStoryList')
  137. ->items($relations)
  138. ->story($story);
  139. }
  140. if($isStoryType && hasPriv('story', 'tasks'))
  141. {
  142. $tabs[] = setting()
  143. ->group('relatives')
  144. ->title($lang->story->legendProjectAndTask)
  145. ->control('executionTaskList')
  146. ->tasks(flat($story->tasks))
  147. ->executions($story->executions);
  148. }
  149. /* 相关信息。 Related info. */
  150. if($config->vision != 'lite')
  151. {
  152. $tabs['storyRelatedList'] = setting()
  153. ->group('relatives')
  154. ->title($lang->story->legendRelated)
  155. ->control('storyRelatedList');
  156. }
  157. $parentTitle = $story->parent > 0 ? set::parentTitle($story->parentName) : null;
  158. $parentUrl = $story->parent > 0 ? set::parentUrl(createLink($story->parentType, 'view', "storyID={$story->parent}&version=0&param=0&storyType=$story->type")) : null;
  159. $versionBtn = count($versions) > 1 ? to::title(dropdown
  160. (
  161. btn(set::type('ghost'), setClass('text-link font-normal text-base'), "#{$version}"),
  162. set::items($versions)
  163. )) : null;
  164. if($isInModal) $config->{$story->type}->actionList['recall']['url']['params'] = str_replace('&from=view&', '&from=modal&', $config->{$story->type}->actionList['recall']['url']['params']);
  165. if($story->status == 'changing') $config->{$story->type}->actionList['recall']['text'] = $lang->story->recallChange;
  166. $this->loadModel('repo');
  167. $hasRepo = $this->repo->getListByProduct($story->product, implode(',', $config->repo->gitServiceTypeList), 1);
  168. $actions = $story->deleted || !$canModify ? array() : $this->loadModel('common')->buildOperateMenu($story, $story->type);
  169. $hasDivider = !empty($actions['mainActions']) && !empty($actions['suffixActions']);
  170. if(!empty($actions)) $actions = array_merge($actions['mainActions'], $hasDivider ? array(array('type' => 'divider')) : array(), $actions['suffixActions']);
  171. foreach($actions as $key => $action)
  172. {
  173. if(!empty($story->frozen) && isset($action['icon']) && in_array($action['icon'], array('edit', 'change', 'trash', 'split', 'copy')))
  174. {
  175. unset($actions[$key]);
  176. continue;
  177. }
  178. if(!$hasDivider && isset($action['type']) && $action['type'] == 'divider')
  179. {
  180. unset($actions[$key]);
  181. continue;
  182. }
  183. if(isset($action['key']) && $action['key'] == 'createTask' && ($story->type != 'story' || in_array($story->status, array('reviewing', 'closed')) || $story->isParent == '1' || $app->tab == 'product' || $isInModal || ($app->tab == 'project' && !empty($project) && $project->multiple)))
  184. {
  185. unset($actions[$key]);
  186. continue;
  187. }
  188. if(isset($action['key']) && $action['key'] == 'testcase' && ($story->type != 'story' || $story->isParent == '1'))
  189. {
  190. unset($actions[$key]);
  191. continue;
  192. }
  193. if(!$hasRepo && isset($action['icon']) && $action['icon'] == 'treemap')
  194. {
  195. unset($actions[$key]);
  196. continue;
  197. }
  198. if(isset($action['icon']) && $action['icon'] == 'split')
  199. {
  200. $objectID = $app->tab == 'project' ? ($project->multiple ? $projectID : $executionID) : $executionID;
  201. if($story->grade < $maxGradeGroup[$story->type] && empty($story->hasOtherTypeChild) && common::hasPriv($story->type, 'batchCreate'))
  202. {
  203. $actions[$key]['url'] = createLink($story->type, 'batchCreate', "productID=$story->product&branch=$story->branch&moduleID=$story->module&storyID=$story->id&executionID=$objectID");
  204. }
  205. elseif($story->type == 'epic' && common::hasPriv('requirement', 'batchCreate') && empty($story->hasSameTypeChild) && !($this->config->epic->gradeRule == 'stepwise' && $story->grade < $maxGradeGroup['epic']))
  206. {
  207. $actions[$key]['url'] = createLink('requirement', 'batchCreate', "productID=$story->product&branch=$story->branch&moduleID=$story->module&storyID=$story->id&executionID=$objectID");
  208. }
  209. elseif($story->type == 'requirement' && common::hasPriv('story', 'batchCreate') && empty($story->hasSameTypeChild) && !($this->config->requirement->gradeRule == 'stepwise' && $story->grade < $maxGradeGroup['requirement']))
  210. {
  211. $actions[$key]['url'] = createLink('story', 'batchCreate', "productID=$story->product&branch=$story->branch&moduleID=$story->module&storyID=$story->id&executionID=$objectID");
  212. }
  213. else
  214. {
  215. unset($actions[$key]);
  216. continue;
  217. }
  218. }
  219. if($isInModal && isset($actions[$key]) && !isset($actions[$key]['data-toggle']) && !isset($actions[$key]['data-load']))
  220. {
  221. $actions[$key]['data-load'] = 'modal';
  222. $actions[$key]['data-size'] = 'lg';
  223. }
  224. }
  225. if($config->edition == 'ipd' && $config->vision == 'rnd' && $story->type == 'story') $story = $this->story->getAffectObject(array(), $story->type, $story);
  226. if($config->edition == 'ipd' && $story->type == 'story' && !empty($story->confirmeActionType))
  227. {
  228. $actions = array();
  229. $method = $story->confirmeActionType == 'confirmedretract' ? 'confirmDemandRetract' : 'confirmDemandUnlink';
  230. $url = helper::createLink('story', $method, "objectID=$story->id&object=story&extra={$story->confirmeObjectID}");
  231. $actions[] = array('name' => $method, 'text' => $lang->story->$method, 'icon' => 'search', 'hint' => $lang->story->$method, 'url' => $url, 'data-toggle' => 'modal');
  232. }
  233. $hiddenActions = $config->vision == 'or' && $story->type == 'story';
  234. detail
  235. (
  236. set::urlFormatter(array('{id}' => $story->id, '{type}' => $story->type, '{product}' => $story->product, '{branch}' => $story->branch, '{module}' => $story->module, '{execution}' => isset($executionID) ? $executionID : (isset($projectID) ? $projectID : 0))),
  237. set::objectType('story'),
  238. set::toolbar($toolbar),
  239. set::sections($sections),
  240. set::tabs($tabs),
  241. set::backBtn(array('url' => createLink('product', 'browse', "productID=$story->product&$story->branch=&browseType=unclosed&param=0&storyType=$story->type"))),
  242. $hiddenActions ? null : set::actions(array_values($actions)),
  243. $parentTitle,
  244. $parentUrl,
  245. $versionBtn
  246. );
  247. /**
  248. * Notice: 旗舰版和 IPD 版在项目的需求详情页面有导入需求库按钮,需要这个对话框。
  249. * 应该将此对话框放置在对应的版本中比较合适。
  250. */
  251. if(isset($libs))
  252. {
  253. modal
  254. (
  255. setID('importToLib'),
  256. set::title($lang->story->importToLib),
  257. form
  258. (
  259. set::action($this->createLink('story', 'importToLib', "storyID=$story->id")),
  260. formGroup
  261. (
  262. set::label($lang->story->lib),
  263. picker
  264. (
  265. set::name('lib'),
  266. set::items($libs),
  267. set::required(true)
  268. )
  269. ),
  270. (!hasPriv('assetlib', 'approveStory') && !hasPriv('assetlib', 'batchApproveStory')) ? formGroup
  271. (
  272. set::label($lang->story->approver),
  273. picker
  274. (
  275. set::name('assignedTo'),
  276. set::items($approvers)
  277. )
  278. ) : null,
  279. set::submitBtnText($lang->import),
  280. set::actions(array('submit'))
  281. )
  282. );
  283. }