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,12 +66,14 @@ function genContentForNav($sectionSettings, $appView)
} else { } else {
$groupedContent[] = ''; $groupedContent[] = '';
} }
$groupedSetting[$sectionName] = array_filter( // only show grouped settings if (!isLeaf($subSectionSettings)) {
array_keys($subSectionSettings), $groupedSetting[$sectionName] = array_filter( // only show grouped settings
function ($settingGroupName) use ($subSectionSettings) { array_keys($subSectionSettings),
return !isLeaf($subSectionSettings[$settingGroupName]) && !empty($subSectionSettings[$settingGroupName]); function ($settingGroupName) use ($subSectionSettings) {
} return !isLeaf($subSectionSettings[$settingGroupName]) && !empty($subSectionSettings[$settingGroupName]);
); }
);
}
} }
$contentHtml = implode('', $groupedContent); $contentHtml = implode('', $groupedContent);
$scrollspyNav = $appView->element('Settings/scrollspyNav', [ $scrollspyNav = $appView->element('Settings/scrollspyNav', [
@ -89,16 +91,25 @@ 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)));
foreach ($subSectionSettings as $panelName => $panelSettings) { if (isLeaf($subSectionSettings)) {
if (!empty($panelSettings)) { $panelHTML = $appView->element('Settings/panel', [
$panelHTML = $appView->element('Settings/panel', [ 'sectionName' => $sectionName,
'sectionName' => $sectionName, 'panelName' => $sectionName,
'panelName' => $panelName, 'panelSettings' => $subSectionSettings,
'panelSettings' => $panelSettings, ]);
]); $sectionContent[] = $panelHTML;
$sectionContent[] = $panelHTML; } else {
} else { foreach ($subSectionSettings as $panelName => $panelSettings) {
$sectionContent[] = ''; if (!empty($panelSettings)) {
$panelHTML = $appView->element('Settings/panel', [
'sectionName' => $sectionName,
'panelName' => $panelName,
'panelSettings' => $panelSettings,
]);
$sectionContent[] = $panelHTML;
} else {
$sectionContent[] = '';
}
} }
} }
$sectionContent[] = '</div>'; $sectionContent[] = '</div>';