batchcreate.html.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. /**
  3. * The UI file of story 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 chen.tao <chentao@easycorp.ltd>
  8. * @package story
  9. * @link https://www.zentao.net
  10. */
  11. namespace zin;
  12. include($this->app->getModuleRoot() . 'ai/ui/inputinject.html.php');
  13. if($app->tab == 'product') data('activeMenuID', $type);
  14. data('storyType', $type);
  15. jsVar('storyType', $type);
  16. jsVar('productID', $productID);
  17. jsVar('executionID', $executionID);
  18. jsVar('branch', $branch);
  19. jsVar('storyID', $storyID);
  20. data('gradeRule', $gradeRule);
  21. !isAjaxRequest() && dropmenu();
  22. foreach(explode(',', $this->config->{$type}->create->requiredFields) as $requiredField)
  23. {
  24. if(isset($customFields[$requiredField]) and strpos(",{$showFields},", ",{$requiredField},") === false) $showFields .= ',' . $requiredField;
  25. }
  26. $roadmaps = !empty($roadmaps) ? $roadmaps : array();
  27. /* Generate fields for the batch create form. */
  28. $fnGenerateFields = function() use ($app, $lang, $type, $fields, $stories, $customFields, $showFields, $storyID, $gradeRule, $roadmaps)
  29. {
  30. global $config;
  31. /* Generate fields with the appropriate properties. */
  32. $items = array();
  33. $items[] = array('name' => 'id', 'label' => $lang->idAB, 'control' => 'index', 'width' => '32px');
  34. if($stories) $items[] = array('name' => 'uploadImage', 'label' => '', 'control' => 'hidden', 'hidden' => true);
  35. unset($fields['color']);
  36. $cols = array_merge($items, array_map(function($name, $field)
  37. {
  38. if($name == 'title') $field['control'] = 'colorInput';
  39. $field['name'] = $name;
  40. if(!empty($field['options'])) $field['items'] = $field['options'];
  41. if(!empty($field['default'])) $field['value'] = $field['default'];
  42. if($field['control'] == 'select') $field['control'] = 'picker';
  43. if($field['control'] == 'picker' and !isset($field['items'])) $field['items'] = array();
  44. unset($field['options']);
  45. return $field;
  46. }, array_keys($fields), array_values($fields)));
  47. /* Hide columns that are not displayed. */
  48. foreach($cols as $index => $col)
  49. {
  50. $colName = $col['name'];
  51. if(strpos(",{$config->{$app->rawModule}->create->requiredFields},", ",{$colName},") !== false) $cols[$index]['required'] = true;
  52. if(isset($customFields[$colName]) && strpos(",$showFields,", ",$colName,") === false) $cols[$index]['hidden'] = true;
  53. if($colName == 'sourceNote' && strpos(",$showFields,", ",source,") === false) $cols[$index]['hidden'] = true;
  54. if($colName == 'plan' && $type != 'story') $cols[$index]['multiple'] = true;
  55. if($colName == 'grade' && $gradeRule == 'stepwise') $cols[$index]['disabled'] = true;
  56. if($colName == 'parent' && $storyID > 0 ) $cols[$index]['hidden'] = true;
  57. if($colName == 'source') $cols[$index]['items'] = $lang->{$type}->sourceList;
  58. if($colName == 'category') $cols[$index]['items'] = $lang->{$type}->categoryList;
  59. if($colName == 'roadmap') $cols[$index]['items'] = $roadmaps;
  60. if($colName == 'grade') $cols[$index]['required'] = true;
  61. if($colName == 'branch') $cols[$index]['defaultDitto'] = false;
  62. if($colName == 'pri')
  63. {
  64. $cols[$index]['items'] = $lang->{$type}->priList;
  65. $cols[$index]['value'] = (string)$col['value'];
  66. $cols[$index]['default'] = (string)$col['default'];
  67. }
  68. }
  69. return $cols;
  70. };
  71. $storyTypeRadio = null;
  72. if($storyID > 0 && $story->type != 'story' && $config->{$story->type}->gradeRule != 'stepwise')
  73. {
  74. $gradeRule = $this->config->{$story->type}->gradeRule;
  75. $isLastGrade = $story->grade == $maxGradeGroup[$story->type];
  76. $disabled = $story->isParent == '1' || $isLastGrade || ($gradeRule == 'stepwise' && !$isLastGrade);
  77. $title = '';
  78. if($story->isParent == '1') $title = $lang->story->errorCannotSplit;
  79. if($isLastGrade) $title = $lang->story->errorMaxGradeSubdivide;
  80. if(!$isLastGrade && $gradeRule == 'stepwise') $title = $lang->story->errorStepwiseSubdivide;
  81. if($story->type == 'epic') unset($lang->story->typeList['story']);
  82. if($story->type == 'requirement') unset($lang->story->typeList['epic']);
  83. if($story->type == 'requirement' && $config->vision == 'or') unset($lang->story->typeList['story']);
  84. $storyTypeRadio = radioList
  85. (
  86. set::name('typeSwitcher'),
  87. set::items($lang->story->typeList),
  88. set::inline(true),
  89. set::value($type),
  90. set::disabled($disabled),
  91. $title ? set::title($title) : null,
  92. on::change('switchType')
  93. );
  94. }
  95. formBatchPanel
  96. (
  97. setID('dataform'),
  98. on::change('[data-name="branch"]', 'setModuleAndPlanByBranch'),
  99. on::change('[data-name="parent"]', 'setGrade'),
  100. on::change('[data-name="region"]', 'changeRegion'),
  101. on::change('[data-name="source"]')->call('setSourceNote', jsRaw('event')),
  102. set::onRenderCol(jsRaw('window.handleRenderFieldCol')),
  103. $stories ? set::data($stories) : null,
  104. set::ajax(array('beforeSubmit' => jsRaw('clickSubmit'))),
  105. set::title($storyID ? $storyTitle . $lang->hyphen . $this->lang->story->subdivide : $this->lang->story->batchCreate),
  106. $storyTypeRadio ? set::headingActionsClass('flex-auto row-reverse justify-between w-11/12') : null,
  107. $storyTypeRadio ? to::headingActions($storyTypeRadio) : null,
  108. set::uploadParams('module=story&params=' . helper::safe64Encode("productID=$productID&branch=$branch&moduleID=$moduleID&storyID=$storyID&executionID=$executionID&plan={$planID}&type=$type")),
  109. set::pasteField('title'),
  110. set::customFields(array('list' => $customFields, 'show' => explode(',', $showFields), 'key' => 'batchCreateFields')),
  111. set::items($fnGenerateFields()),
  112. set::actions(array
  113. (
  114. array('text' => $lang->save, 'data-status' => 'active', 'class' => 'primary', 'btnType' => 'submit'),
  115. array('text' => $lang->story->saveDraft, 'data-status' => 'draft', 'class' => 'secondary', 'btnType' => 'submit'),
  116. array('text' => $lang->goback, 'data-back' => 'APP', 'class' => 'open-url')
  117. )),
  118. formHidden('type', $type),
  119. formHidden('status', '')
  120. );
  121. render();