From aa3d7ec75eaf27c48e6e32fc8aae0a6fe0e41cec Mon Sep 17 00:00:00 2001 From: mokaddem Date: Fri, 30 Jul 2021 14:50:10 +0200 Subject: [PATCH] chg: [setting] Nicer layout for nested settings --- templates/Instance/settings.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/templates/Instance/settings.php b/templates/Instance/settings.php index 1df0f1e..fb7c46b 100644 --- a/templates/Instance/settings.php +++ b/templates/Instance/settings.php @@ -92,7 +92,6 @@ function genSection($sectionName, $subSectionSettings, $appView) { $sectionContent = []; $sectionContent[] = '
'; - $sectionContent[] = sprintf('

%s

', getResolvableID($sectionName), h($sectionName)); if (isLeaf($subSectionSettings)) { $panelHTML = $appView->element('Settings/panel', [ 'sectionName' => $sectionName, @@ -101,6 +100,9 @@ function genSection($sectionName, $subSectionSettings, $appView) ]); $sectionContent[] = $panelHTML; } else { + if (count($subSectionSettings) > 1) { + $sectionContent[] = sprintf('

%s

', getResolvableID($sectionName), h($sectionName)); + } foreach ($subSectionSettings as $panelName => $panelSettings) { if (!empty($panelSettings)) { $panelHTML = $appView->element('Settings/panel', [ @@ -125,9 +127,9 @@ function isLeaf($setting) function getResolvableID($sectionName, $panelName=false) { - $id = sprintf('sp-%s', h($sectionName)); + $id = sprintf('sp-%s', preg_replace('/(\.|\W)/', '_', h($sectionName))); if (!empty($panelName)) { - $id .= '-' . preg_replace('/(\.|\s)/', '_', h($panelName)); + $id .= '-' . preg_replace('/(\.|\W)/', '_', h($panelName)); } return $id; }