edit.text.html.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. /**
  3. * The edit 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($doc->status == 'draft') $headingActions['items'][] = array('type' => 'secondary', 'class' => 'save-draft', 'text' => $lang->doc->saveDraft, 'btnType' => 'submit');
  15. $headingActions['items'][] = array('type' => 'primary', 'class' => 'btn-wide', 'text' => $lang->doc->release, 'btnType' => 'submit');
  16. $headingActions['items'][] = array('type' => 'ghost', 'icon' => 'cog-outline', 'text' => $lang->settings, 'url' => '#modalBasicInfo', 'data-toggle' => 'modal');
  17. if($type == 'custom') unset($spaces['mine']);
  18. $basicInfoModal = modal
  19. (
  20. set::id('modalBasicInfo'),
  21. set::bodyClass('form form-horz'),
  22. set::title($lang->doc->release . $lang->doc->common),
  23. on::change('[name="space"],[name="product"],[name="project"],[name="execution"]')->call('loadObjectModules', jsRaw('event')),
  24. on::change('[name="lib"]')->call('loadLibModules', jsRaw('event')),
  25. on::change('[name=lib]', 'checkLibPriv'),
  26. on::change('[name^=users]', 'checkLibPriv'),
  27. $type == 'execution' ? formHidden('project', $doc->project) : null,
  28. (strpos('product|project|execution', $type) !== false) ? formGroup
  29. (
  30. set::width('1/2'),
  31. set::label($lang->doc->{$type}),
  32. set::required(true),
  33. set::control(array('control' => 'picker', 'name' => $type, 'items' => $objects, 'required' => true, 'value' => $objectID))
  34. ) : null,
  35. ($type == 'mine' || $type == 'custom') ? formGroup
  36. (
  37. set::width('1/2'),
  38. set::label($lang->doc->space),
  39. set::required(true),
  40. set::control(array('control' => 'picker', 'name' => 'space', 'items' => $spaces, 'required' => true, 'value' => $type == 'mine' ? 'mine' : $lib->parent, 'disabled' => $type == 'mine'))
  41. ) : null,
  42. formGroup
  43. (
  44. setData('libType', $type),
  45. set::width('1/2'),
  46. set::label($lang->doc->lib),
  47. set::required(true),
  48. set::control(array('control' => 'picker', 'name' => 'lib', 'items' => $libs, 'required' => true, 'value' => $doc->lib))
  49. ),
  50. formGroup
  51. (
  52. set::width('1/2'),
  53. set::label($lang->doc->module),
  54. set::control(array('control' => 'picker', 'name' => 'module', 'items' => $optionMenu, 'required' => true, 'value' => $doc->module))
  55. ),
  56. formGroup
  57. (
  58. (strpos($config->doc->officeTypes, $doc->type) === false && $doc->type != 'text') ? setClass('hidden') : null,
  59. set::label($lang->doc->keywords),
  60. set::control('input'),
  61. set::name('keywords'),
  62. set::value($doc->keywords)
  63. ),
  64. formGroup
  65. (
  66. setStyle('min-height', 'auto'),
  67. set::label($lang->doc->files),
  68. fileSelector()
  69. ),
  70. formGroup
  71. (
  72. set::label($lang->doc->mailto),
  73. mailto(set::items($users), set::value($doc->mailto))
  74. ),
  75. formGroup
  76. (
  77. set::label($lang->doclib->control),
  78. radioList
  79. (
  80. set::name('acl'),
  81. set::items($lang->doc->aclList),
  82. set::value(isset($lang->doc->aclList[$doc->acl]) ? $doc->acl : key($lang->doc->aclList)),
  83. on::change('toggleWhiteList')
  84. )
  85. ),
  86. $lib->type != 'mine' ? formGroup
  87. (
  88. $doc->acl == 'open' ? setClass('hidden') : null,
  89. set::label($lang->doc->whiteList),
  90. set::id('whiteListBox'),
  91. div
  92. (
  93. setClass('w-full check-list'),
  94. inputGroup
  95. (
  96. setClass('w-full'),
  97. $lang->doc->groupLabel,
  98. picker
  99. (
  100. set::name('groups[]'),
  101. set::items($groups),
  102. set::multiple(true),
  103. set::value($doc->groups)
  104. )
  105. ),
  106. div
  107. (
  108. setClass('w-full'),
  109. userPicker(set::label($lang->doc->userLabel), set::items($users), set::value($doc->users))
  110. )
  111. )
  112. ) : null,
  113. formRow
  114. (
  115. div
  116. (
  117. setClass('form-actions form-group no-label'),
  118. btn
  119. (
  120. set::type('primary'),
  121. set::btnType('button'),
  122. setData('dismiss', 'modal'),
  123. $lang->save
  124. )
  125. )
  126. )
  127. );
  128. $handleSubmitForm = <<<'JS'
  129. function(e)
  130. {
  131. const isDraft = $(e.submitter).hasClass('save-draft');
  132. const $title = $('#title');
  133. if(isDraft && !$title.val().length)
  134. {
  135. zui.Modal.alert($title.data('titleHint')).then(() => $title[0].focus());
  136. return false;
  137. }
  138. $(e.target).removeClass('has-changed').find('input[name=status]').val(isDraft ? 'draft' : 'normal');
  139. const pageEditor = $('#docEditor').zui('pageEditor');
  140. if (pageEditor) {
  141. return pageEditor.syncData().then(() => true);
  142. }
  143. }
  144. JS;
  145. formBase
  146. (
  147. setID('docForm'),
  148. set::actions(false),
  149. set::morph(),
  150. set::ajax(array('beforeSubmit' => jsRaw($handleSubmitForm), 'onFail' => jsRaw('() => $("#docForm").addClass("has-changed")'))),
  151. setData('unsavedConfirm', $lang->doc->confirmLeaveOnEdit),
  152. on::change('#showTitle,zen-editor')->once()->do('$element.addClass("has-changed")'),
  153. panel
  154. (
  155. setClass('doc-form preserve-on-morph'),
  156. to::heading
  157. (
  158. input
  159. (
  160. setClass('ring-0 text-xl font-bold px-0'),
  161. set::name('title'),
  162. set::value($doc->title),
  163. set::maxlength(100),
  164. set::placeholder($lang->doc->titlePlaceholder),
  165. setData('title-hint', sprintf($lang->error->notempty, $lang->doc->title))
  166. )
  167. ),
  168. set::headingActions($headingActions),
  169. set::headingClass('py-3'),
  170. set::bodyClass('p-0 border-t'),
  171. $doc->contentType === 'doc' ? pageEditor
  172. (
  173. set::_id('docEditor'),
  174. set::name('content'),
  175. set::size('auto'),
  176. set::resizable(false),
  177. set::placeholder($lang->noticePasteImg),
  178. set::value($doc->content)
  179. ) : editor
  180. (
  181. set::name('content'),
  182. set::size('full'),
  183. set::resizable(false),
  184. set::markdown($doc->contentType == 'markdown'),
  185. html($doc->content)
  186. )
  187. ),
  188. formHidden('status', $doc->status),
  189. formHidden('contentType', $doc->contentType),
  190. formHidden('type', 'text'),
  191. $basicInfoModal
  192. );