From 270151c8550f2dd02e59ca9972b1c8204cc436a3 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Fri, 21 Feb 2025 09:49:39 +0800 Subject: [PATCH] * [task#137615,doing,1h] Alert tip when has no type when create doc template. --- module/doc/control.php | 15 ++++++--------- module/doc/js/browsetemplate.ui.js | 5 +++-- module/doc/ui/templatelist.html.php | 3 ++- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/module/doc/control.php b/module/doc/control.php index 8310212166..19dac32790 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -497,20 +497,16 @@ class doc extends control */ public function browseTemplate(int $libID = 0, string $type = 'all', int $docID = 0, string $orderBy = 'id_desc', int $recTotal = 0, int $recPerPage = 20, int $pageID = 1, string $mode = 'home') { - $this->app->loadClass('pager', true); - $pager = new pager($recTotal, $recPerPage, $pageID); - $this->lang->doc->menu->template['alias'] .= ',' . $this->app->rawMethod; - $modules = $this->doc->getTemplateModules(); + $modules = $this->doc->getTemplateModules($libID); $modules = array_column($modules, 'fullName', 'id'); if($mode == 'create' && empty($modules)) return $this->send(array('result' => 'success', 'load' => array('alert' => $this->lang->docTemplate->createTypeFirst))); - $templateList = $this->doc->getDocTemplateList(0, $type, $orderBy, $pager); + $this->app->loadClass('pager', true); + $pager = new pager($recTotal, $recPerPage, $pageID); + $templateList = $this->doc->getDocTemplateList($libID, $type, $orderBy, $pager); $templateList = $this->doc->filterPrivDocs($templateList, 'template'); - foreach($templateList as $template) - { - $template->moduleName = zget($modules, $template->module); - } + foreach($templateList as $template) $template->moduleName = zget($modules, $template->module); $this->view->title = $this->lang->doc->template; $this->view->libID = $libID; @@ -521,6 +517,7 @@ class doc extends control $this->view->recPerPage = $recPerPage; $this->view->pageID = $pageID; $this->view->mode = $mode; + $this->view->hasModules = count($modules) ? true : false; $this->display(); } diff --git a/module/doc/js/browsetemplate.ui.js b/module/doc/js/browsetemplate.ui.js index 7093e2a883..bbed606746 100644 --- a/module/doc/js/browsetemplate.ui.js +++ b/module/doc/js/browsetemplate.ui.js @@ -386,8 +386,9 @@ $.extend(window.docAppCommands, { startCreateTemplate: function() { - const docApp = getDocApp(); - if(!docApp.treeMap.modules.size) return zui.Modal.alert(getLang('createTypeFirst')); + const docApp = getDocApp(); + const hasModules = docApp.props.hasModules; + if(!hasModules) return zui.Modal.alert(getLang('createTypeFirst')); docApp.startCreateDoc(); }, deleteDoc: function(_, args) diff --git a/module/doc/ui/templatelist.html.php b/module/doc/ui/templatelist.html.php index a3b6148ee3..710dfc64f2 100644 --- a/module/doc/ui/templatelist.html.php +++ b/module/doc/ui/templatelist.html.php @@ -99,7 +99,8 @@ docApp set::viewModeUrl($viewModeUrl), set::pager(array('recTotal' => count($templateList), 'recPerPage' => $recPerPage, 'page' => $pageID)), set('$options', jsRaw('window.setDocAppOptions')), - set::showDocOutline(false) + set::showDocOutline(false), + set::hasModules($hasModules) ); render();