diff options
author | MaurĂcio Meneghini Fauth <mauricio@fauth.dev> | 2021-09-11 15:34:01 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-11 15:34:01 +0300 |
commit | 8031072f2737312b52a7180ab99f554e3ee0da43 (patch) | |
tree | 237238b09bde3d5dc8ef1adaaee3b3deeb1f512e | |
parent | 83091680cc9cab37ffcf29ed839f5f126527643e (diff) | |
parent | 0ee16ff0fef07a1b04a3eb8d0a6bf640afbf6e53 (diff) |
Merge pull request #17076 from lrb2/fix-table-grouping
Fix grouping of tables in navigation tree if `$cfg['NavigationTreeTableLevel'] > 1`
-rw-r--r-- | libraries/classes/Navigation/NavigationTree.php | 14 | ||||
-rw-r--r-- | templates/navigation/tree/node.twig | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/libraries/classes/Navigation/NavigationTree.php b/libraries/classes/Navigation/NavigationTree.php index 7fc1038bd3..e4a73a2c6a 100644 --- a/libraries/classes/Navigation/NavigationTree.php +++ b/libraries/classes/Navigation/NavigationTree.php @@ -1143,10 +1143,18 @@ class NavigationTree $controlButtons = ''; $paths = $node->getPaths(); $nodeIsContainer = $node->type === Node::CONTAINER; - $hasSiblingsOrIsNotRoot = $node->hasSiblings() || $node->realParent() === false; $liClasses = ''; - if ($hasSiblingsOrIsNotRoot) { + // Whether to show the node in the tree (true for all nodes but root) + // If false, the node's children will still be shown, but as children of the node's parent + $showNode = $node->hasSiblings() || count($node->parents(false, true)) > 0; + + // Don't show the 'Tables' node under each database unless it has 'Views', etc. as a sibling + if ($node instanceof NodeTableContainer && ! $node->hasSiblings()) { + $showNode = false; + } + + if ($showNode) { $response = ResponseRenderer::getInstance(); if ($nodeIsContainer && count($node->children) === 0 && ! $response->isAjax()) { return ''; @@ -1262,7 +1270,7 @@ class NavigationTree return $this->template->render('navigation/tree/node', [ 'node' => $node, 'class' => $class, - 'has_siblings_or_is_not_root' => $hasSiblingsOrIsNotRoot, + 'show_node' => $showNode, 'has_siblings' => $node->hasSiblings(), 'li_classes' => $liClasses, 'control_buttons' => $controlButtons, diff --git a/templates/navigation/tree/node.twig b/templates/navigation/tree/node.twig index 89c3d58f9b..fc1fb00f23 100644 --- a/templates/navigation/tree/node.twig +++ b/templates/navigation/tree/node.twig @@ -1,4 +1,4 @@ -{% if has_siblings_or_is_not_root %} +{% if show_node %} <li class="{{ li_classes }}"> <div class="block"> <i{{ class == 'first' ? ' class="first"' }}></i> |