Use "Show all parts" for most root categories and started to make it configurable for the future

This commit is contained in:
Jan Böhmer 2025-07-02 22:09:41 +02:00
parent 7273d55bf8
commit a32c875702

View file

@ -63,7 +63,8 @@ class TreeViewGenerator
private readonly UrlGeneratorInterface $router, private readonly UrlGeneratorInterface $router,
protected bool $rootNodeExpandedByDefault, protected bool $rootNodeExpandedByDefault,
protected bool $rootNodeEnabled, protected bool $rootNodeEnabled,
//TODO: Make this configurable in the future
protected bool $rootNodeRedirectsToNewEntity = false,
) { ) {
} }
@ -186,6 +187,8 @@ class TreeViewGenerator
protected function entityClassToRootNodeHref(string $class): ?string 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) { return match ($class) {
Category::class => $this->router->generate('category_new'), Category::class => $this->router->generate('category_new'),
StorageLocation::class => $this->router->generate('store_location_new'), StorageLocation::class => $this->router->generate('store_location_new'),
@ -197,6 +200,12 @@ class TreeViewGenerator
}; };
} }
return match ($class) {
Project::class => $this->router->generate('project_new'),
default => $this->router->generate('parts_show_all')
};
}
protected function entityClassToRootNodeString(string $class): string protected function entityClassToRootNodeString(string $class): string
{ {
return match ($class) { return match ($class) {