From 57ab7c6ed80097b7ac7a9d8df7b4018f5db2da42 Mon Sep 17 00:00:00 2001 From: mokaddem Date: Fri, 30 Jul 2021 08:18:30 +0200 Subject: [PATCH] fix: [settings] Fixed scrollspy resolving missing some entries --- templates/Instance/settings.php | 15 +++++++++++++-- templates/element/Settings/panel.php | 2 +- templates/element/Settings/scrollspyNav.php | 6 +++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/templates/Instance/settings.php b/templates/Instance/settings.php index f020b1f..6cdfc90 100644 --- a/templates/Instance/settings.php +++ b/templates/Instance/settings.php @@ -1,4 +1,5 @@ 'danger', 'warning' => 'warning', @@ -82,7 +83,7 @@ function genContentForNav($sectionSettings, $appView) $mainPanelHeight = 'calc(100vh - 42px - 1rem - 56px - 38px - 1rem)'; $container = '
'; $container .= "
{$scrollspyNav}
"; - $container .= "
{$contentHtml}
"; + $container .= "
{$contentHtml}
"; $container .= '
'; return $container; } @@ -90,7 +91,8 @@ function genContentForNav($sectionSettings, $appView) function genSection($sectionName, $subSectionSettings, $appView) { $sectionContent = []; - $sectionContent[] = sprintf('
', sprintf('sp-%s', h($sectionName))); + $sectionContent[] = '
'; + $sectionContent[] = sprintf('

%s

', getResolvableID($sectionName), h($sectionName)); if (isLeaf($subSectionSettings)) { $panelHTML = $appView->element('Settings/panel', [ 'sectionName' => $sectionName, @@ -120,6 +122,15 @@ function isLeaf($setting) { return !empty($setting['name']) && !empty($setting['type']); } + +function getResolvableID($sectionName, $panelName=false) +{ + $id = sprintf('sp-%s', h($sectionName)); + if (!empty($panelName)) { + $id .= preg_replace('/(\.|\s)/', '_', h($panelName)); + } + return $id; +} ?>