story.html.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /**
  3. * The story view file of my 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 Yuting Wang <wangyuting@easycorp.ltd>
  7. * @package my
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. include 'header.html.php';
  12. jsVar('children', $lang->story->children);
  13. jsVar('childrenAB', $lang->story->childrenAB);
  14. jsVar('showGrade', $showGrade);
  15. jsVar('gradeGroup', $gradeGroup);
  16. jsVar('window.globalSearchType', 'story');
  17. featureBar
  18. (
  19. set::current($type),
  20. set::linkParams("mode=story&type={key}&param=&orderBy={$orderBy}"),
  21. li(searchToggle(set::module($this->app->rawMethod . 'Story'), set::open($type == 'bysearch')))
  22. );
  23. $viewType = $this->cookie->storyViewType ? $this->cookie->storyViewType : 'tree';
  24. toolbar
  25. (
  26. item(set(array
  27. (
  28. 'type' => 'btnGroup',
  29. 'items' => array(array
  30. (
  31. 'icon' => 'list',
  32. 'class' => 'btn-icon switchButton' . ($viewType == 'tiled' ? ' text-primary' : ''),
  33. 'data-type' => 'tiled',
  34. 'hint' => $lang->story->viewTypeList['tiled']
  35. ), array
  36. (
  37. 'icon' => 'treeview',
  38. 'class' => 'switchButton btn-icon' . ($viewType == 'tree' ? ' text-primary' : ''),
  39. 'data-type' => 'tree',
  40. 'hint' => $lang->story->viewTypeList['tree']
  41. ))
  42. )))
  43. );
  44. $canBatchEdit = common::hasPriv('story', 'batchEdit');
  45. $canBatchReview = common::hasPriv('story', 'batchReview');
  46. $canBatchAssignTo = common::hasPriv('story', 'batchAssignTo');
  47. $canBatchClose = common::hasPriv('story', 'batchClose');
  48. $canBatchAction = $canBatchEdit || $canBatchReview || $canBatchAssignTo || $canBatchClose;
  49. $reviewItems = array();
  50. if($canBatchReview)
  51. {
  52. $rejectItems = array();
  53. foreach($lang->story->reasonList as $key => $reason)
  54. {
  55. if(!$key || $key == 'subdivided' || $key == 'duplicate') continue;
  56. $rejectItems[] = array('text' => $reason, 'innerClass' => 'batch-btn ajax-btn not-open-url', 'data-url' => helper::createLink('story', 'batchReview', "result=reject&reason={$key}&storyType=story"));
  57. }
  58. foreach($lang->story->reviewResultList as $key => $result)
  59. {
  60. if(!$key || $key == 'revert') continue;
  61. if($key == 'reject')
  62. {
  63. $reviewItems[] = array('text' => $result, 'class' => 'not-hide-menu', 'items' => $rejectItems);
  64. }
  65. else
  66. {
  67. $reviewItems[] = array('text' => $result, 'innerClass' => 'batch-btn ajax-btn not-open-url', 'data-url' => helper::createLink('story', 'batchReview', "result={$key}&reason=&storyType=story"));
  68. }
  69. }
  70. }
  71. $assignedToItems = array();
  72. if($canBatchAssignTo)
  73. {
  74. $pinyinItems = common::convert2Pinyin($users);
  75. foreach($users as $key => $value)
  76. {
  77. if(empty($key) || $key == 'closed') continue;
  78. $assignedToItems[] = array('text' => $value, 'keys' => zget($pinyinItems, $value, ''), 'innerClass' => 'batch-btn ajax-btn not-open-url', 'data-url' => helper::createLink('story', 'batchAssignTo', "storyType=story&assignedTo={$key}"));
  79. }
  80. }
  81. $footToolbar = array('items' => array
  82. (
  83. $canBatchEdit ? array('text' => $lang->edit, 'className' => 'batch-btn', 'data-url' => helper::createLink('story', 'batchEdit', "productID=0&executionID=0&branch=0&storyType=story&from={$app->rawMethod}")) : null,
  84. $canBatchReview ? array('caret' => 'up', 'text' => $lang->story->review, 'type' => 'dropdown', 'items' => $reviewItems, 'data-placement' => 'top-start') : null,
  85. $canBatchAssignTo ? array('caret' => 'up', 'text' => $lang->story->assignedTo, 'type' => 'dropdown', 'items' => $assignedToItems, 'data-placement' => 'top-start', 'data-menu' => array('searchBox' => true)) : null,
  86. $canBatchClose ? array('text' => $lang->story->close, 'className' => 'batch-btn', 'data-url' => helper::createLink('story', 'batchClose', "productID=0&executionID=0&storyType=story&from={$app->rawMethod}")) : null
  87. ), 'btnProps' => array('size' => 'sm', 'btnType' => 'secondary'));
  88. if($canBatchAction) $config->my->story->dtable->fieldList['id']['type'] = 'checkID';
  89. $stories = initTableData($stories, $config->my->story->dtable->fieldList, $this->story);
  90. /* 父需求去掉创建用例按钮。 */
  91. foreach($stories as $id => $story)
  92. {
  93. if(isset($story->actions))
  94. {
  95. foreach($story->actions as $key => $action)
  96. {
  97. if($action['name'] == 'create' && $story->isParent == '1') $stories[$id]->actions[$key]['disabled'] = 1;
  98. if(!empty($story->frozen) && in_array($action['name'], array('edit', 'change'))) $stories[$id]->actions[$key]['hint'] = sprintf($lang->story->frozenTip, $lang->story->{$action['name']});
  99. }
  100. }
  101. $story->estimate = helper::formatHours($story->estimate);
  102. }
  103. if($viewType == 'tiled') $config->my->story->dtable->fieldList['title']['nestedToggle'] = false;
  104. $cols = array_values($config->my->story->dtable->fieldList);
  105. $data = array_values($stories);
  106. dtable
  107. (
  108. set::cols($cols),
  109. set::data($data),
  110. set::userMap($users),
  111. set::fixedLeftWidth('44%'),
  112. set::checkable($canBatchAction ? true : false),
  113. set::onRenderCell(jsRaw('window.renderCell')),
  114. set::orderBy($orderBy),
  115. set::sortLink(createLink('my', $app->rawMethod, "mode={$mode}&type={$type}&param={$param}&orderBy={name}_{sortType}&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}")),
  116. set::footToolbar($footToolbar),
  117. set::footPager(usePager()),
  118. set::emptyTip(sprintf($lang->my->noData, $lang->SRCommon))
  119. );
  120. render();