N°1070: Enhance ergonomics of "Add To Dashboard..." popup window

* Larger window to avoid the scrollbar.
* Check the dashboards root parent access rights to generate the dashboards list proposed in the popup.

SVN:trunk[5185]
This commit is contained in:
Eric Espié
2018-01-02 13:08:14 +00:00
parent fe23e099fe
commit f73ca10b6c

View File

@@ -765,27 +765,52 @@ EOF
$sRootMenuId = ApplicationMenu::GetRootMenuId($sContextMenuId); $sRootMenuId = ApplicationMenu::GetRootMenuId($sContextMenuId);
$aAllowedDashboards = array(); $aAllowedDashboards = array();
$sDefaultDashboard = null; $sDefaultDashboard = null;
foreach($aAllMenus as $idx => $aMenu)
// Store the parent menus for acces check
$aParentMenus = array();
foreach($aAllMenus as $idx => $aMenu)
{
/** @var MenuNode $oMenu */
$oMenu = $aMenu['node'];
if (count(ApplicationMenu::GetChildren($oMenu->GetIndex())) > 0)
{
$aParentMenus[$oMenu->GetMenuId()] = $aMenu;
}
}
foreach($aAllMenus as $idx => $aMenu)
{ {
$oMenu = $aMenu['node']; $oMenu = $aMenu['node'];
$sParentId = $aMenu['parent']; if ($oMenu instanceof DashboardMenuNode)
if (($oMenu instanceof DashboardMenuNode) && ($oMenu->IsEnabled())) {
{ // Get the root parent for access check
$sMenuLabel = $oMenu->GetTitle(); $sParentId = $aMenu['parent'];
$sParentLabel = Dict::S('Menu:'.$sParentId); $aParentMenu = $aParentMenus[$sParentId];
if ($sParentLabel != $sMenuLabel) while (isset($aParentMenus[$aParentMenu['parent']]))
{ {
$aAllowedDashboards[$oMenu->GetMenuId()] = $sParentLabel.' - '.$sMenuLabel; // grand parent exists
} $sParentId = $aParentMenu['parent'];
else $aParentMenu = $aParentMenus[$sParentId];
{ }
$aAllowedDashboards[$oMenu->GetMenuId()] = $sMenuLabel; $oParentMenu = $aParentMenu['node'];
} if ($oMenu->IsEnabled() && $oParentMenu->IsEnabled())
if (empty($sDefaultDashboard) && ($sRootMenuId == ApplicationMenu::GetRootMenuId($oMenu->GetMenuId()))) {
{ $sMenuLabel = $oMenu->GetTitle();
$sDefaultDashboard = $oMenu->GetMenuId(); $sParentLabel = Dict::S('Menu:'.$sParentId);
} if ($sParentLabel != $sMenuLabel)
} {
$aAllowedDashboards[$oMenu->GetMenuId()] = $sParentLabel.' - '.$sMenuLabel;
}
else
{
$aAllowedDashboards[$oMenu->GetMenuId()] = $sMenuLabel;
}
if (empty($sDefaultDashboard) && ($sRootMenuId == ApplicationMenu::GetRootMenuId($oMenu->GetMenuId())))
{
$sDefaultDashboard = $oMenu->GetMenuId();
}
}
}
} }
asort($aAllowedDashboards); asort($aAllowedDashboards);
@@ -849,7 +874,7 @@ EOF
$oPage->add_ready_script( $oPage->add_ready_script(
<<<EOF <<<EOF
$('#dashlet_creation_dlg').dialog({ $('#dashlet_creation_dlg').dialog({
width: 500, width: 600,
modal: true, modal: true,
title: '$sDialogTitle', title: '$sDialogTitle',
buttons: [ buttons: [