Skip to content

Commit 7273d55

Browse files
committed
fix sidebar root node links
link sidebar root nodes to their corresponding "new" route
1 parent c445359 commit 7273d55

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/Services/Trees/TreeViewGenerator.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,7 @@ private function getTreeViewUncached(
174174
}
175175

176176
if (($mode === 'list_parts_root' || $mode === 'devices') && $this->rootNodeEnabled) {
177-
//We show the root node as a link to the list of all parts
178-
$show_all_parts_url = $this->router->generate('parts_show_all');
179-
180-
$root_node = new TreeViewNode($this->entityClassToRootNodeString($class), $show_all_parts_url, $generic);
177+
$root_node = new TreeViewNode($this->entityClassToRootNodeString($class), $this->entityClassToRootNodeHref($class), $generic);
181178
$root_node->setExpanded($this->rootNodeExpandedByDefault);
182179
$root_node->setIcon($this->entityClassToRootNodeIcon($class));
183180

@@ -187,6 +184,19 @@ private function getTreeViewUncached(
187184
return array_merge($head, $generic);
188185
}
189186

187+
protected function entityClassToRootNodeHref(string $class): ?string
188+
{
189+
return match ($class) {
190+
Category::class => $this->router->generate('category_new'),
191+
StorageLocation::class => $this->router->generate('store_location_new'),
192+
Footprint::class => $this->router->generate('footprint_new'),
193+
Manufacturer::class => $this->router->generate('manufacturer_new'),
194+
Supplier::class => $this->router->generate('supplier_new'),
195+
Project::class => $this->router->generate('project_new'),
196+
default => null,
197+
};
198+
}
199+
190200
protected function entityClassToRootNodeString(string $class): string
191201
{
192202
return match ($class) {

0 commit comments

Comments
 (0)