From e032f6b33d421a825128d6bd48f8ca342ce6267e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 3 Jul 2023 00:34:37 +0200 Subject: [PATCH] Use root node of sidebar trees as link to link to all parts list --- src/Services/Trees/TreeViewGenerator.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Services/Trees/TreeViewGenerator.php b/src/Services/Trees/TreeViewGenerator.php index ca93873c..75e0f57c 100644 --- a/src/Services/Trees/TreeViewGenerator.php +++ b/src/Services/Trees/TreeViewGenerator.php @@ -39,6 +39,7 @@ use App\Services\UserSystem\UserCacheKeyGenerator; use Doctrine\ORM\EntityManagerInterface; use InvalidArgumentException; use RecursiveIteratorIterator; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Contracts\Cache\ItemInterface; use Symfony\Contracts\Cache\TagAwareCacheInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -50,7 +51,9 @@ use function count; */ class TreeViewGenerator { - public function __construct(protected EntityURLGenerator $urlGenerator, protected EntityManagerInterface $em, protected TagAwareCacheInterface $cache, protected UserCacheKeyGenerator $keyGenerator, protected TranslatorInterface $translator, protected bool $rootNodeExpandedByDefault, protected bool $rootNodeEnabled) + public function __construct(protected EntityURLGenerator $urlGenerator, protected EntityManagerInterface $em, protected TagAwareCacheInterface $cache, + protected UserCacheKeyGenerator $keyGenerator, protected TranslatorInterface $translator, private UrlGeneratorInterface $router, + protected bool $rootNodeExpandedByDefault, protected bool $rootNodeEnabled) { } @@ -121,7 +124,10 @@ class TreeViewGenerator } if (($mode === 'list_parts_root' || $mode === 'devices') && $this->rootNodeEnabled) { - $root_node = new TreeViewNode($this->entityClassToRootNodeString($class), null, $generic); + //We show the root node as a link to the list of all parts + $show_all_parts_url = $this->router->generate('parts_show_all'); + + $root_node = new TreeViewNode($this->entityClassToRootNodeString($class), $show_all_parts_url, $generic); $root_node->setExpanded($this->rootNodeExpandedByDefault); $root_node->setIcon($this->entityClassToRootNodeIcon($class));