diff --git a/config/parameters.yaml b/config/parameters.yaml index a78d989e..64c06aeb 100644 --- a/config/parameters.yaml +++ b/config/parameters.yaml @@ -48,6 +48,7 @@ parameters: - devices - tools partdb.sidebar.root_expanded: true # If this is set to true, the root node of the sidebar is expanded by default + partdb.sidebar.root_node_enable: true # Put all entities below a root node in the sidebar ###################################################################################################################### # Miscellaneous diff --git a/config/services.yaml b/config/services.yaml index 90f44739..449519b8 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -205,6 +205,7 @@ services: App\Services\Trees\TreeViewGenerator: arguments: $rootNodeExpandedByDefault: '%partdb.sidebar.root_expanded%' + $rootNodeEnabled: '%partdb.sidebar.root_node_enable%' #################################################################################################################### # Symfony overrides diff --git a/src/Services/Trees/TreeViewGenerator.php b/src/Services/Trees/TreeViewGenerator.php index 310d5cdc..fb5ad525 100644 --- a/src/Services/Trees/TreeViewGenerator.php +++ b/src/Services/Trees/TreeViewGenerator.php @@ -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];