editstruct.html.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <?php
  2. /**
  3. * The edit struct view file of api 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 Gang Liu <liugang@easycorp.ltd>
  7. * @package api
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. $attributes = array();
  12. if(!empty($struct->attribute))
  13. {
  14. $buildAttributes = function($struct, $data, $typeList, $level = 0) use (&$buildAttributes)
  15. {
  16. global $lang;
  17. $hidden = $struct->type == 'formData' ? 'hidden' : '';
  18. $attributes[] = h::tr
  19. (
  20. setClass('input-row'),
  21. setData(array('level' => $level + 1, 'key' => $data['key'], 'parent' => isset($data['parent']) ? $data['parent'] : 0)),
  22. h::td
  23. (
  24. $level ? setStyle('padding-left', ($level + 1) * 10 . 'px') : null,
  25. input
  26. (
  27. set::name(''),
  28. set::value($data['field'])
  29. )
  30. ),
  31. h::td
  32. (
  33. select
  34. (
  35. setClass('objectType'),
  36. set::name(''),
  37. set::value($data['paramsType']),
  38. set::items($typeList)
  39. )
  40. ),
  41. h::td
  42. (
  43. $data['required'] ? html("<input type='checkbox' checked/>") : html("<input type='checkbox' />")
  44. ),
  45. h::td
  46. (
  47. textarea
  48. (
  49. set::rows(1),
  50. set::name(''),
  51. set::value($data['desc'])
  52. )
  53. ),
  54. h::td
  55. (
  56. div
  57. (
  58. setClass('pl-2 flex self-center line-btn'),
  59. btn
  60. (
  61. setClass("btn ghost btn-split $hidden"),
  62. icon('split')
  63. ),
  64. btn
  65. (
  66. setClass('btn ghost btn-add'),
  67. icon('plus')
  68. ),
  69. btn
  70. (
  71. setClass('btn ghost btn-delete'),
  72. icon('trash')
  73. )
  74. )
  75. )
  76. );
  77. if(isset($data['children']) && count($data['children']) > 0)
  78. {
  79. $level++;
  80. foreach($data['children'] as $attribute) $attributes[] = $buildAttributes($struct, $attribute, $typeList, $level);
  81. }
  82. return $attributes;
  83. };
  84. foreach($struct->attribute as $attribute) $attributes[] = $buildAttributes($struct, $attribute, $typeOptions);
  85. }
  86. else
  87. {
  88. $attributes = h::tr
  89. (
  90. setClass('input-row'),
  91. setData(array('level' => 1, 'key' => 'origin', 'parent' => '0')),
  92. h::td
  93. (
  94. input
  95. (
  96. set::name('')
  97. )
  98. ),
  99. h::td
  100. (
  101. select
  102. (
  103. setClass('objectType'),
  104. set::name(''),
  105. set::value('object'),
  106. set::items($lang->api->paramsTypeOptions)
  107. )
  108. ),
  109. h::td
  110. (
  111. html("<input type='checkbox' />")
  112. ),
  113. h::td
  114. (
  115. textarea
  116. (
  117. set::rows(1),
  118. set::name('')
  119. )
  120. ),
  121. h::td
  122. (
  123. div
  124. (
  125. setClass('pl-2 flex self-center line-btn'),
  126. btn
  127. (
  128. setClass('btn ghost btn-split hidden'),
  129. icon('split')
  130. ),
  131. btn
  132. (
  133. setClass('btn ghost btn-add'),
  134. icon('plus')
  135. ),
  136. btn
  137. (
  138. setClass('btn ghost btn-delete'),
  139. icon('trash')
  140. )
  141. )
  142. )
  143. );
  144. }
  145. formPanel
  146. (
  147. to::heading
  148. (
  149. div
  150. (
  151. setClass('panel-title text-lg'),
  152. $lang->api->editStruct
  153. )
  154. ),
  155. formGroup
  156. (
  157. set::width('1/2'),
  158. set::label($lang->api->structName),
  159. set::name('name'),
  160. set::value($struct->name),
  161. set::required(true)
  162. ),
  163. formGroup
  164. (
  165. setID('form-paramsType'),
  166. setClass('params-group struct'),
  167. set::label($lang->struct->type),
  168. radioList
  169. (
  170. set::name('type'),
  171. set::inline(true),
  172. set::value($struct->type),
  173. set::items($lang->struct->typeOptions)
  174. )
  175. ),
  176. formGroup
  177. (
  178. setID('form-params'),
  179. setClass('params-group struct'),
  180. set::label($lang->api->params),
  181. h::table
  182. (
  183. setClass('table condensed bordered'),
  184. h::tr
  185. (
  186. h::th
  187. (
  188. width('300px'),
  189. $lang->struct->field
  190. ),
  191. h::th
  192. (
  193. width('100px'),
  194. $lang->struct->paramsType
  195. ),
  196. h::th
  197. (
  198. width('70px'),
  199. $lang->struct->required
  200. ),
  201. h::th
  202. (
  203. $lang->struct->desc
  204. ),
  205. h::th
  206. (
  207. width('100px')
  208. )
  209. ),
  210. $attributes
  211. )
  212. ),
  213. formHidden('attribute', json_encode($struct->attribute)),
  214. formGroup
  215. (
  216. set::label($lang->api->desc),
  217. editor
  218. (
  219. set::name('desc'),
  220. html($struct->desc)
  221. )
  222. )
  223. );
  224. render();