diff --git a/application/menunode.class.inc.php b/application/menunode.class.inc.php index 9d89be860..cd69f2b09 100644 --- a/application/menunode.class.inc.php +++ b/application/menunode.class.inc.php @@ -277,6 +277,7 @@ class ApplicationMenu $aSubMenuNodes[] = [ 'sId' => $oSubMenuNode->GetMenuId(), 'sTitle' => $oSubMenuNode->GetTitle(), + 'sEntriesCount' => $oSubMenuNode->GetEntriesCount(), 'sUrl' => $oSubMenuNode->GetHyperlink($aExtraParams), 'bOpenInNewWindow' => $oSubMenuNode->IsHyperLinkInNewWindow(), 'aSubMenuNodes' => static::GetSubMenuNodes($sSubMenuItemIdx, $aExtraParams), @@ -666,21 +667,22 @@ abstract class MenuNode return Dict::S("Menu:$this->sMenuId", str_replace('_', ' ', $this->sMenuId)); } + public function GetEntriesCount() + { + return -1; + } + /** * @return string */ public function GetLabel() { $sRet = Dict::S("Menu:$this->sMenuId+", ""); - if ($sRet === '') - { - if ($this->iParentIndex != -1) - { + if ($sRet === '') { + if ($this->iParentIndex != -1) { $oParentMenu = ApplicationMenu::GetMenuNode($this->iParentIndex); $sRet = $oParentMenu->GetTitle().' / '.$this->GetTitle(); - } - else - { + } else { $sRet = $this->GetTitle(); } //$sRet = $this->GetTitle(); @@ -1065,15 +1067,14 @@ class OQLMenuNode extends MenuNode $oBlock = new DisplayBlock($oSearch, 'search', false /* Asynchronous */, $aParams); $oBlock->Display($oPage, 0); } - + $oPage->add("
$sIcon ".utils::HtmlEntities(Dict::S($sTitle))."
"); - + $aParams = array_merge(array('table_id' => $sUsageId), $aExtraParams); $oBlock = new DisplayBlock($oSearch, 'list', false /* Asynchronous */, $aParams); $oBlock->Display($oPage, $sUsageId); - if ($bEnableBreadcrumb && ($oPage instanceof iTopWebPage)) - { + if ($bEnableBreadcrumb && ($oPage instanceof iTopWebPage)) { // Breadcrumb //$iCount = $oBlock->GetDisplayedCount(); $sPageId = "ui-search-".$oSearch->GetClass(); @@ -1081,6 +1082,19 @@ class OQLMenuNode extends MenuNode $oPage->SetBreadCrumbEntry($sPageId, $sLabel, $sTitle, '', 'fas fa-list', iTopWebPage::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_CSS_CLASSES); } } + + public function GetEntriesCount() + { + // Count the entries up to 99 + + $oSet = new DBObjectSet(DBSearch::FromOQL($this->sOQL)); + $iCount = $oSet->CountWithLimit(99); + if ($iCount > 99) { + $iCount = "99+"; + } + + return $iCount; + } } /** diff --git a/templates/layouts/navigation-menu/menu-node.html.twig b/templates/layouts/navigation-menu/menu-node.html.twig index 1ce87c59b..3ec41ed20 100644 --- a/templates/layouts/navigation-menu/menu-node.html.twig +++ b/templates/layouts/navigation-menu/menu-node.html.twig @@ -1,7 +1,11 @@