* code for task #2518.
This commit is contained in:
@@ -69,6 +69,7 @@ $lang->hideNotCheck = 'Hide not checked field';
|
||||
$lang->quitNovice = 'Quit novice';
|
||||
$lang->enterNovice = 'Enter novice';
|
||||
$lang->homepage = 'Set homepage';
|
||||
$lang->customMenu = 'Custom menu';
|
||||
|
||||
$lang->preShortcutKey = '[Shortcut key:←]';
|
||||
$lang->nextShortcutKey = '[Shortcut key:→]';
|
||||
|
||||
@@ -69,6 +69,7 @@ $lang->hideNotCheck = '页面隐藏取消选中字段';
|
||||
$lang->quitNovice = '退出新手';
|
||||
$lang->enterNovice = '进入新手';
|
||||
$lang->homepage = '设为主页';
|
||||
$lang->customMenu = '自定义导航';
|
||||
|
||||
$lang->preShortcutKey = '[快捷键:←]';
|
||||
$lang->nextShortcutKey = '[快捷键:→]';
|
||||
|
||||
+11
-15
@@ -381,8 +381,6 @@ class commonModel extends model
|
||||
public static function printMainmenu($moduleName, $methodName = '')
|
||||
{
|
||||
global $app, $lang;
|
||||
if(empty($app->customMenu)) $app->customMenu = customModel::getCustomMenu($app->getModuleName(), $app->getMethodName());
|
||||
echo "<ul class='nav'>\n";
|
||||
|
||||
/* Set the main main menu. */
|
||||
$mainMenu = $moduleName;
|
||||
@@ -396,22 +394,20 @@ class commonModel extends model
|
||||
if($moduleName == 'task' and !isset($lang->menu->task)) $mainMenu = 'project';
|
||||
}
|
||||
|
||||
$activeName = $app->getViewType() == 'mhtml' ? 'ui-btn-active' : 'active';
|
||||
/* Print all main menus. */
|
||||
foreach($app->customMenu['main'] as $menuKey => $menuContent)
|
||||
{
|
||||
if($menuContent['status'] == 'hide') continue;
|
||||
$active = $menuKey == $mainMenu ? "class='$activeName'" : '';
|
||||
$link = explode('|', $menuContent['link']);
|
||||
list($menuLabel, $module, $method) = $link;
|
||||
$vars = isset($link[3]) ? $link[3] : '';
|
||||
$menu = customModel::getMainMenu();
|
||||
$activeName = $app->getViewType() == 'mhtml' ? 'ui-btn-active' : 'active';
|
||||
|
||||
if(commonModel::hasPriv($module, $method))
|
||||
{
|
||||
$link = helper::createLink($module, $method, $vars);
|
||||
echo "<li $active><a href='$link' $active data-id='$menuKey'>$menuLabel</a></li>\n";
|
||||
}
|
||||
echo "<ul class='nav'>\n";
|
||||
foreach($menu as $menuItem)
|
||||
{
|
||||
if($menuItem->hidden) continue;
|
||||
$active = $menuItem->name == $mainMenu ? "class='$activeName'" : '';
|
||||
$link = is_array($menuItem->link) ? helper::createLink($menuItem->link['module'], $menuItem->link['method'], $menuItem->link['vars']) : $menuItem->link;
|
||||
echo "<li $active data-id='$menuItem->name'><a href='$link' $active>$menuItem->label</a></li>\n";
|
||||
}
|
||||
$customLink = helper::createLink('custom', 'menu');
|
||||
echo "<li class='custom-item'><a href='$customLink' data-toggle='modal' data-type='iframe' title='$lang->customMenu' data-icon='cog'><i class='icon icon-cog'></i></a></li>";
|
||||
echo "</ul>\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -7,3 +7,7 @@ $config->custom->canAdd['testcase'] = 'priList,typeList,stageList';
|
||||
$config->custom->canAdd['testtask'] = 'priList';
|
||||
$config->custom->canAdd['todo'] = 'priList,typeList';
|
||||
$config->custom->canAdd['user'] = 'roleList';
|
||||
|
||||
$config->menu = new stdclass();
|
||||
$config->menu->main = array();
|
||||
$config->menu->main['novice'] = 'my,product,project,qa,doc,report,company,admin';
|
||||
|
||||
@@ -181,4 +181,24 @@ class custom extends control
|
||||
$account = $this->app->user->account;
|
||||
$this->loadModel('setting')->setItem("$account.$module.homepage", $page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get or set menu
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function menu($type = 'main')
|
||||
{
|
||||
global $config;
|
||||
if($_POST)
|
||||
{
|
||||
$config->menucustom->main = $_POST['menu'];
|
||||
$this->send(array('result' => 'success', 'menu' => $_POST['menu']));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->send(customModel::getMainMenu());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +123,57 @@ class customModel extends model
|
||||
->beginIF($params['key'])->andWhere('`key`')->in($params['key'])->fi();
|
||||
}
|
||||
|
||||
public static function getMainMenu($rebuild = false)
|
||||
{
|
||||
global $app, $lang, $config;
|
||||
// if(empty($app->customMenu)) $app->customMenu = array();
|
||||
// if(!$rebuild && !empty($app->customMenu['main'])) return $app->customMenu['main'];
|
||||
|
||||
$menuConfig = $config->menucustom->main;
|
||||
if(!isset($menuConfig) && common::inNoviceMode()) $menuConfig = $config->menu->main['novice'];
|
||||
$isSetMenuConfig = isset($menuConfig);
|
||||
|
||||
if($isSetMenuConfig)
|
||||
{
|
||||
if(is_string($menuConfig))
|
||||
{
|
||||
$menuConfigItems = explode(',', $menuConfig);
|
||||
$menuConfig = array();
|
||||
foreach($menuConfigItems as $menuConfigItem)
|
||||
{
|
||||
$menuConfig[$menuConfigItem] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$menu = array();
|
||||
foreach($lang->menu as $name => $item)
|
||||
{
|
||||
$link = explode('|', $item);
|
||||
list($label, $module, $method) = $link;
|
||||
|
||||
if(commonModel::hasPriv($module, $method))
|
||||
{
|
||||
$vars = isset($link[3]) ? $link[3] : '';
|
||||
|
||||
$menuItem = new stdclass();
|
||||
$menuItem->name = $name;
|
||||
$menuItem->link = array('module' => $module, 'method' => $method, 'vars' => $vars);
|
||||
$menuItem->label = $label;
|
||||
$menuItem->hidden = $isSetMenuConfig && (!$menuConfig[$name]);
|
||||
|
||||
$menu[] = $menuItem;
|
||||
}
|
||||
}
|
||||
// $app->customMenu['main'] = $menu;
|
||||
return $menu;
|
||||
}
|
||||
|
||||
public static function getModuleMenu()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function getCustomMenu($module, $method)
|
||||
{
|
||||
global $app, $lang, $config;
|
||||
@@ -139,6 +190,7 @@ class customModel extends model
|
||||
$menuStatus = array();
|
||||
if($type == 'main') $menucustom = isset($config->menucustom->main) ? $config->menucustom->main : '';
|
||||
if($type == 'module')$menucustom = isset($config->menucustomModule->$module) ? $config->menucustomModule->$module : '';
|
||||
|
||||
/* Get order and status from config. */
|
||||
if($menucustom)
|
||||
{
|
||||
|
||||
+11
-2
@@ -1790,8 +1790,17 @@ function setHomepage(module, page)
|
||||
function initMainMenu()
|
||||
{
|
||||
var $menu = $('#mainmenu > .nav');
|
||||
$menu.sortable({
|
||||
|
||||
$menu.sortable(
|
||||
{
|
||||
selector: 'li:not(.custom-item)',
|
||||
finish: function(e)
|
||||
{
|
||||
var menu = e.list.map(function(){return $(this).data('id');}).get();
|
||||
$.post(createLink('custom', 'menu'), {menu: menu.join(',')}, function(data)
|
||||
{
|
||||
console.log(data);
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -371,8 +371,12 @@ body {font-size: 13px; color:#141414;padding-bottom: 40px;}
|
||||
#mainmenu {margin-top: 12px; width: 100%; position: relative;}
|
||||
#mainmenu .nav > li {float: left;}
|
||||
#mainmenu .nav > li > a {display: block; margin-right: 3px; white-space:nowrap; padding:7px 15px; color:#E5E5E5; font-size: 14px; background:#114f8e;-webkit-box-shadow: 0 -3px 3px rgba(0, 0, 0, 0.10);box-shadow: 0 -3px 3px rgba(0, 0, 0, 0.10);}
|
||||
#mainmenu .nav > li > a:hover{background-color: #2e6dad;color: #fff;-webkit-box-shadow: 0 -3px 5px rgba(0, 0, 0, 0.2);box-shadow: 0 -3px 5px rgba(0, 0, 0, 0.2);}
|
||||
#mainmenu .nav > li > a:hover{background-color: #2e6dad;color: #fff; box-shadow: 0 -3px 5px rgba(0, 0, 0, 0.2);}
|
||||
#mainmenu .nav > li.active > a { background-color:#e5e5e5;color:#21841d; font-weight:bold;}
|
||||
#mainmenu .nav > li.custom-item {opacity: 0; transition: opacity .4s .6s}
|
||||
#mainmenu:hover .nav > li.custom-item {opacity: 1;}
|
||||
#mainmenu .nav > li.custom-item > a {background-color: transparent; box-shadow: none}
|
||||
#mainmenu .nav > li.custom-item > a:hover {background-color: #2e6dad;color: #fff; box-shadow: 0 -3px 5px rgba(0, 0, 0, 0.2);}
|
||||
|
||||
#searchbox {position: absolute; right: 0; top: 1px; width: 200px;}
|
||||
#searchbox .form-control, #searchbox .btn {padding: 2px 5px; line-height: 20px; height: 24px;border-top: 0; border-bottom: 0; float: left; display: block;}
|
||||
|
||||
Reference in New Issue
Block a user