* Refactor drop menu of the admin.

This commit is contained in:
tianshujie
2023-07-11 14:44:52 +08:00
parent 88fa25b206
commit 6dedbe2fc5
5 changed files with 66 additions and 2 deletions
+1 -1
View File
@@ -486,5 +486,5 @@ $config->featureGroup->other = array('devops', 'kanban');
$config->bi = new stdclass();
$config->bi->pickerHeight = 150;
$config->hasDropmenuApps = array('program', 'project', 'product', 'execution', 'qa');
$config->hasDropmenuApps = array('program', 'project', 'product', 'execution', 'qa', 'admin');
$config->excludeDropmenuList = array('program-browse', 'product-all', 'product-index', 'execution-all', 'project-browse', 'product-batchedit');
+8
View File
@@ -51,6 +51,7 @@ class dropmenu extends wg
list($url, $text, $objectID, $cache, $tab, $module, $method, $extra, $id, $data) = $this->prop(array('url', 'text', 'objectID', 'cache', 'tab', 'module', 'method', 'extra', 'id', 'data'));
$app = data('app');
$lang = data('lang');
if(empty($tab)) $tab = $app->tab;
if(empty($module)) $module = $app->rawModule;
@@ -63,6 +64,13 @@ class dropmenu extends wg
if(isset($object->id)) $objectID = $object->id;
}
if($tab == 'admin')
{
$currentMenuKey = $app->control->loadModel('admin')->getMenuKey();
$text = $lang->admin->menuList->{$currentMenuKey}['name'];
$url = createLink('admin', 'ajaxGetDropMenu', "currentMenuKey={$currentMenuKey}");
}
if(empty($url) && empty($data)) $url = createLink($tab, 'ajaxGetDropMenu', "objectID=$objectID&module=$module&method=$method&extra=$extra");
if(empty($text) && !empty($tab))
{
+31
View File
@@ -515,4 +515,35 @@ class admin extends control
return print(json_encode($response));
}
/**
* AJAX: Get drop menu.
*
* @param string $currentMenuKey
* @access public
* @return void
*/
public function ajaxGetDropMenu($currentMenuKey = '')
{
$this->admin->checkPrivMenu();
$data = array();
foreach($this->lang->admin->menuList as $menuKey => $menuGroup)
{
if($this->config->vision == 'lite' and !in_array($menuKey, $this->config->admin->liteMenuList)) continue;
$data[] = array(
'id' => $menuKey,
'name' => $menuKey,
'text' => $menuGroup['name'],
'content' => "<img src='{$this->config->webRoot}static/svg/admin-{$menuKey}.svg'/> " . $menuGroup['name'],
'title' => $menuGroup['name'],
'type' => 'item',
'url' => $menuGroup['disabled'] ? '###' : $menuGroup['link'],
'active' => $currentMenuKey == $menuKey,
'rootClass' => 'admin-menu-item'
);
}
$this->view->data = $data;
$this->display();
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
/**
* The ajaxGetDropMenu view file of admin module of ZenTaoPMS.
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author Shujie Tian<tianshujie@easycorp.ltd>
* @package admin
* @link https://www.zentao.net
*/
namespace zin;
/**
* 定义最终的 JSON 数据。
* Define the final json data.
*/
$json = array();
$json['data'] = $data;
$json['search'] = false;
/**
* 渲染 JSON 字符串并发送到客户端。
* Render json data to string and send to client.
*/
renderJson($json);
+1 -1
View File
@@ -590,7 +590,7 @@ class custom extends control
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $locate));
}
$this->view->title = $this->lang->custom->flow;
$this->view->title = $this->lang->custom->flow;
$this->display();
}