Merge Code.
This commit is contained in:
@@ -71,7 +71,7 @@ function generateAddNavbarItems(onClick)
|
||||
onClick('divider');
|
||||
const items = getCurrentNavbarItems();
|
||||
const app = $.apps.getLastApp().code;
|
||||
const menu = getMenuName(items, app);
|
||||
const menu = getMenuName(app);
|
||||
$.ajaxSubmit({url: customUrl, data: {menu: menu, items: JSON.stringify(items)}});
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ function generateAddNavbarItems(onClick)
|
||||
onClick(name);
|
||||
const items = getCurrentNavbarItems();
|
||||
const app = $.apps.getLastApp().code;
|
||||
const menu = getMenuName(items, app);
|
||||
const menu = getMenuName(app);
|
||||
$.ajaxSubmit({url: customUrl, data: {menu: menu, items: JSON.stringify(items)}});
|
||||
}
|
||||
}
|
||||
@@ -126,14 +126,11 @@ function canHideCurrentNavbar($item)
|
||||
/**
|
||||
* Get menu name by items and app.
|
||||
*
|
||||
* @param {Array<{name: string; order: number;}>} items
|
||||
* @param {string} app
|
||||
* @returns {string}
|
||||
*/
|
||||
function getMenuName(items, app)
|
||||
function getMenuName(app)
|
||||
{
|
||||
const isHomeMenu = items.length <= 3 && ['program', 'project', 'product', 'execution'].includes(app);
|
||||
|
||||
if(typeof projectModel !== 'undefined')
|
||||
{
|
||||
return `project-${projectModel}`;
|
||||
@@ -142,6 +139,10 @@ function getMenuName(items, app)
|
||||
{
|
||||
return `${app}-home`;
|
||||
}
|
||||
else if(app == 'admin')
|
||||
{
|
||||
return `admin-${adminMenuKey}`;
|
||||
}
|
||||
else
|
||||
{
|
||||
return app;
|
||||
@@ -167,7 +168,7 @@ $(document).on(
|
||||
onClick: () => {
|
||||
$item.closest('.nav').zui().destroy();
|
||||
const items = getCurrentNavbarItems();
|
||||
const menu = getMenuName(items, app);
|
||||
const menu = getMenuName(app);
|
||||
$.ajaxSubmit({url: customUrl, data: {menu: menu, items: JSON.stringify(items)}});
|
||||
}
|
||||
}
|
||||
@@ -191,7 +192,7 @@ $(document).on(
|
||||
: () => {
|
||||
$li.remove();
|
||||
const items = getCurrentNavbarItems();
|
||||
const menu = getMenuName(items, app);
|
||||
const menu = getMenuName(app);
|
||||
$.ajaxSubmit({url: customUrl, data: {menu: menu, items: JSON.stringify(items)}});
|
||||
}
|
||||
},
|
||||
@@ -211,7 +212,7 @@ $(document).on(
|
||||
$navItem.append($a);
|
||||
$li.after($navItem);
|
||||
const items = getCurrentNavbarItems();
|
||||
const menu = getMenuName(items, app);
|
||||
const menu = getMenuName(app);
|
||||
$.ajaxSubmit({url: customUrl, data: {menu: menu, items: JSON.stringify(items)}});
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ class navbar extends wg
|
||||
'text' => $lang->more,
|
||||
'trigger' => 'hover',
|
||||
'id' => 'navbarMoreMenu',
|
||||
'data-id' => 'more',
|
||||
'menu' => array('style' => array('max-width' => '300px'))
|
||||
);
|
||||
}
|
||||
@@ -128,11 +129,19 @@ class navbar extends wg
|
||||
if(!empty($items)) return $items;
|
||||
|
||||
global $app, $lang, $config;
|
||||
if($app->tab == 'admin') $app->control->loadModel('admin')->setMenu();
|
||||
if($app->tab == 'admin')
|
||||
{
|
||||
$app->control->loadModel('admin')->setMenu();
|
||||
$adminMenuKey = $app->control->loadModel('admin')->getMenuKey();
|
||||
jsVar('adminMenuKey', $adminMenuKey);
|
||||
}
|
||||
|
||||
commonModel::replaceMenuLang();
|
||||
commonModel::setMainMenu();
|
||||
$isHomeMenu = commonModel::setMainMenu();
|
||||
commonModel::checkMenuVarsReplaced();
|
||||
|
||||
jsVar('isHomeMenu', $isHomeMenu);
|
||||
|
||||
$isTutorialMode = commonModel::isTutorialMode();
|
||||
$currentModule = $app->rawModule;
|
||||
$currentMethod = $app->rawMethod;
|
||||
@@ -141,7 +150,7 @@ class navbar extends wg
|
||||
if($isTutorialMode and defined('WIZARD_METHOD')) $currentMethod = WIZARD_METHOD;
|
||||
|
||||
$tab = $app->tab;
|
||||
$menu = \customModel::getMainMenu();
|
||||
$menu = \customModel::getMainMenu($isHomeMenu);
|
||||
$activeMenu = '';
|
||||
$activeMenuID = data('activeMenuID');
|
||||
$items = array();
|
||||
@@ -194,7 +203,6 @@ class navbar extends wg
|
||||
$executionMoreItem = $this->getExecutionMoreItem($executionID);
|
||||
if(!empty($executionMoreItem))
|
||||
{
|
||||
$items[] = array('type' => 'divider');
|
||||
$items[] = $executionMoreItem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +111,9 @@ class adminModel extends model
|
||||
$menuKey = $this->getMenuKey();
|
||||
if(empty($menuKey)) return;
|
||||
|
||||
$customKey = "admin-$menuKey";
|
||||
$customMenu = isset($this->config->customMenu->{$customKey}) ? json_decode($this->config->customMenu->{$customKey}) : array();
|
||||
|
||||
$this->setSwitcher($menuKey);
|
||||
if(isset($this->lang->admin->menuList->$menuKey))
|
||||
{
|
||||
@@ -146,6 +149,22 @@ class adminModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
if($customMenu)
|
||||
{
|
||||
$this->lang->admin->menuList->{$menuKey}['menuOrder'] = array();
|
||||
$this->lang->admin->menuList->{$menuKey}['dividerMenu'] = '';
|
||||
$prev = '';
|
||||
foreach($customMenu as $item)
|
||||
{
|
||||
$this->lang->admin->menuList->{$menuKey}['menuOrder'][$item->order] = $item->name;
|
||||
if($prev == 'divider') $this->lang->admin->menuList->{$menuKey}['dividerMenu'] .= ',' . $item->name;
|
||||
$prev = $item->name;
|
||||
}
|
||||
|
||||
if($this->lang->admin->menuList->{$menuKey}['dividerMenu']) $this->lang->admin->menuList->{$menuKey}['dividerMenu'] = ',' . trim($this->lang->admin->menuList->{$menuKey}['dividerMenu']) . ',';
|
||||
ksort($this->lang->admin->menuList->{$menuKey}['menuOrder']);
|
||||
}
|
||||
|
||||
if(isset($this->lang->admin->menuList->{$menuKey}['menuOrder'])) $this->lang->admin->menuOrder = $this->lang->admin->menuList->{$menuKey}['menuOrder'];
|
||||
if(isset($this->lang->admin->menuList->{$menuKey}['dividerMenu'])) $this->lang->admin->dividerMenu = $this->lang->admin->menuList->{$menuKey}['dividerMenu'];
|
||||
if(isset($this->lang->admin->menuList->{$menuKey}['tabMenu'])) $this->lang->admin->tabMenu = $this->lang->admin->menuList->{$menuKey}['tabMenu'];
|
||||
|
||||
@@ -401,6 +401,7 @@ $lang->execution->menuOrder[55] = 'build';
|
||||
$lang->execution->menuOrder[60] = 'release';
|
||||
$lang->execution->menuOrder[65] = 'action';
|
||||
$lang->execution->menuOrder[70] = 'settings';
|
||||
$lang->execution->menuOrder[75] = 'more';
|
||||
|
||||
$lang->execution->menu->view['subMenu'] = new stdclass();
|
||||
$lang->execution->menu->view['subMenu']->groupTask = "$lang->groupView|execution|grouptask|executionID=%s";
|
||||
@@ -437,7 +438,7 @@ $lang->execution->menu->settings['subMenu']->products = array('link' => "$lang-
|
||||
$lang->execution->menu->settings['subMenu']->team = array('link' => "{$lang->team->common}|execution|team|executionID=%s", 'alias' => 'managemembers');
|
||||
$lang->execution->menu->settings['subMenu']->whitelist = array('link' => "$lang->whitelist|execution|whitelist|executionID=%s", 'subModule' => 'personnel', 'alias' => 'addwhitelist');
|
||||
|
||||
$lang->execution->dividerMenu = ',story,build,';
|
||||
$lang->execution->dividerMenu = ',story,build,more,';
|
||||
|
||||
$lang->project->noMultiple = new stdclass();
|
||||
$lang->project->noMultiple->scrum = new stdclass();
|
||||
|
||||
@@ -2056,9 +2056,9 @@ eof;
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public static function setMainMenu()
|
||||
public static function setMainMenu(): bool
|
||||
{
|
||||
global $app, $lang;
|
||||
$tab = $app->tab;
|
||||
@@ -2072,12 +2072,12 @@ eof;
|
||||
$lang->menu = isset($lang->$tab->menu) ? $lang->$tab->menu : array();
|
||||
$lang->menuOrder = isset($lang->$tab->menuOrder) ? $lang->$tab->menuOrder : array();
|
||||
|
||||
if(!isset($lang->$tab->homeMenu)) return;
|
||||
if(!isset($lang->$tab->homeMenu)) return false;
|
||||
|
||||
if($currentModule == $tab and $currentMethod == 'create')
|
||||
{
|
||||
$lang->menu = $lang->$tab->homeMenu;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* If the method is in homeMenu, display homeMenu. */
|
||||
@@ -2090,7 +2090,7 @@ eof;
|
||||
if($method == $currentMethod)
|
||||
{
|
||||
$lang->menu = $lang->$tab->homeMenu;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
$alias = isset($menu['alias']) ? explode(',', strtolower($menu['alias'])) : array();
|
||||
@@ -2098,15 +2098,17 @@ eof;
|
||||
if(in_array($currentMethod, $alias) && !in_array("{$currentModule}-{$currentMethod}", $exclude))
|
||||
{
|
||||
$lang->menu = $lang->$tab->homeMenu;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(isset($menu['subModule']) and strpos(",{$menu['subModule']},", ",$currentModule,") !== false)
|
||||
{
|
||||
$lang->menu = $lang->$tab->homeMenu;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* The model file of custom module of ZenTaoCMS.
|
||||
*
|
||||
@@ -428,10 +427,11 @@ class customModel extends model
|
||||
* Get module menu data, if module is 'main' then return main menu.
|
||||
*
|
||||
* @param string $module
|
||||
* @param bool $isHomeMenu
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function getModuleMenu($module = 'main'): array
|
||||
public static function getModuleMenu($module = 'main', $isHomeMenu = false): array
|
||||
{
|
||||
global $app, $lang, $config;
|
||||
|
||||
@@ -443,7 +443,6 @@ class customModel extends model
|
||||
if($module == 'product' and isset($allMenu->branch)) $allMenu->branch = str_replace('@branch@', $lang->custom->branch, $allMenu->branch);
|
||||
|
||||
/* 获取自定义过的导航。 */
|
||||
$isHomeMenu = in_array($app->tab, array('program', 'product', 'project', 'execution')) && count((array)$allMenu) <= 3 && $module == 'main';
|
||||
$customKey = $isHomeMenu ? $app->tab . '-home' : ($module == 'main' ? $app->tab : $app->tab . '-' . $module);
|
||||
$customMenu = isset($config->customMenu->{$customKey}) ? $config->customMenu->{$customKey}: array();
|
||||
|
||||
@@ -457,12 +456,13 @@ class customModel extends model
|
||||
* 获取主菜单数据。
|
||||
* Get main menu data.
|
||||
*
|
||||
* @param bool $isHomeMenu
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function getMainMenu(): array
|
||||
public static function getMainMenu($isHomeMenu = false): array
|
||||
{
|
||||
return static::getModuleMenu('main');
|
||||
return static::getModuleMenu('main', $isHomeMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user