From c16c654268154fed3ac2e04053e9405f01fcdeea Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Thu, 26 Oct 2023 12:16:10 +0800 Subject: [PATCH] * Add dimension dropmenu for bi. --- config/zentaopms.php | 4 +- lib/zin/wg/heading/v1.php | 1 + module/dimension/control.php | 10 ++-- module/dimension/ui/ajaxgetdropmenu.html.php | 38 +++++++++++++ module/dimension/zen.php | 57 ++++++++++++++++++++ module/screen/control.php | 6 +-- 6 files changed, 106 insertions(+), 10 deletions(-) create mode 100644 module/dimension/ui/ajaxgetdropmenu.html.php create mode 100644 module/dimension/zen.php diff --git a/config/zentaopms.php b/config/zentaopms.php index 39d514d0ae..11f89d692c 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -659,9 +659,9 @@ $config->bi = new stdclass(); $config->bi->pickerHeight = 150; $config->db->sqliteBlacklist = array('sqlite_queue', 'cron'); -$config->hasDropmenuApps = array('program', 'project', 'product', 'execution', 'qa', 'admin'); +$config->hasDropmenuApps = array('program', 'project', 'product', 'execution', 'qa', 'admin', 'bi'); $config->hasBranchMenuModules = array('product', 'story', 'release', 'bug', 'testcase', 'testtask'); -$config->excludeDropmenuList = array('program-browse', 'program-productview', 'product-all', 'product-index', 'execution-all', 'project-browse', 'project-batchedit', 'product-batchedit', 'admin-index', 'product-create', 'project-create', 'execution-create', 'program-create', 'execution-batchedit'); +$config->excludeDropmenuList = array('program-browse', 'program-productview', 'product-all', 'product-index', 'execution-all', 'project-browse', 'project-batchedit', 'product-batchedit', 'admin-index', 'product-create', 'project-create', 'execution-create', 'program-create', 'execution-batchedit', 'metric-preview'); $config->hasSwitcherModules = array('design'); $config->hasSwitcherMethods = array('project-bug', 'project-testcase', 'execution-bug', 'execution-testcase'); $config->excludeSwitcherList = array(); diff --git a/lib/zin/wg/heading/v1.php b/lib/zin/wg/heading/v1.php index eca5067f26..75212f5454 100644 --- a/lib/zin/wg/heading/v1.php +++ b/lib/zin/wg/heading/v1.php @@ -67,6 +67,7 @@ class heading extends wg if(in_array($app->tab, is_array($config->hasDropmenuApps) ? $config->hasDropmenuApps : array())) { $module = $app->tab == 'qa' ? 'product' : $app->tab; + $module = $app->tab == 'bi' ? 'dimension' : $app->tab; if($app->tab == 'qa' && $moduleName == 'caselib') $module = 'caselib'; return new dropmenu(set::tab($module)); } diff --git a/module/dimension/control.php b/module/dimension/control.php index 55e8fc601c..7ffc849e5d 100644 --- a/module/dimension/control.php +++ b/module/dimension/control.php @@ -21,13 +21,13 @@ class dimension extends control * @param string type screen|pivot|chart * @return void */ - public function ajaxGetDropMenu($currentModule, $currentMethod, $dimensionID, $type = '') + public function ajaxGetDropMenu(int $dimensionID, string $module, string $method) { - $this->view->currentModule = $currentModule; - $this->view->currentMethod = $currentMethod; $this->view->dimensionID = $dimensionID; - $this->view->type = $type; - $this->view->dimensions = $this->dimension->getList(); + + $dimensions = $this->dimension->getList(); + $this->view->dimensionTree = $this->dimensionZen->buildTree($dimensions); + $this->view->link = $this->dimensionZen->getLink($module, $method, '{id}', '', 'dimension'); $this->display(); } } diff --git a/module/dimension/ui/ajaxgetdropmenu.html.php b/module/dimension/ui/ajaxgetdropmenu.html.php new file mode 100644 index 0000000000..cb6e1d9ab7 --- /dev/null +++ b/module/dimension/ui/ajaxgetdropmenu.html.php @@ -0,0 +1,38 @@ + + * @package project + * @version $Id + * @link https://www.zentao.net + */ +namespace zin; + +$topItem = array(); +$topItem['id'] = 0; +$topItem['type'] = 'dimension'; +$topItem['text'] = $lang->dimension->common; +$topItem['url'] = false; +$topItem['label'] = false; +$topItem['items'] = $dimensionTree; + +/** + * 定义最终的 JSON 数据。 + * Define the final json data. + */ +$json = array(); +$json['data'] = array($topItem); +$json['searchHint'] = $lang->searchAB; +$json['link'] = array('dimension' => $link); +$json['labelMap'] = array('dimension' => $lang->dimension->common); +$json['expandName'] = 'closed'; +$json['itemType'] = 'dimension'; + +/** + * 渲染 JSON 字符串并发送到客户端。 + * Render json data to string and send to client. + */ +renderJson($json); diff --git a/module/dimension/zen.php b/module/dimension/zen.php new file mode 100644 index 0000000000..8a1e78f870 --- /dev/null +++ b/module/dimension/zen.php @@ -0,0 +1,57 @@ + + * @package dimension + * @link http://www.zentao.net + */ +class dimensionZen extends dimension +{ + /** + * 构造1.5级导航的数据。 + * Build the data of 1.5 level navigation. + * + * @param array $dimensions + * @param int $parentID + * @access protected + * @return void + */ + protected function buildTree(array $dimensions): array + { + $result = array(); + foreach($dimensions as $dimension) + { + $itemArray = array + ( + 'id' => $dimension->id, + 'text' => $dimension->name, + 'keys' => zget(common::convert2Pinyin(array($dimension->name)), $dimension->name, ''), + ); + + $result[] = $itemArray; + } + return $result; + } + + /** + * 获取下拉树菜单的链接。 + * Get link for drop tree menu. + * + * @param string $moduleName + * @param string $methodName + * @param int $programID + * @param string $vars + * @param string $from + * @access protected + * @return string + */ + protected function getLink(string $moduleName, string $methodName, string $dimensionID, string $vars = '', string $from = 'dimension'): string + { + return helper::createLink($moduleName, $methodName, "dimensionID={$dimensionID}"); + } +} + diff --git a/module/screen/control.php b/module/screen/control.php index 987791915d..b5a8c6bdc5 100644 --- a/module/screen/control.php +++ b/module/screen/control.php @@ -23,9 +23,9 @@ class screen extends control $dimensionID = $this->loadModel('dimension')->setSwitcherMenu($dimensionID); $this->checkShowGuide(); - $this->view->title = $this->lang->screen->common; - $this->view->screens = $this->screen->getList($dimensionID); - $this->view->dimension = $dimensionID; + $this->view->title = $this->lang->screen->common; + $this->view->screens = $this->screen->getList($dimensionID); + $this->view->dimensionID = $dimensionID; $this->display(); }