From b75cdac42b27804bb43cd93667844af3818df764 Mon Sep 17 00:00:00 2001 From: mokaddem Date: Tue, 27 Jul 2021 13:40:24 +0200 Subject: [PATCH] chg: [instance:settings] group and panel level are optionals --- templates/Instance/settings.php | 43 +++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/templates/Instance/settings.php b/templates/Instance/settings.php index e8c9246..f020b1f 100644 --- a/templates/Instance/settings.php +++ b/templates/Instance/settings.php @@ -66,12 +66,14 @@ function genContentForNav($sectionSettings, $appView) } else { $groupedContent[] = ''; } - $groupedSetting[$sectionName] = array_filter( // only show grouped settings - array_keys($subSectionSettings), - function ($settingGroupName) use ($subSectionSettings) { - return !isLeaf($subSectionSettings[$settingGroupName]) && !empty($subSectionSettings[$settingGroupName]); - } - ); + if (!isLeaf($subSectionSettings)) { + $groupedSetting[$sectionName] = array_filter( // only show grouped settings + array_keys($subSectionSettings), + function ($settingGroupName) use ($subSectionSettings) { + return !isLeaf($subSectionSettings[$settingGroupName]) && !empty($subSectionSettings[$settingGroupName]); + } + ); + } } $contentHtml = implode('', $groupedContent); $scrollspyNav = $appView->element('Settings/scrollspyNav', [ @@ -89,16 +91,25 @@ function genSection($sectionName, $subSectionSettings, $appView) { $sectionContent = []; $sectionContent[] = sprintf('
', sprintf('sp-%s', h($sectionName))); - foreach ($subSectionSettings as $panelName => $panelSettings) { - if (!empty($panelSettings)) { - $panelHTML = $appView->element('Settings/panel', [ - 'sectionName' => $sectionName, - 'panelName' => $panelName, - 'panelSettings' => $panelSettings, - ]); - $sectionContent[] = $panelHTML; - } else { - $sectionContent[] = ''; + if (isLeaf($subSectionSettings)) { + $panelHTML = $appView->element('Settings/panel', [ + 'sectionName' => $sectionName, + 'panelName' => $sectionName, + 'panelSettings' => $subSectionSettings, + ]); + $sectionContent[] = $panelHTML; + } else { + foreach ($subSectionSettings as $panelName => $panelSettings) { + if (!empty($panelSettings)) { + $panelHTML = $appView->element('Settings/panel', [ + 'sectionName' => $sectionName, + 'panelName' => $panelName, + 'panelSettings' => $panelSettings, + ]); + $sectionContent[] = $panelHTML; + } else { + $sectionContent[] = ''; + } } } $sectionContent[] = '
';