Skip to content

Commit

Permalink
Merge pull request #17076 from lrb2/fix-table-grouping
Browse files Browse the repository at this point in the history
Fix grouping of tables in navigation tree if `$cfg['NavigationTreeTableLevel'] > 1`
  • Loading branch information
MauricioFauth committed Sep 11, 2021
2 parents 8309168 + 0ee16ff commit 8031072
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions libraries/classes/Navigation/NavigationTree.php
Expand Up @@ -1143,10 +1143,18 @@ private function renderNode(Node $node, string $class = ''): string
$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 '';
Expand Down Expand Up @@ -1262,7 +1270,7 @@ private function renderNode(Node $node, string $class = ''): string
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,
Expand Down
2 changes: 1 addition & 1 deletion 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>
Expand Down

0 comments on commit 8031072

Please sign in to comment.