chg: [layout:sidebar] Only show collapsible parents if they have children

pull/93/head
Sami Mokaddem 2022-02-23 10:19:16 +01:00
parent 64cb0f920a
commit f044bd8957
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 38 additions and 32 deletions

View File

@ -8,7 +8,7 @@
if (!empty($children)) {
$url = "#{$seed}";
} else {
$url = $parent['url'] ?? '#';
$url = $parent['url'] ?? false;
}
$controller = \Cake\Utility\Inflector::variable($this->request->getParam('controller'));
@ -59,38 +59,40 @@
?>
<li class="<?= !empty($children) ? 'parent collapsed' : '' ?>">
<a
class="d-flex align-items-center sidebar-link <?= !empty($children) ? 'collapsed' : '' ?> <?= $active ? 'active' : '' ?> <?= $hasActiveChild ? 'have-active-child' : '' ?>"
href="<?= h($url) ?>"
<?= !empty($children) ? 'data-bs-toggle="collapse"' : '' ?>
<?= $hasActiveChild ? 'aria-expanded="true"' : '' ?>
>
<i class="position-relative sidebar-icon <?= $this->FontAwesome->getClass($icon) ?>">
<?php
if ($childHasNotification || ($hasNotification && !empty($children))) {
echo $this->Bootstrap->notificationBubble([
'variant' => $childHasNotification ? $childNotificationVariant : $notificationVariant,
<?php if (!empty($children) || !empty($url)): ?>
<a
class="d-flex align-items-center sidebar-link <?= !empty($children) ? 'collapsed' : '' ?> <?= $active ? 'active' : '' ?> <?= $hasActiveChild ? 'have-active-child' : '' ?>"
href="<?= h($url) ?>"
<?= !empty($children) ? 'data-bs-toggle="collapse"' : '' ?>
<?= $hasActiveChild ? 'aria-expanded="true"' : '' ?>
>
<i class="position-relative sidebar-icon <?= $this->FontAwesome->getClass($icon) ?>">
<?php
if ($childHasNotification || ($hasNotification && !empty($children))) {
echo $this->Bootstrap->notificationBubble([
'variant' => $childHasNotification ? $childNotificationVariant : $notificationVariant,
]);
}
?>
</i>
<span class="text"><?= h($label) ?></span>
<?php
if (empty($children) && $hasNotification) {
echo $this->Bootstrap->badge([
'text' => $notificationAmount,
'class' => 'ms-auto',
'variant' => $notificationVariant,
]);
}
?>
</a>
<?php if (!empty($children)): ?>
<?= $this->element('layouts/sidebar/sub-menu', [
'seed' => $seed,
'children' => $children,
'open' => $hasActiveChild,
]);
}
?>
</i>
<span class="text"><?= h($label) ?></span>
<?php
if (empty($children) && $hasNotification) {
echo $this->Bootstrap->badge([
'text' => $notificationAmount,
'class' => 'ms-auto',
'variant' => $notificationVariant,
]);
}
?>
</a>
<?php if (!empty($children)): ?>
<?= $this->element('layouts/sidebar/sub-menu', [
'seed' => $seed,
'children' => $children,
'open' => $hasActiveChild,
]);
?>
<?php endif; ?>
<?php endif; ?>
</li>

View File

@ -328,6 +328,10 @@ ul.sidebar-elements > li > a.sidebar-link > * {
vertical-align: middle;
}
ul.sidebar-elements li.parent .sub-menu > li > a.sidebar-link > i.sidebar-icon {
margin-right: 8px;
}
ul.sidebar-elements > li > a.sidebar-link > i.sidebar-icon {
margin-right: 10px;
font-size: 19px;