* [task#140360,doing,1.5h] Set parent when create doc template.

This commit is contained in:
xieqiyu
2025-04-02 15:44:38 +08:00
committed by 刘刚
parent 7c9dffc622
commit 4e5ad4cd1f
3 changed files with 12 additions and 7 deletions
+3 -2
View File
@@ -2298,9 +2298,10 @@ class doc extends control
}
if($modalType == 'chapter') $title = $isCreate ? $this->lang->doc->addChapter : $this->lang->doc->editChapter;
$chapterAndDocs = $this->doc->getDocsOfLibs(array($libID), $objectType, $docID);
$modulePairs = empty($libID) || $modalType == 'chapter' ? array() : $this->loadModel('tree')->getOptionMenu($libID, 'doc', 0);
$chapterAndDocs = $this->doc->getDocsOfLibs(array($libID), $objectType, $docID, $objectType == 'template' ? true : false);
if($objectType == 'template' && !empty($moduleID)) $chapterAndDocs = array_filter($chapterAndDocs, fn($docInfo) => $docInfo->module == $moduleID);
if(isset($doc) && !empty($doc->parent) && !isset($chapterAndDocs[$doc->parent])) $chapterAndDocs[$doc->parent] = $this->doc->fetchByID($doc->parent);
$modulePairs = empty($libID) || $modalType == 'chapter' || $objectType == 'template' ? array() : $this->loadModel('tree')->getOptionMenu($libID, 'doc', 0);
$chapterAndDocs = $this->doc->buildNestedDocs($chapterAndDocs, $modulePairs);
$this->view->chapterAndDocs = $chapterAndDocs;
+8 -4
View File
@@ -757,18 +757,21 @@ class docModel extends model
* @param array $libs
* @param string $spaceType
* @param int $excludeID
* @param bool $queryTemplate
* @access public
* @return array
*/
public function getDocsOfLibs(array $libs, string $spaceType, int $excludeID = 0): array
public function getDocsOfLibs(array $libs, string $spaceType, int $excludeID = 0, $queryTemplate = false): array
{
$docs = $this->dao->select('t1.*')->from(TABLE_DOC)->alias('t1')
->leftJoin(TABLE_MODULE)->alias('t2')->on('t1.module=t2.id')
->where('t1.lib')->in($libs)
->andWhere('t1.vision')->eq($this->config->vision)
->andWhere('t1.templateType')->eq('')
->beginIF(!$queryTemplate)->andWhere('t1.templateType')->eq('')->fi()
->beginIF($queryTemplate)->andWhere('t1.templateType')->ne('')->fi()
->beginIF(!$queryTemplate)->andWhere('t2.type')->eq('doc')->fi()
->beginIF($queryTemplate)->andWhere('t2.type')->eq('docTemplate')->fi()
->andWhere("(t1.status = 'normal' or (t1.status = 'draft' and t1.addedBy='{$this->app->user->account}'))")
->andWhere('t2.type')->eq('doc')
->andWhere('t2.deleted')->eq('0')
->beginIF(!empty($excludeID))->andWhere("NOT FIND_IN_SET('{$excludeID}', t1.`path`)")->andWhere('t1.id')->ne($excludeID)->fi()
->orderBy('t1.`order` asc, t1.id asc')
@@ -777,7 +780,8 @@ class docModel extends model
$rootDocs = $this->dao->select('*')->from(TABLE_DOC)
->where('lib')->in($libs)
->andWhere('vision')->eq($this->config->vision)
->andWhere('templateType')->eq('')
->beginIF(!$queryTemplate)->andWhere('templateType')->eq('')->fi()
->beginIF($queryTemplate)->andWhere('templateType')->ne('')->fi()
->andWhere("(status = 'normal' or (status = 'draft' and addedBy='{$this->app->user->account}'))")
->andWhere('module')->in(array('0', ''))
->beginIF(!empty($excludeID))->andWhere("NOT FIND_IN_SET('{$excludeID}', `path`)")->andWhere('id')->ne($excludeID)->fi()
+1 -1
View File
@@ -52,7 +52,7 @@ formPanel
picker
(
set::name('parent'),
set::items($modalType != 'chapter' ? array('m_0' => '/') + $chapterAndDocs : $chapterAndDocs),
set::items($modalType != 'chapter' ? array(0 => '/') + $chapterAndDocs : $chapterAndDocs),
set::value($parentID ? $parentID : "m_$moduleID"),
set::required(true)
),