Added an parameter to enable/disable the root node in the sidebar

Fixes issue #158
This commit is contained in:
Jan Böhmer 2022-08-13 01:46:53 +02:00
parent e8e1da9c61
commit 796dea33f2
3 changed files with 6 additions and 2 deletions

View file

@ -65,9 +65,10 @@ class TreeViewGenerator
protected $translator;
protected $rootNodeExpandedByDefault;
protected $rootNodeEnabled;
public function __construct(EntityURLGenerator $URLGenerator, EntityManagerInterface $em,
TagAwareCacheInterface $treeCache, UserCacheKeyGenerator $keyGenerator, TranslatorInterface $translator, bool $rootNodeExpandedByDefault)
TagAwareCacheInterface $treeCache, UserCacheKeyGenerator $keyGenerator, TranslatorInterface $translator, bool $rootNodeExpandedByDefault, bool $rootNodeEnabled)
{
$this->urlGenerator = $URLGenerator;
$this->em = $em;
@ -76,6 +77,7 @@ class TreeViewGenerator
$this->translator = $translator;
$this->rootNodeExpandedByDefault = $rootNodeExpandedByDefault;
$this->rootNodeEnabled = $rootNodeEnabled;
}
/**
@ -144,7 +146,7 @@ class TreeViewGenerator
}
}
if ($mode === 'list_parts_root' ||$mode === 'devices') {
if (($mode === 'list_parts_root' || $mode === 'devices') && $this->rootNodeEnabled) {
$root_node = new TreeViewNode($this->translator->trans('tree.root_node.text'), null, $generic);
$root_node->setExpanded($this->rootNodeExpandedByDefault);
$generic = [$root_node];