view.html.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?php
  2. /**
  3. * The view file of bug module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Yuting Wang<wangyuting@easycorp.ltd>
  8. * @package bug
  9. * @link https://www.zentao.net
  10. */
  11. namespace zin;
  12. global $app;
  13. include($this->app->getModuleRoot() . 'ai/ui/promptmenu.html.php');
  14. /* 检查是否需要确认撤销/移除。*/
  15. /* Build confirmeObject. */
  16. if($this->config->edition == 'ipd')
  17. {
  18. $bug = $this->loadModel('story')->getAffectObject(array(), 'bug', $bug);
  19. if(!empty($bug->confirmeActionType)) $config->bug->actions->view['mainActions'] = array('confirmDemandRetract', 'confirmDemandUnlink');
  20. if(!empty($bug->confirmeActionType)) $config->bug->actions->view['suffixActions'] = array();
  21. }
  22. jsVar('bugID', $bug->id);
  23. jsVar('productID', $bug->product);
  24. jsVar('branchID', $bug->branch);
  25. jsVar('errorNoExecution', $lang->bug->noExecution);
  26. jsVar('errorNoProject', $lang->bug->noProject);
  27. jsVar('isInModal', isInModal());
  28. jsVar('executions', $executions);
  29. jsVar('disableExecution', $lang->project->disableExecution);
  30. $canModify = !empty($project) ? common::canModify('project', $project) : true;
  31. $isInModal = isInModal();
  32. $canCreateBug = $canModify && $this->app->tab != 'devops' && hasPriv('bug', 'create');
  33. $canViewRepo = hasPriv('repo', 'revision');
  34. $canViewMR = hasPriv('mr', 'view');
  35. $canViewBug = hasPriv('bug', 'view');
  36. $operateList = $this->loadModel('common')->buildOperateMenu($bug);
  37. /* 初始化头部右上方工具栏。Init detail toolbar. */
  38. $toolbar = array();
  39. if(!$isInModal && $canCreateBug)
  40. {
  41. $toolbar[] = array
  42. (
  43. 'icon' => 'plus',
  44. 'type' => 'primary',
  45. 'text' => $lang->bug->create,
  46. 'data-app' => $app->tab,
  47. 'url' => createLink('bug', 'create', "productID={$product->id}&branch={$bug->branch}&extras=projectID={$bug->project},executionID={$bug->execution},moduleID={$bug->module}")
  48. );
  49. }
  50. /* 初始化底部操作栏。Init bottom actions. */
  51. $actions = array();
  52. if(!$bug->deleted && $canModify)
  53. {
  54. /* Construct common actions for bug. */
  55. $actions = $operateList['mainActions'];
  56. if(!empty($operateList['suffixActions']))
  57. {
  58. if($app->getClientLang() == 'en') $actions = array_merge($actions, $operateList['suffixActions']);
  59. if($app->getClientLang() != 'en') $actions = array_merge($actions, array(array('type' => 'divider')), $operateList['suffixActions']);
  60. }
  61. $this->loadModel('repo');
  62. $hasRepo = $this->repo->getListByProduct($bug->product, implode(',', $config->repo->gitServiceTypeList), 1);
  63. foreach($actions as $key => $action)
  64. {
  65. if(!$hasRepo && isset($action['icon']) && $action['icon'] == 'treemap')
  66. {
  67. unset($actions[$key]);
  68. continue;
  69. }
  70. if(isset($action['id']) && $action['id'] == 'toStory')
  71. {
  72. if(!empty($project))
  73. {
  74. if(empty($project->hasProduct)) $action['data-app'] = $app->tab == 'execution' ? 'execution' : 'project';
  75. if($project->type == 'project' && $project->multiple == '0') $action['data-app'] = 'project';
  76. if($isInModal)
  77. {
  78. $action['data-load'] = 'modal';
  79. $action['data-size'] = 'lg';
  80. }
  81. }
  82. $actions[$key] = $action;
  83. }
  84. if(!empty($action['icon']) && $action['icon'] == 'edit' && isInModal())
  85. {
  86. $action['data-load'] = 'modal';
  87. $action['data-size'] = 'lg';
  88. $actions[$key] = $action;
  89. }
  90. }
  91. }
  92. /* 初始化主栏内容。Init sections in main column. */
  93. $sections = array();
  94. $sections[] = setting()
  95. ->title($lang->bug->legendSteps)
  96. ->control('html')
  97. ->content($bug->steps);
  98. if($bug->files)
  99. {
  100. $sections[] = array
  101. (
  102. 'control' => 'fileList',
  103. 'files' => $bug->files,
  104. 'object' => $bug,
  105. 'padding' => false
  106. );
  107. }
  108. /* 初始化侧边栏标签页。Init sidebar tabs. */
  109. $tabs = array();
  110. /* 基本信息。Legend basic items. */
  111. $tabs[] = setting()
  112. ->group('basic')
  113. ->title($lang->bug->legendBasicInfo)
  114. ->control('bugBasicInfo')
  115. ->statusText($this->processStatus('bug', $bug));
  116. /* 一生信息。Legend life items. */
  117. $tabs[] = setting()
  118. ->group('basic')
  119. ->title($lang->bug->legendLife)
  120. ->control('bugLifeInfo');
  121. $tabs[] = setting()
  122. ->group('related')
  123. ->title(!empty($project->multiple) ? $lang->bug->legendPRJExecStoryTask : $lang->bug->legendExecStoryTask)
  124. ->control('bugRelatedInfo');
  125. $tabs['bugRelatedList'] = setting()
  126. ->group('related')
  127. ->title($lang->bug->legendMisc)
  128. ->control('bugRelatedList');
  129. detail
  130. (
  131. set::urlFormatter(array('{id}' => $bug->id, '{product}' => $bug->product, '{branch}' => $bug->branch, '{project}' => $bug->project, '{execution}' => $bug->execution, '{module}' => $bug->module, '{confirmeObjectID}' => isset($bug->confirmeObjectID) ? $bug->confirmeObjectID : 0)),
  132. set::toolbar($toolbar),
  133. set::sections($sections),
  134. set::tabs($tabs),
  135. set::actions(array_values($actions))
  136. );
  137. modal
  138. (
  139. setID('toTask'),
  140. set::modalProps(array('title' => $lang->bug->selectProjects)),
  141. to::footer
  142. (
  143. div
  144. (
  145. setClass('toolbar gap-4 w-full justify-center'),
  146. btn($lang->bug->nextStep, setID('toTaskButton'), setClass('primary'), setData(array('on' => 'click', 'call' => 'clickToTask'))),
  147. btn($lang->cancel, setID('cancelButton'), setData(array('dismiss' => 'modal')))
  148. )
  149. ),
  150. formPanel
  151. (
  152. on::change('#taskProjects', 'changeTaskProjects'),
  153. set::actions(''),
  154. set::showExtra(false),
  155. formRow
  156. (
  157. formGroup
  158. (
  159. set::label($lang->bug->selectProjects),
  160. set::required(true),
  161. set::control('picker'),
  162. set::name('taskProjects'),
  163. set::items($projects)
  164. )
  165. ),
  166. formRow
  167. (
  168. formGroup
  169. (
  170. set::label($lang->bug->execution),
  171. set::required(true),
  172. inputGroup
  173. (
  174. setID('executionBox'),
  175. picker
  176. (
  177. set::name('execution'),
  178. set::items($executions)
  179. )
  180. )
  181. )
  182. )
  183. )
  184. );