mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 10:49:00 +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
|
@ -65,9 +65,10 @@ class TreeViewGenerator
|
|||
protected $translator;
|
||||
|
||||
protected $rootNodeExpandedByDefault;
|
||||
protected $rootNodeEnabled;
|
||||
|
||||
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->em = $em;
|
||||
|
@ -76,6 +77,7 @@ class TreeViewGenerator
|
|||
$this->translator = $translator;
|
||||
|
||||
$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->setExpanded($this->rootNodeExpandedByDefault);
|
||||
$generic = [$root_node];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue