view.html.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <?php
  2. /**
  3. * The view view file of testcase 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 Mengyi Liu <liumengyi@easycorp.ltd>
  7. * @package testcase
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. include($this->app->getModuleRoot() . 'ai/ui/promptmenu.html.php');
  12. jsVar('viewParams', "caseID={$case->id}&version={$version}&from={$from}&taskID={$taskID}&stepsType=");
  13. $isInModal = isInModal();
  14. $viewModule = $isLibCase ? 'caselib' : 'testcase';
  15. $viewMethod = $isLibCase ? 'viewCase' : 'view';
  16. /* 版本列表。Version list. */
  17. $versions = array();
  18. for($i = $case->version; $i >= 1; $i--)
  19. {
  20. $versionItem = setting()
  21. ->text("#{$i}")
  22. ->set('data-app', $app->tab)
  23. ->url(createLink($viewModule, $viewMethod, "caseID={$case->id}&version={$i}&from={$from}&taskID={$taskID}&stepsType={$stepsType}&suiteID={$suiteID}"));
  24. if($isInModal)
  25. {
  26. $versionItem->set(array('data-load' => 'modal', 'data-target' => '.modal.show:not(.modal-hide)'));
  27. }
  28. $versionItem->selected($version == $i);
  29. $versions[] = $versionItem;
  30. }
  31. $versionBtn = count($versions) > 1 ? to::title(dropdown
  32. (
  33. btn(set::type('ghost'), setClass('text-link font-normal text-base'), "#{$version}"),
  34. set::items($versions)
  35. )) : null;
  36. /* 初始化头部右上方工具栏。Init detail toolbar. */
  37. $toolbar = array();
  38. if(!$isInModal)
  39. {
  40. if(!$isLibCase && hasPriv('testcase', 'create', $case)) $toolbar[] = array
  41. (
  42. 'icon' => 'plus',
  43. 'type' => 'primary',
  44. 'text' => $lang->case->create,
  45. 'url' => createLink('testcase', 'create', "productID={$case->product}&branch={$case->branch}&moduleID={$case->module}")
  46. );
  47. if($isLibCase && hasPriv('caselib', 'createCase')) $toolbar[] = array
  48. (
  49. 'icon' => 'plus',
  50. 'type' => 'primary',
  51. 'text' => $lang->case->create,
  52. 'url' => createLink('caselib', 'createCase', "libID={$case->lib}&module={$case->module}")
  53. );
  54. }
  55. /* 检查是否需要确认撤销/移除。*/
  56. /* Build confirmeObject. */
  57. if($this->config->edition == 'ipd')
  58. {
  59. $testcase = $this->loadModel('story')->getAffectObject(array(), 'case', $case);
  60. if(!empty($testcase->confirmeActionType)) $config->testcase->actions->view['mainActions'] = array('confirmDemandRetract', 'confirmDemandUnlink');
  61. if(!empty($testcase->confirmeActionType)) $config->testcase->actions->view['suffixActions'] = array();
  62. }
  63. /* 初始化底部操作栏。Init bottom actions. */
  64. $config->testcase->actionList['edit']['url'] = array('module' => 'testcase', 'method' => 'edit', 'params' => 'caseID={caseID}&comment=false&executionID=%executionID%&from={from}');
  65. $actions = !$testcase->deleted ? $this->loadModel('common')->buildOperateMenu($case) : array();
  66. if(!$testcase->deleted) $actions = array_merge($actions['mainActions'], !empty($actions['mainActions']) && !empty($actions['suffixActions']) ? array(array('type' => 'divider')) : array(), $actions['suffixActions']);
  67. foreach($actions as $index => $action)
  68. {
  69. if(!isset($action['url'])) continue;
  70. $actions[$index]['url'] = str_replace(array('%executionID%', '{runID}', '{from}'), array((string)$this->session->execution, (string)$runID, $from), $action['url']);
  71. if($isInModal && !isset($action['data-toggle']) && !isset($action['data-load']))
  72. {
  73. $actions[$index]['data-load'] = 'modal';
  74. $actions[$index]['data-size'] = 'lg';
  75. }
  76. }
  77. $steps = array();
  78. if(!empty($case->steps) && $stepsType == 'table')
  79. {
  80. foreach($case->steps as $step)
  81. {
  82. $stepClass = $step->type == 'step' ? 'step-group' : "step-{$step->type}";
  83. $stepClass .= count($steps) > 0 && $step->grade == 1 ? ' mt-2' : ' border-t-0';
  84. $steps[] = cell
  85. (
  86. setClass("step {$stepClass} border align-top flex"),
  87. cell
  88. (
  89. setClass('text-left flex border-r step-id whitespace-pre-line'),
  90. width('1/2'),
  91. span
  92. (
  93. setClass('nowrap pr-2 pl-' . (($step->grade - 1) * 2)),
  94. $step->name
  95. ),
  96. text(html_entity_decode(str_replace(' ', '&nbsp;', $step->desc)))
  97. ),
  98. cell
  99. (
  100. setClass('text-left flex whitespace-pre-line'),
  101. width('1/2'),
  102. text(html_entity_decode(str_replace(' ', '&nbsp;', $step->expect)))
  103. )
  104. );
  105. }
  106. }
  107. $stepsTable = !empty($case->steps) ? div
  108. (
  109. $stepsType == 'table' ? div
  110. (
  111. setID('stepsTable'),
  112. div
  113. (
  114. setClass('steps-header'),
  115. div
  116. (
  117. setClass('text-left inline-block steps border'),
  118. width('1/2'),
  119. $lang->testcase->stepDesc
  120. ),
  121. div
  122. (
  123. setClass('text-left inline-block border border-l-0'),
  124. width('1/2'),
  125. $lang->testcase->stepExpect
  126. )
  127. ),
  128. div
  129. (
  130. setClass('steps-body'),
  131. $steps
  132. )
  133. ) : div
  134. (
  135. setID('stepsView'),
  136. setClass('relative'),
  137. mindmap
  138. (
  139. set::data($case->mindMapSteps),
  140. set::readonly(true)
  141. ),
  142. btn
  143. (
  144. setClass('ghost absolute z-1 top-1 right-1'),
  145. set::icon('fullscreen'),
  146. on::click()->call('zui.toggleFullscreen', '#stepsView')
  147. ),
  148. h::css('.is-in-fullscreen > .mindmap-iframe {height: 100%!important}')
  149. )
  150. ) : div
  151. (
  152. setClass('canvas text-center py-2'),
  153. p
  154. (
  155. setClass('py-2 my-2'),
  156. span
  157. (
  158. setClass('text-gray'),
  159. $lang->noData
  160. )
  161. )
  162. );
  163. $stepsActions = array();
  164. $stepsMisc = isInModal() ? array('data-load' => 'modal', 'data-target' => '.modal-content') : array();
  165. $stepsActions['items'][] = $stepsMisc + array('icon' => 'table', 'data-app' => $app->tab, 'size' => 'xs', 'type' => $stepsType == 'table' ? 'primary' : 'ghost', 'class' => 'mr-2', 'url' => createLink($viewModule, $viewMethod, "caseID={$case->id}&version={$version}&from={$from}&taskID={$taskID}&stepsType=table&suiteID={$suiteID}"));
  166. $stepsActions['items'][] = $stepsMisc + array('icon' => 'tree', 'data-app' => $app->tab, 'size' => 'xs', 'type' => $stepsType == 'mindmap' ? 'primary' : 'ghost', 'url' => createLink($viewModule, $viewMethod, "caseID={$case->id}&version={$version}&from={$from}&taskID={$taskID}&stepsType=mindmap&suiteID={$suiteID}"));
  167. /* 初始化主栏内容。Init sections in main column. */
  168. $sections = array();
  169. $sections[] = setting()
  170. ->title($lang->testcase->precondition)
  171. ->control('html')
  172. ->content($case->precondition);
  173. $sections[] = setting()
  174. ->title($lang->testcase->steps)
  175. ->titleActions($stepsActions)
  176. ->children(wg($stepsTable));
  177. $sections[] = setting()
  178. ->control('fileList')
  179. ->files($case->files)
  180. ->showDelete(false)
  181. ->padding(false)
  182. ->object($case);
  183. /* 初始化侧边栏标签页。Init sidebar tabs. */
  184. $tabs = array();
  185. $tabs[] = setting()
  186. ->group('basic')
  187. ->title($lang->testcase->legendBasicInfo)
  188. ->control('caseBasicInfo');
  189. $tabs[] = setting()
  190. ->group('basic')
  191. ->title($lang->testcase->legendOpenAndEdit)
  192. ->control('caseTimeInfo');
  193. $tabs['caseRelatedList'] = setting()
  194. ->group('relatives')
  195. ->title($lang->testcase->legendOther)
  196. ->control('caseRelatedList');
  197. detail
  198. (
  199. set::urlFormatter(array('{caseID}' => $case->caseID, '{version}' => $case->version, '{product}' => $case->product, '{branch}' => $case->branch, '{module}' => $case->module, '{id}' => $case->id, '{lib}' => $case->lib, '{confirmeObjectID}' => isset($case->confirmeObjectID) ? $case->confirmeObjectID : 0)),
  200. set::toolbar($toolbar),
  201. set::objectType('testcase'),
  202. set::object($case),
  203. set::sections($sections),
  204. set::tabs($tabs),
  205. set::actions($actions),
  206. set::linkCreator(createLink('testcase', 'view', "caseID={id}&version=0&from={$from}&taskID={$taskID}&stepsType={$stepsType}&suiteID={$suiteID}")),
  207. $versionBtn
  208. );