create.text.html.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <?php
  2. /**
  3. * The create view file of doc module of ZenTaoPMS.
  4. * @copyright Copyright 2024 禅道软件(青岛)有限公司(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 Sun Hao<sunhao@easycorp.ltd>
  7. * @package doc
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. jsVar('isTutorialMode', common::isTutorialMode());
  12. include 'lefttree.html.php';
  13. $headingActions = array('class' => 'gap-3 pr-1', 'items' => array());
  14. if(!common::isTutorialMode()) $headingActions['items'][] = array('type' => 'secondary', 'class' => 'save-draft', 'text' => $lang->doc->saveDraft, 'btnType' => 'submit');
  15. $headingActions['items'][] = array('type' => 'primary', 'class' => 'btn-wide release-btn', 'text' => $lang->doc->release, 'url' => '#modalBasicInfo', 'data-toggle' => 'modal');
  16. $basicInfoModal = modal
  17. (
  18. set::title($lang->doc->release . $lang->doc->common),
  19. set::id('modalBasicInfo'),
  20. set::bodyClass('form form-horz'),
  21. on::change('[name=space],[name=product],[name=execution]')->call('loadObjectModules', jsRaw('event')),
  22. on::change('[name=lib]')->call('loadLibModules', jsRaw('event')),
  23. on::change('[name=project]')->call('loadExecutions', jsRaw('event')),
  24. on::change('[name=lib],[name^=users]', 'checkLibPriv'),
  25. $lib->type == 'project' ? formRow
  26. (
  27. formGroup
  28. (
  29. setClass('w-1/2'),
  30. set::label($lang->doc->project),
  31. set::required(true),
  32. set::control(array('control' => 'picker', 'name' => 'project', 'items' => $objects, 'required' => true, 'value' => isset($execution) ? $execution->project : $objectID))
  33. ),
  34. ($this->app->tab == 'doc' and $config->vision == 'rnd') ? formGroup
  35. (
  36. setClass('w-1/2'),
  37. set::label($lang->doc->execution),
  38. set::control(array('control' => 'picker', 'name' => 'execution', 'items' => $executions, 'value' => isset($execution) ? $objectID : ''))
  39. ) : null
  40. ) : null,
  41. ($lib->type == 'execution') ? formGroup
  42. (
  43. set::width('1/2'),
  44. set::label($lang->doc->execution),
  45. set::required(true),
  46. set::control(array('control' => 'picker', 'name' => 'execution', 'items' => $objects, 'required' => true, 'value' => $lib->execution))
  47. ) : null,
  48. ($lib->type == 'product') ? formGroup
  49. (
  50. set::width('1/2'),
  51. set::label($lang->doc->product),
  52. set::required(true),
  53. set::control(array('control' => 'picker', 'name' => 'product', 'items' => $objects, 'required' => true, 'value' => $objectID))
  54. ) : null,
  55. isset($spaces) ? formGroup
  56. (
  57. set::width('1/2'),
  58. set::label($lang->doc->space),
  59. set::required(true),
  60. set::control(array('control' => 'picker', 'name' => 'space', 'items' => $spaces, 'required' => true, 'value' => $objectID, 'disabled' => $lib->type == 'mine'))
  61. ) : null,
  62. formGroup
  63. (
  64. setData('libType', $lib->type),
  65. set::width('1/2'),
  66. set::label($lang->doc->lib),
  67. set::required(true),
  68. picker(set::name('lib'), set::items($libs), set::value(isset($libs[$libID]) ? $libID : ''), set::required(true))
  69. ),
  70. formGroup
  71. (
  72. set::width('1/2'),
  73. set::label($lang->doc->module),
  74. picker(set::name('module'), set::items($optionMenu), set::value($moduleID), set::required(true))
  75. ),
  76. formGroup
  77. (
  78. setClass('flex items-center preserve-on-morph'),
  79. set::label($lang->doc->title),
  80. set::name('title'),
  81. set::control('input'),
  82. set::required(),
  83. on::change()->do('$("#showTitle").val($("#title").val())')
  84. ),
  85. formGroup
  86. (
  87. set::label($lang->doc->keywords),
  88. set::control('input'),
  89. set::name('keywords')
  90. ),
  91. formGroup
  92. (
  93. setStyle('min-height', 'auto'),
  94. set::label($lang->doc->files),
  95. fileSelector()
  96. ),
  97. formGroup
  98. (
  99. set::label($lang->doc->mailto),
  100. mailto(set::items($users))
  101. ),
  102. formGroup
  103. (
  104. set::label($lang->doclib->control),
  105. radioList
  106. (
  107. set::name('acl'),
  108. set::items($lang->doc->aclList),
  109. set::value($objectType == 'mine' ? 'private' : 'open'),
  110. on::change('toggleWhiteList')
  111. )
  112. ),
  113. formGroup
  114. (
  115. setID('whiteListBox'),
  116. setClass('hidden'),
  117. set::label($lang->doc->whiteList),
  118. div
  119. (
  120. setClass('w-full check-list'),
  121. inputGroup
  122. (
  123. setClass('w-full'),
  124. $lang->doc->groupLabel,
  125. picker
  126. (
  127. set::name('groups[]'),
  128. set::items($groups),
  129. set::multiple(true)
  130. )
  131. ),
  132. div
  133. (
  134. setClass('w-full'),
  135. userPicker(set::label($lang->doc->userLabel), set::items($users))
  136. )
  137. )
  138. ),
  139. formRow
  140. (
  141. div
  142. (
  143. setClass('form-actions form-group no-label'),
  144. btn(set::type('primary'), set::btnType('submit'), setClass('saveBasicInfoBtn'), $lang->doc->release)
  145. )
  146. )
  147. );
  148. $handleSubmitForm = <<<'JS'
  149. function(e)
  150. {
  151. const isDraft = $(e.submitter).hasClass('save-draft');
  152. const $showTitle = $('#showTitle');
  153. if(isDraft && !$showTitle.val().length)
  154. {
  155. zui.Modal.alert($showTitle.data('titleHint')).then(() => $showTitle[0].focus());
  156. return false;
  157. }
  158. $(e.target).removeClass('has-changed').find('input[name=status]').val(isDraft ? 'draft' : 'normal');
  159. const pageEditor = $('#docEditor').zui('pageEditor');
  160. if(pageEditor) return pageEditor.syncData().then(() => true);
  161. }
  162. JS;
  163. formBase
  164. (
  165. setID('docForm'),
  166. setData('unsavedConfirm', $lang->doc->confirmLeaveOnEdit),
  167. set::actions(false),
  168. set::ajax(array('beforeSubmit' => jsRaw($handleSubmitForm), 'onFail' => jsRaw('() => $("#docForm").addClass("has-changed")'))),
  169. set::morph(),
  170. on::change('#showTitle,zen-editor')->once()->do('$element.addClass("has-changed")'),
  171. panel
  172. (
  173. setClass('doc-form preserve-on-morph'),
  174. set::headingActions($headingActions),
  175. set::headingClass('py-3'),
  176. set::bodyClass('p-0 border-t'),
  177. to::heading
  178. (
  179. input
  180. (
  181. setID('showTitle'),
  182. setClass('ring-0 text-xl font-bold px-0'),
  183. setData('title-hint', sprintf($lang->error->notempty, $lang->doc->title)),
  184. set::maxlength(100),
  185. set::placeholder($lang->doc->titlePlaceholder),
  186. on::init()->do('$element.on("change input", () => {$("#title").val($element.val()).removeClass("has-error");$("#titleTip").remove();})')
  187. )
  188. ),
  189. $docType === 'doc' ? pageEditor
  190. (
  191. set::_id('docEditor'),
  192. set::name('content'),
  193. set::size('auto'),
  194. set::resizable(false),
  195. set::placeholder($lang->noticePasteImg)
  196. ) : editor
  197. (
  198. set::name('content'),
  199. set::size('full'),
  200. set::resizable(false),
  201. set::placeholder($lang->noticePasteImg)
  202. )
  203. ),
  204. formHidden('status', 'normal'),
  205. formHidden('contentType', $docType),
  206. formHidden('type', 'text'),
  207. $basicInfoModal
  208. );