story.html.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. * The story view file of product plan 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 Tingting Dai <daitingting@easycorp.ltd>
  7. * @package productplan
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. jsVar('gradeGroup', $gradeGroup);
  12. $isFromAI = $from === 'ai';
  13. $storyCols = array();
  14. foreach($config->productplan->defaultFields['story'] as $field)
  15. {
  16. if($field == 'branch' && $product->type == 'normal') continue;
  17. $storyCols[$field] = zget($config->story->dtable->fieldList, $field, array());
  18. }
  19. if(isset($storyCols['branch'])) $storyCols['branch']['map'] = $branchOption;
  20. $storyCols['title']['title'] = $lang->productplan->storyTitle;
  21. $storyCols['assignedTo']['type'] = 'user';
  22. $storyCols['module']['type'] = 'text';
  23. $storyCols['module']['map'] = $modulePairs;
  24. foreach($storyCols as $storyColKey => $storyCol)
  25. {
  26. $storyCols[$storyColKey]['sortType'] = false;
  27. if(isset($storyCol['link'])) unset($storyCols[$storyColKey]['link']);
  28. if($storyColKey == 'title') $storyCols[$storyColKey]['link'] = array('url' => createLink('{type}', 'view', "storyID={id}&version={version}"), 'data-toggle' => 'modal', 'data-size' => 'lg');
  29. }
  30. unset($storyCols['actions']);
  31. $productsWithShadow = $this->loadModel('product')->getPairs('', 0, '', 'all');
  32. $productChangeLink = createLink('productplan', 'story', "productID={productID}&planID=0&blockID=$blockID&orderBy=$orderBy&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}&from=$from");
  33. $planChangeLink = createLink('productplan', 'story', "productID=$productID&planID={planID}&blockID=$blockID&orderBy=$orderBy&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}&from=$from");
  34. $insertListLink = createLink('productplan', 'story', "productID=$productID&planID=$planID&blockID={blockID}&orderBy=$orderBy&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}&from=$from");
  35. $footToolbar = array(array('text' => $lang->doc->insertText, 'data-on' => 'click', 'data-call' => "insertListToDoc('#planStories', 'planStory', $blockID, '$insertListLink')"));
  36. if($isFromAI) $footToolbar = array(array('text' => $lang->doc->insertText, 'data-on' => 'click', 'data-call' => "insertListToAI('#planStories', 'story')"));
  37. formPanel
  38. (
  39. setID('zentaolist'),
  40. setClass('mb-4-important'),
  41. set::title(sprintf($this->lang->doc->insertTitle, $this->lang->doc->zentaoList['planStory'])),
  42. set::actions(array()),
  43. set::showExtra(false),
  44. to::titleSuffix
  45. (
  46. span
  47. (
  48. setClass('text-muted text-sm text-gray-600 font-light'),
  49. span(setClass('text-warning mr-1'), icon('help')),
  50. $lang->doc->previewTip
  51. )
  52. ),
  53. formRow
  54. (
  55. formGroup
  56. (
  57. set::width('1/2'),
  58. set::name('product'),
  59. set::label($lang->doc->product),
  60. set::control(array('required' => false)),
  61. set::items($productsWithShadow),
  62. set::value($productID),
  63. set::required(),
  64. span
  65. (
  66. setClass('error-tip text-danger hidden'),
  67. $lang->doc->emptyError
  68. ),
  69. on::change('[name="product"]')->do("loadModal('$productChangeLink'.replace('{productID}', $(this).val()))")
  70. )
  71. ),
  72. formRow
  73. (
  74. formGroup
  75. (
  76. set::width('1/2'),
  77. set::name('plan'),
  78. set::label($lang->doc->plan),
  79. set::control(array('required' => false)),
  80. set::items($plans),
  81. set::value($planID),
  82. set::required(),
  83. span
  84. (
  85. setClass('error-tip text-danger hidden'),
  86. $lang->doc->emptyError
  87. ),
  88. on::change('[name="plan"]')->do("loadModal('$planChangeLink'.replace('{planID}', $(this).val()))")
  89. )
  90. )
  91. );
  92. foreach($planStories as $story) $story->estimate = helper::formatHours($story->estimate) . $config->hourUnit;
  93. dtable
  94. (
  95. setID('planStories'),
  96. set::userMap($users),
  97. set::checkable(),
  98. set::cols($storyCols),
  99. set::data(array_values($planStories)),
  100. set::noNestedCheck(),
  101. set::orderBy($orderBy),
  102. set::onRenderCell(jsRaw('window.renderStoryCell')),
  103. set::footPager(usePager()),
  104. set::emptyTip($lang->story->noStory),
  105. set::footToolbar($footToolbar),
  106. set::height(400),
  107. set::afterRender(jsCallback()->call('toggleCheckRows', $idList)),
  108. set::onCheckChange(jsRaw('window.checkedChange'))
  109. );
  110. render();