From a32c87570237800ee421f45eb733a3cc953cf777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Wed, 2 Jul 2025 22:09:41 +0200 Subject: [PATCH] Use "Show all parts" for most root categories and started to make it configurable for the future --- src/Services/Trees/TreeViewGenerator.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Services/Trees/TreeViewGenerator.php b/src/Services/Trees/TreeViewGenerator.php index 9a67a03c..c66f2ee2 100644 --- a/src/Services/Trees/TreeViewGenerator.php +++ b/src/Services/Trees/TreeViewGenerator.php @@ -63,7 +63,8 @@ class TreeViewGenerator private readonly UrlGeneratorInterface $router, protected bool $rootNodeExpandedByDefault, protected bool $rootNodeEnabled, - + //TODO: Make this configurable in the future + protected bool $rootNodeRedirectsToNewEntity = false, ) { } @@ -186,14 +187,22 @@ class TreeViewGenerator protected function entityClassToRootNodeHref(string $class): ?string { + //If the root node should redirect to the new entity page, we return the URL for the new entity. + if ($this->rootNodeRedirectsToNewEntity) { + return match ($class) { + Category::class => $this->router->generate('category_new'), + StorageLocation::class => $this->router->generate('store_location_new'), + Footprint::class => $this->router->generate('footprint_new'), + Manufacturer::class => $this->router->generate('manufacturer_new'), + Supplier::class => $this->router->generate('supplier_new'), + Project::class => $this->router->generate('project_new'), + default => null, + }; + } + return match ($class) { - Category::class => $this->router->generate('category_new'), - StorageLocation::class => $this->router->generate('store_location_new'), - Footprint::class => $this->router->generate('footprint_new'), - Manufacturer::class => $this->router->generate('manufacturer_new'), - Supplier::class => $this->router->generate('supplier_new'), Project::class => $this->router->generate('project_new'), - default => null, + default => $this->router->generate('parts_show_all') }; }