From 0cd791fd4f04e7790dcfd56db046201995edaa4f Mon Sep 17 00:00:00 2001 From: tianshujie Date: Fri, 10 Mar 2023 17:16:34 +0800 Subject: [PATCH] * Modify the module tree on the left side of the editor. --- module/dev/model.php | 3 ++- module/editor/control.php | 2 +- module/editor/css/index.css | 6 ++++++ module/editor/js/index.js | 36 ++++++++++++++++++++++++++----- module/editor/view/index.html.php | 31 ++------------------------ 5 files changed, 42 insertions(+), 36 deletions(-) diff --git a/module/dev/model.php b/module/dev/model.php index fe9e6125e2..8b982029a3 100644 --- a/module/dev/model.php +++ b/module/dev/model.php @@ -1087,7 +1087,8 @@ class devModel extends model if(!in_array($type, array('module', 'table'))) return $tree; $objects = $type == 'module' ? $this->getModules() : $this->getTables(); - foreach($this->lang->dev->groupList as $moduleKey => $moduleName) + $groupList = array_merge($this->lang->dev->groupList, $this->lang->dev->endGroupList); + foreach($groupList as $moduleKey => $moduleName) { if(empty($objects[$moduleKey])) continue; $module = new stdclass(); diff --git a/module/editor/control.php b/module/editor/control.php index 13d392ddd0..a03432e552 100644 --- a/module/editor/control.php +++ b/module/editor/control.php @@ -36,8 +36,8 @@ class editor extends control $this->app->loadLang('dev'); $this->view->title = $this->lang->editor->common; $this->view->position[] = $this->lang->editor->common; - $this->view->modules = $this->loadModel('dev')->getModules(); $this->view->tab = $type; + $this->view->moduleTree = $this->loadModel('dev')->getTree($type, 'module'); $this->display(); } diff --git a/module/editor/css/index.css b/module/editor/css/index.css index 6b2b49c929..8de33476ee 100644 --- a/module/editor/css/index.css +++ b/module/editor/css/index.css @@ -9,3 +9,9 @@ td.w-200px a:hover {font-weight:bold;} #mainContent .module-content {padding: 0;} #sidebar .module-tree {overflow-y: auto;} #sidebar .module-tree .panel-heading {padding: 4px 10px;} + +/* module-tree. */ +#moduleTree.tree ul {margin-bottom: 0;} +#moduleTree .active {background-color: #fff;} +#menuTree > li.has-list > ul > li {padding-left: 10px;} +#menuTree > li.has-list > ul > li.has-list {padding-left: 15px;} diff --git a/module/editor/js/index.js b/module/editor/js/index.js index 72b76cc59e..bad09cc0ba 100644 --- a/module/editor/js/index.js +++ b/module/editor/js/index.js @@ -1,10 +1,6 @@ $(function() { - $('.side-col a').click(function() - { - $(this).closest('.side-col').find('a.text-primary').removeClass('text-primary'); - $(this).addClass('text-primary'); - }); + initModule(); setHeight(); $(window).resize(setHeight); }); @@ -21,3 +17,33 @@ function setHeight() $('#sidebar .module-tree,#mainContent .module-col,#extendWin').css('height', paneHeight); $(' #mainContent .module-content, #editWin').css('height', paneHeight - 6); } + +/** + * Init module tree by zui. + * + * @access public + * @return void + */ +function initModule() +{ + $('#moduleTree').tree( + { + data: moduleTree, + initialState: 'active', + itemCreator: function($li, item) + { + $li.append('' + item.title + ''); + if (item.active) $li.addClass('active open in'); + } + }); + + $('#moduleTree').on('click', 'a', function(e) + { + var target = $(e.target); + if (target.attr('data-has-children') === 'true') return; + $('#extendWin').attr('src', createLink('editor', 'extend', 'moduleDir=' + target.attr('data-module'))); + + $(this).closest('.side-col').find('li.active').removeClass('active'); + $(this).parent().addClass('active'); + }) +} diff --git a/module/editor/view/index.html.php b/module/editor/view/index.html.php index 5e458b21f5..b1a364d273 100644 --- a/module/editor/view/index.html.php +++ b/module/editor/view/index.html.php @@ -11,6 +11,7 @@ */ ?> getModuleRoot() . 'dev/view/header.html.php';?> +