From 7273d55bf8b1f7b0586c3da08b075bcddfb6bd5b Mon Sep 17 00:00:00 2001 From: d-buchmann Date: Fri, 27 Jun 2025 12:21:02 +0200 Subject: [PATCH] fix sidebar root node links link sidebar root nodes to their corresponding "new" route --- src/Services/Trees/TreeViewGenerator.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Services/Trees/TreeViewGenerator.php b/src/Services/Trees/TreeViewGenerator.php index 23d6a406..9a67a03c 100644 --- a/src/Services/Trees/TreeViewGenerator.php +++ b/src/Services/Trees/TreeViewGenerator.php @@ -174,10 +174,7 @@ class TreeViewGenerator } if (($mode === 'list_parts_root' || $mode === 'devices') && $this->rootNodeEnabled) { - //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 = new TreeViewNode($this->entityClassToRootNodeString($class), $this->entityClassToRootNodeHref($class), $generic); $root_node->setExpanded($this->rootNodeExpandedByDefault); $root_node->setIcon($this->entityClassToRootNodeIcon($class)); @@ -187,6 +184,19 @@ class TreeViewGenerator return array_merge($head, $generic); } + protected function entityClassToRootNodeHref(string $class): ?string + { + 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, + }; + } + protected function entityClassToRootNodeString(string $class): string { return match ($class) {