mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-25 03:08:51 +02:00
Added an parameter to enable/disable the root node in the sidebar
Fixes issue #158
This commit is contained in:
parent
e8e1da9c61
commit
796dea33f2
3 changed files with 6 additions and 2 deletions
|
@ -48,6 +48,7 @@ parameters:
|
||||||
- devices
|
- devices
|
||||||
- tools
|
- tools
|
||||||
partdb.sidebar.root_expanded: true # If this is set to true, the root node of the sidebar is expanded by default
|
partdb.sidebar.root_expanded: true # If this is set to true, the root node of the sidebar is expanded by default
|
||||||
|
partdb.sidebar.root_node_enable: true # Put all entities below a root node in the sidebar
|
||||||
|
|
||||||
######################################################################################################################
|
######################################################################################################################
|
||||||
# Miscellaneous
|
# Miscellaneous
|
||||||
|
|
|
@ -205,6 +205,7 @@ services:
|
||||||
App\Services\Trees\TreeViewGenerator:
|
App\Services\Trees\TreeViewGenerator:
|
||||||
arguments:
|
arguments:
|
||||||
$rootNodeExpandedByDefault: '%partdb.sidebar.root_expanded%'
|
$rootNodeExpandedByDefault: '%partdb.sidebar.root_expanded%'
|
||||||
|
$rootNodeEnabled: '%partdb.sidebar.root_node_enable%'
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Symfony overrides
|
# Symfony overrides
|
||||||
|
|
|
@ -65,9 +65,10 @@ class TreeViewGenerator
|
||||||
protected $translator;
|
protected $translator;
|
||||||
|
|
||||||
protected $rootNodeExpandedByDefault;
|
protected $rootNodeExpandedByDefault;
|
||||||
|
protected $rootNodeEnabled;
|
||||||
|
|
||||||
public function __construct(EntityURLGenerator $URLGenerator, EntityManagerInterface $em,
|
public function __construct(EntityURLGenerator $URLGenerator, EntityManagerInterface $em,
|
||||||
TagAwareCacheInterface $treeCache, UserCacheKeyGenerator $keyGenerator, TranslatorInterface $translator, bool $rootNodeExpandedByDefault)
|
TagAwareCacheInterface $treeCache, UserCacheKeyGenerator $keyGenerator, TranslatorInterface $translator, bool $rootNodeExpandedByDefault, bool $rootNodeEnabled)
|
||||||
{
|
{
|
||||||
$this->urlGenerator = $URLGenerator;
|
$this->urlGenerator = $URLGenerator;
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
|
@ -76,6 +77,7 @@ class TreeViewGenerator
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
|
|
||||||
$this->rootNodeExpandedByDefault = $rootNodeExpandedByDefault;
|
$this->rootNodeExpandedByDefault = $rootNodeExpandedByDefault;
|
||||||
|
$this->rootNodeEnabled = $rootNodeEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,7 +146,7 @@ class TreeViewGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mode === 'list_parts_root' ||$mode === 'devices') {
|
if (($mode === 'list_parts_root' || $mode === 'devices') && $this->rootNodeEnabled) {
|
||||||
$root_node = new TreeViewNode($this->translator->trans('tree.root_node.text'), null, $generic);
|
$root_node = new TreeViewNode($this->translator->trans('tree.root_node.text'), null, $generic);
|
||||||
$root_node->setExpanded($this->rootNodeExpandedByDefault);
|
$root_node->setExpanded($this->rootNodeExpandedByDefault);
|
||||||
$generic = [$root_node];
|
$generic = [$root_node];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue