From de9c7e44f4c27106a07b4294ced6a2e2c6c1a1bf Mon Sep 17 00:00:00 2001 From: guofeilong Date: Mon, 20 Feb 2023 15:15:52 +0800 Subject: [PATCH 1/2] * Code for js in module langitem . --- module/dev/js/langitem.js | 113 ++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 52 deletions(-) diff --git a/module/dev/js/langitem.js b/module/dev/js/langitem.js index 28d63e0312..8a237c5262 100644 --- a/module/dev/js/langitem.js +++ b/module/dev/js/langitem.js @@ -2,7 +2,7 @@ $(function() { $(".input-list").on("click", 'input', function(e) { - handleClickItem(e.target.id); + handleClickItem(e.target.id); }); $(".input-list").on("blur", 'input', function(e) { @@ -11,11 +11,15 @@ $(function() $('.label-list > .input-label').on('click', function(e) { - handleClickItem($(this).attr('labelid')); + handleClickItem($(this).attr('labelid')); }); initMenu(); + $('li.has-list > ul').addClass("menu-active-primary menu-hover-primary") + + handleInputSearch(); + function addActive(id) { $('[labelid=' + id + ']').addClass('text-primary'); @@ -42,61 +46,66 @@ $(function() }; } + function handleInputSearch() + { + $('.menu-tree .search-input').on('input', function() + { + var val = $(this).val(); + if (!val) + { + var updateData = menuTree; + } + else + { + var updateData = []; + for (var i = 0; i < menuTree.length; i++) + { + var item = {}; + $.extend(true, item, menuTree[i]) + if (item.children) + { + var children = []; + for (var j = 0; j < item.children.length; j++) + { + if (item.children[j].title.includes(val) || (item.children[j].key && item.children[j].key.includes(val))) + { + children.push(item.children[j]); + } + } + item.children = children; + } + if (item.children.length || item.title.includes(val) ||(item.key && item.key.includes(val))) + { + updateData.push(item); + } + } + } + $('#menuTree').data('zui.tree').reload(updateData); + }) + } + function initMenu() { - if (navTypes.includes(type)) - { - $('#menuTree').tree( + if (navTypes.includes(type)) { - data: menuTree, - itemCreator: function($li, item) + $('#menuTree').tree( { - $li.append('' + item.title + ''); - } - }); - } + data: menuTree, + initialState: 'active', + itemCreator: function($li, item) + { + $li.append('' + item.title + ''); + if (item.active) $li.addClass('active open in'); + } + }); + } - $('.menu-tree .search-input').on('input', function() - { - var val = $(this).val(); - if (!val) - { - var updateData = menuTree; - } - else - { - var updateData = []; - for (var i = 0; i < menuTree.length; i++) - { - var item = {}; - $.extend(true, item, menuTree[i]) - if (item.children) - { - var children = []; - for (var j = 0; j < item.children.length; j++) - { - if (item.children[j].title.includes(val) || (item.children[j].key && item.children[j].key.includes(val))) - { - children.push(item.children[j]); - } - } - item.children = children; - } - if (item.children.length || item.title.includes(val) ||(item.key && item.key.includes(val))) - { - updateData.push(item); - } - } - } - $('#menuTree').data('zui.tree').reload(updateData); - }) - - $('#menuTree').on('click', 'a', function(e) - { - var target = $(e.target); - if (target.attr('data-has-children') === 'true') return + $('#menuTree').on('click', 'a', function(e) + { + var target = $(e.target); + if (target.attr('data-has-children') === 'true') return - self.location.href = createLink('dev', 'langItem', 'type=' + type + '&module=' + target.attr('data-module') + '&method=' + target.attr('data-method')); - }) + self.location.href = createLink('dev', 'langItem', 'type=' + type + '&module=' + target.attr('data-module') + '&method=' + target.attr('data-method')); + }) } }) From 51855da58233167a951d4e2e89e1755bbf93318b Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Mon, 20 Feb 2023 15:44:08 +0800 Subject: [PATCH 2/2] * Modify menu tree data. --- module/dev/control.php | 15 ++++++--- module/dev/model.php | 54 ++++++++++--------------------- module/dev/view/langitem.html.php | 2 +- 3 files changed, 28 insertions(+), 43 deletions(-) diff --git a/module/dev/control.php b/module/dev/control.php index 6811636eed..716aaf4010 100644 --- a/module/dev/control.php +++ b/module/dev/control.php @@ -92,13 +92,21 @@ class dev extends control * @access public * @return void */ - public function langItem($type = 'common', $module = '', $method = '', $language = 'zh_cn') + public function langItem($type = 'common', $module = 'my', $method = '', $language = 'zh_cn') { $language = str_replace('_', '-', $language); $moduleName = $module; + if($type == 'common') $moduleName = 'common'; if($type == 'second') $moduleName = $module . 'Menu'; - if($type == 'third') $moduleName = $module . 'SubMenu'; + + if($type == 'third') + { + if(empty($method)) $method = 'work'; + $moduleName = $module . 'SubMenu'; + } + + if($type == 'feature' and empty($method)) $method = 'todo'; if($this->server->request_method == 'POST') { @@ -128,11 +136,8 @@ class dev extends control return $this->send(array('result' => 'success', 'locate' => 'reload', 'message' => $this->lang->saveSuccess)); } - $this->dev->loadDefaultLang(); - $this->view->title = $this->lang->langItem; $this->view->type = $type; - $this->view->featureBar = $this->lang->dev->featureBar['langItem']; $this->view->originalLangs = $this->dev->getOriginalLang($type, $module, $method, $language); $this->view->customedLangs = $this->dev->getCustomedLang($type, $module, $method, $language); $this->view->menuTree = $this->dev->getMenuTree($type, $module, $method); diff --git a/module/dev/model.php b/module/dev/model.php index 22b8611187..e3f99139f8 100644 --- a/module/dev/model.php +++ b/module/dev/model.php @@ -304,23 +304,6 @@ class devModel extends model */ public function getOriginalLang($type, $module = '', $method = '', $language = 'zh-cn') { - // Defalut value set, remove when left tree display. - if($type == 'feature') - { - $module = 'product'; - $method = 'browse'; - } - elseif($type == 'second') - { - $module = 'scrum'; - } - elseif($type == 'third') - { - $module = 'kanbanProject'; - $method = 'settings'; - } - // Defalut value set end. - $originalLangs = array(); $clientLang = $this->app->getClientLang(); $defaultLang = $this->loadDefaultLang(); @@ -398,7 +381,7 @@ class devModel extends model elseif($type == 'third') { $langKey = "{$method}_"; - $lang = $defaultLang->$module->menu->$method['subMenu']; + $lang = $defaultLang->$module->menu->{$method}['subMenu']; } $menus = $this->getLinkTitle($lang); @@ -427,23 +410,6 @@ class devModel extends model $customedLangs = array(); $clientLang = $this->app->getClientLang(); - // Defalut value set, remove when left tree display. - if($type == 'feature') - { - $module = 'product'; - $method = 'browse'; - } - elseif($type == 'second') - { - $module = 'scrum'; - } - elseif($type == 'third') - { - $module = 'kanbanProject'; - $method = 'settings'; - } - // Defalut value set end. - $langKey = ''; $customeds = array(); if($type == 'common') @@ -593,7 +559,7 @@ class devModel extends model $menusPinYin = common::convert2Pinyin($menuLang); foreach($menuLang as $menuKey => $menuName) { - if(!isset($this->lang->$menu->menu->$menuKey['subMenu'])) continue; + if(!isset($this->lang->$menu->menu->{$menuKey}['subMenu']) or !get_object_vars($this->lang->$menu->menu->{$menuKey}['subMenu'])) continue; $subMenu = new stdClass(); $subMenu->title = $menuName; @@ -656,7 +622,21 @@ class devModel extends model $menuTree = array(); if(!in_array($type, $this->config->dev->navTypes)) return $menuTree; - $mainNav = $this->getLinkTitle($this->lang->mainNav); + $mainNav = $type == 'second' ? $this->lang->mainNav : array(); + if($type != 'second') + { + foreach($this->lang->mainNav as $menuKey => $menu) + { + if($menuKey == 'project') + { + foreach($this->config->dev->projectMenus as $subMenuKey) $mainNav[$subMenuKey] = $this->lang->dev->projectMenu[$subMenuKey]; + } + + $mainNav[$menuKey] = $menu; + } + } + + $mainNav = $this->getLinkTitle($mainNav); $maimNavPinYin = common::convert2Pinyin($mainNav); if(empty($module)) $module = 'my'; diff --git a/module/dev/view/langitem.html.php b/module/dev/view/langitem.html.php index f1de76bee7..2f7e9b0df3 100644 --- a/module/dev/view/langitem.html.php +++ b/module/dev/view/langitem.html.php @@ -16,7 +16,7 @@