browse.html.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <?php
  2. /**
  3. * The browsetask view file of tree 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 Jinyong Zhu<zhujinyong@easycorp.ltd>
  7. * @package tree
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. jsVar('rootID', $root->id);
  12. jsVar('viewType', $viewType);
  13. jsVar('noSubmodule', $lang->tree->noSubmodule);
  14. $manageTitle = $lang->tree->manageChild;
  15. if(strpos($viewType, 'doc') !== false)
  16. {
  17. $manageTitle = $lang->doc->manageType;
  18. }
  19. elseif($viewType == 'host')
  20. {
  21. $manageTitle = $lang->host->groupMaintenance;
  22. }
  23. elseif(strpos($viewType, 'trainskill') === false and strpos($viewType, 'trainpost') === false)
  24. {
  25. $manageChild = 'manage' . ucfirst($viewType) . 'Child';
  26. $manageTitle = $lang->tree->$manageChild;
  27. }
  28. $maxOrder = 0;
  29. /* Generate module rows. */
  30. $moduleRows = array();
  31. if($viewType == 'story' && $allProduct)
  32. {
  33. $moduleRows[] = formRow
  34. (
  35. setClass('copyBox hidden'),
  36. formGroup
  37. (
  38. inputGroup(setClass('row-module'), picker(setClass('col-module'), set::name("allProduct"), set::items($allProduct), on::change("syncProduct(e.target)"), set::required(true)), picker(setClass('col-short'), set::name("productModule"), set::items($productModules), set::required(true))),
  39. btn(setID('copyModule'), on::click("syncModule"), icon('copy'), setClass('ghost'))
  40. )
  41. );
  42. }
  43. foreach($sons as $son)
  44. {
  45. if($son->order > $maxOrder) $maxOrder = $son->order;
  46. $disabled = $son->type != $viewType;
  47. $moduleRows[] = formRow
  48. (
  49. setClass('sonModule'),
  50. formGroup
  51. (
  52. inputGroup
  53. (
  54. setClass('row-module no-morph'),
  55. input
  56. (
  57. setClass('col-module'),
  58. set::name("modules[id$son->id]"),
  59. set::type('input'),
  60. set::value($son->name),
  61. set::disabled($disabled),
  62. set::placeholder($placeholder)
  63. ),
  64. empty($branches) ? null : picker
  65. (
  66. set::name("branch[id$son->id]"),
  67. set::items($branches),
  68. set::value($son->branch),
  69. set::disabled($disabled),
  70. set::required(true)
  71. ),
  72. input
  73. (
  74. setClass('col-short'),
  75. set::name("shorts[id$son->id]"),
  76. set::type('input'),
  77. set::value($son->short),
  78. set::disabled($disabled),
  79. set::placeholder($lang->tree->short)
  80. ),
  81. input
  82. (
  83. setClass('hidden'),
  84. set::name("order[id$son->id]"),
  85. set::disabled($disabled),
  86. set::value($son->order),
  87. set::control('hidden')
  88. )
  89. ),
  90. batchActions(set::actionClass('action-group child-hidden'))
  91. )
  92. );
  93. }
  94. $initBranch = (int)$branch;
  95. if($parentModules)
  96. {
  97. $parentModule = end($parentModules);
  98. $initBranch = (int)$parentModule->branch;
  99. }
  100. for($i = 0; $i < \tree::NEW_CHILD_COUNT; $i ++)
  101. {
  102. $moduleRows[] = formRow
  103. (
  104. formGroup
  105. (
  106. inputGroup
  107. (
  108. setClass('row-module no-morph'),
  109. input
  110. (
  111. setClass('col-module'),
  112. set::name("modules[]"),
  113. set::type('input'),
  114. set::value(''),
  115. set::placeholder($placeholder)
  116. ),
  117. empty($branches) ? null : picker
  118. (
  119. set::name("branch[]"),
  120. set::items($branches),
  121. set::value($initBranch),
  122. set::required(true)
  123. ),
  124. input
  125. (
  126. setClass('col-short'),
  127. set::name("shorts[]"),
  128. set::type('input'),
  129. set::placeholder($lang->tree->short)
  130. )
  131. ),
  132. batchActions(set::actionClass('action-group'))
  133. )
  134. );
  135. }
  136. $parentPath = array();
  137. $parentLinkData = array('app' => $app->tab);
  138. if(isInModal())
  139. {
  140. $parentLinkData['size'] = 'lg';
  141. $parentLinkData['toggle'] = 'modal';
  142. $parentLinkData['dismiss'] = 'modal';
  143. }
  144. $parentPath[] = div
  145. (
  146. setClass('row flex-nowrap items-center'),
  147. a
  148. (
  149. setClass('tree-link text-clip'),
  150. set('href', helper::createLink('tree', 'browse', "rootID=$root->id&view={$viewType}&currentModuleID=0&branch=$branch")),
  151. setData($parentLinkData),
  152. set::title($root->name),
  153. $root->name
  154. ),
  155. h::i
  156. (
  157. setClass('icon icon-angle-right muted align-middle'),
  158. setStyle('color', '#313C52')
  159. )
  160. );
  161. foreach($parentModules as $module)
  162. {
  163. $parentPath[] = div
  164. (
  165. setClass('row flex-nowrap items-center'),
  166. a
  167. (
  168. setClass('tree-link text-clip'),
  169. set('href', helper::createLink('tree', 'browse', "rootID=$root->id&view={$viewType}&currentModuleID=$module->id&branch=$branch")),
  170. set('data-app', $app->tab),
  171. set::title($module->name),
  172. $module->name
  173. ),
  174. h::i
  175. (
  176. setClass('icon icon-angle-right muted align-middle'),
  177. setStyle('color', '#313C52')
  178. )
  179. );
  180. }
  181. div
  182. (
  183. setClass('row gap-4'),
  184. !isInModal() ? backBtn
  185. (
  186. set::icon('back'),
  187. set::type('secondary'),
  188. $lang->goback
  189. ) : null,
  190. div
  191. (
  192. setClass('entity-label flex items-center gap-x-2 text-lg font-bold'),
  193. $viewType == 'host' ? $root->name : $lang->tree->common . $lang->hyphen . $root->name
  194. )
  195. );
  196. div
  197. (
  198. setClass('row gap-4 mt-2'),
  199. sidebar
  200. (
  201. set::toggleBtn(false),
  202. set::width(400),
  203. set::minWidth(350),
  204. set::maxWidth(550),
  205. panel
  206. (
  207. set::title($title),
  208. ($app->tab == 'product' and $viewType == 'story') ? to::headingActions
  209. (
  210. btn
  211. (
  212. setClass('primary size-sm'),
  213. set::url('tree', 'viewHistory', "productID=$rootID"),
  214. toggle::modal(),
  215. $lang->history
  216. )
  217. ) : null,
  218. treeEditor
  219. (
  220. set::selected($currentModuleID),
  221. set::type($viewType),
  222. set::items($tree),
  223. set::canEdit(common::hasPriv('tree', 'edit') && $canBeChanged),
  224. set::canDelete(common::hasPriv('tree', 'delete') && $canBeChanged),
  225. set::canSplit($viewType != 'deliverable'),
  226. set::sortable(array('handle' => '.icon-move')),
  227. set::onSort(jsRaw('window.updateOrder'))
  228. )
  229. )
  230. ),
  231. div
  232. (
  233. setClass('flex-auto'),
  234. setID('modulePanel'),
  235. panel
  236. (
  237. setClass('pb-4'),
  238. set::title($manageTitle),
  239. to::headingActions
  240. (
  241. ($viewType == 'story' && $allProduct && $canBeChanged) ? btn(setClass('primary'), set::size('sm'), $lang->tree->syncFromProduct, on::click('toggleCopy')) : null
  242. ),
  243. div
  244. (
  245. setClass('flex'),
  246. div
  247. (
  248. setClass('pr-2 tree-item-content row items-center'),
  249. setStyle('max-width', '380px'),
  250. setStyle('padding-bottom', '48px'),
  251. $parentPath
  252. ),
  253. form
  254. (
  255. setClass('flex-1 form-horz'),
  256. set::url(helper::createLink('tree', 'manageChild', "root=$root->id&viewType=$viewType")),
  257. set('data-app', $app->tab),
  258. $moduleRows,
  259. set::actionsClass('justify-start'),
  260. set::submitBtnText($lang->save),
  261. set::back($isFlowModule ? 'GLOBAL' : 'APP'),
  262. input
  263. (
  264. set::type('hidden'),
  265. set::name('parentModuleID'),
  266. set::value($currentModuleID),
  267. set::control('hidden')
  268. ),
  269. input
  270. (
  271. set::type('hidden'),
  272. set::name('maxOrder'),
  273. set::value($maxOrder),
  274. set::control('hidden')
  275. )
  276. )
  277. )
  278. )
  279. )
  280. );
  281. render();