chg: [instance:settings] group and panel level are optionals

pull/70/head
mokaddem 2021-07-27 13:40:24 +02:00
parent 99522056fe
commit b75cdac42b
1 changed files with 27 additions and 16 deletions

View File

@ -66,6 +66,7 @@ function genContentForNav($sectionSettings, $appView)
} else { } else {
$groupedContent[] = ''; $groupedContent[] = '';
} }
if (!isLeaf($subSectionSettings)) {
$groupedSetting[$sectionName] = array_filter( // only show grouped settings $groupedSetting[$sectionName] = array_filter( // only show grouped settings
array_keys($subSectionSettings), array_keys($subSectionSettings),
function ($settingGroupName) use ($subSectionSettings) { function ($settingGroupName) use ($subSectionSettings) {
@ -73,6 +74,7 @@ function genContentForNav($sectionSettings, $appView)
} }
); );
} }
}
$contentHtml = implode('', $groupedContent); $contentHtml = implode('', $groupedContent);
$scrollspyNav = $appView->element('Settings/scrollspyNav', [ $scrollspyNav = $appView->element('Settings/scrollspyNav', [
'groupedSetting' => $groupedSetting 'groupedSetting' => $groupedSetting
@ -89,6 +91,14 @@ function genSection($sectionName, $subSectionSettings, $appView)
{ {
$sectionContent = []; $sectionContent = [];
$sectionContent[] = sprintf('<div id="%s">', sprintf('sp-%s', h($sectionName))); $sectionContent[] = sprintf('<div id="%s">', sprintf('sp-%s', h($sectionName)));
if (isLeaf($subSectionSettings)) {
$panelHTML = $appView->element('Settings/panel', [
'sectionName' => $sectionName,
'panelName' => $sectionName,
'panelSettings' => $subSectionSettings,
]);
$sectionContent[] = $panelHTML;
} else {
foreach ($subSectionSettings as $panelName => $panelSettings) { foreach ($subSectionSettings as $panelName => $panelSettings) {
if (!empty($panelSettings)) { if (!empty($panelSettings)) {
$panelHTML = $appView->element('Settings/panel', [ $panelHTML = $appView->element('Settings/panel', [
@ -101,6 +111,7 @@ function genSection($sectionName, $subSectionSettings, $appView)
$sectionContent[] = ''; $sectionContent[] = '';
} }
} }
}
$sectionContent[] = '</div>'; $sectionContent[] = '</div>';
return implode('', $sectionContent); return implode('', $sectionContent);
} }