From 5a64c96a2b219cef17fa60c72875121892e380ae Mon Sep 17 00:00:00 2001 From: tianshujie Date: Sat, 11 Mar 2023 18:08:40 +0800 Subject: [PATCH] * Modify the module tree on the left side of the editor. --- module/dev/js/api.js | 4 ++-- module/dev/js/db.js | 4 ++-- module/dev/model.php | 14 ++++++++------ module/editor/js/index.js | 5 +++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/module/dev/js/api.js b/module/dev/js/api.js index e446b599da..16f1439eb8 100644 --- a/module/dev/js/api.js +++ b/module/dev/js/api.js @@ -1,6 +1,6 @@ $(function() { - initModule(); + initModuleTree(); setHeight(); $(window).resize(setHeight); }); @@ -23,7 +23,7 @@ function setHeight() * @access public * @return void */ -function initModule() +function initModuleTree() { $('#moduleTree').tree( { diff --git a/module/dev/js/db.js b/module/dev/js/db.js index c7f6d7f9cf..dbf1b65a14 100644 --- a/module/dev/js/db.js +++ b/module/dev/js/db.js @@ -1,6 +1,6 @@ $(function() { - initTable(); + initTableTree(); setHeight(); $(window).resize(setHeight); }); @@ -23,7 +23,7 @@ function setHeight() * @access public * @return void */ -function initTable() +function initTableTree() { $('#tableTree').tree( { diff --git a/module/dev/model.php b/module/dev/model.php index 8648582fcc..e2706de62f 100644 --- a/module/dev/model.php +++ b/module/dev/model.php @@ -1074,14 +1074,14 @@ class devModel extends model } /** - * Get module tree. + * Get tree by type. * - * @param string $currentModule + * @param string $currentObject * @param string $type module|table * @access public * @return array */ - public function getTree($currentModule, $type) + public function getTree($currentObject, $type) { $tree = array(); if(!in_array($type, array('module', 'table'))) return $tree; @@ -1091,6 +1091,7 @@ class devModel extends model foreach($groupList as $moduleKey => $moduleName) { if(empty($objects[$moduleKey])) continue; + $module = new stdclass(); $module->key = $moduleKey; $module->title = $moduleName; @@ -1098,10 +1099,11 @@ class devModel extends model $module->children = array(); foreach($objects[$moduleKey] as $objectKey => $objectName) { - $object = new stdclass(); + $defaultValue = $type == 'module' ? $objectName : ''; + $object = new stdclass(); $object->key = $objectName; - $object->title = zget($this->lang->dev->tableList, $objectKey, $objectKey); - $object->active = $objectName == $currentModule ? 1 : 0; + $object->title = zget($this->lang->dev->tableList, $objectKey, $defaultValue); + $object->active = $objectName == $currentObject ? 1 : 0; if($object->active) $module->active = 1; $module->children[] = $object; diff --git a/module/editor/js/index.js b/module/editor/js/index.js index bad09cc0ba..161b430f51 100644 --- a/module/editor/js/index.js +++ b/module/editor/js/index.js @@ -1,6 +1,6 @@ $(function() { - initModule(); + initModuleTree(); setHeight(); $(window).resize(setHeight); }); @@ -24,7 +24,7 @@ function setHeight() * @access public * @return void */ -function initModule() +function initModuleTree() { $('#moduleTree').tree( { @@ -45,5 +45,6 @@ function initModule() $(this).closest('.side-col').find('li.active').removeClass('active'); $(this).parent().addClass('active'); + $(this).parent().parent().parent().addClass('active'); }) }