chg: [layout:sidebar] Only show collapsible parents if they have children
parent
64cb0f920a
commit
f044bd8957
|
@ -8,7 +8,7 @@
|
||||||
if (!empty($children)) {
|
if (!empty($children)) {
|
||||||
$url = "#{$seed}";
|
$url = "#{$seed}";
|
||||||
} else {
|
} else {
|
||||||
$url = $parent['url'] ?? '#';
|
$url = $parent['url'] ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$controller = \Cake\Utility\Inflector::variable($this->request->getParam('controller'));
|
$controller = \Cake\Utility\Inflector::variable($this->request->getParam('controller'));
|
||||||
|
@ -59,38 +59,40 @@
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<li class="<?= !empty($children) ? 'parent collapsed' : '' ?>">
|
<li class="<?= !empty($children) ? 'parent collapsed' : '' ?>">
|
||||||
<a
|
<?php if (!empty($children) || !empty($url)): ?>
|
||||||
class="d-flex align-items-center sidebar-link <?= !empty($children) ? 'collapsed' : '' ?> <?= $active ? 'active' : '' ?> <?= $hasActiveChild ? 'have-active-child' : '' ?>"
|
<a
|
||||||
href="<?= h($url) ?>"
|
class="d-flex align-items-center sidebar-link <?= !empty($children) ? 'collapsed' : '' ?> <?= $active ? 'active' : '' ?> <?= $hasActiveChild ? 'have-active-child' : '' ?>"
|
||||||
<?= !empty($children) ? 'data-bs-toggle="collapse"' : '' ?>
|
href="<?= h($url) ?>"
|
||||||
<?= $hasActiveChild ? 'aria-expanded="true"' : '' ?>
|
<?= !empty($children) ? 'data-bs-toggle="collapse"' : '' ?>
|
||||||
>
|
<?= $hasActiveChild ? 'aria-expanded="true"' : '' ?>
|
||||||
<i class="position-relative sidebar-icon <?= $this->FontAwesome->getClass($icon) ?>">
|
>
|
||||||
<?php
|
<i class="position-relative sidebar-icon <?= $this->FontAwesome->getClass($icon) ?>">
|
||||||
if ($childHasNotification || ($hasNotification && !empty($children))) {
|
<?php
|
||||||
echo $this->Bootstrap->notificationBubble([
|
if ($childHasNotification || ($hasNotification && !empty($children))) {
|
||||||
'variant' => $childHasNotification ? $childNotificationVariant : $notificationVariant,
|
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>
|
<?php endif; ?>
|
||||||
<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>
|
</li>
|
||||||
|
|
|
@ -328,6 +328,10 @@ ul.sidebar-elements > li > a.sidebar-link > * {
|
||||||
vertical-align: middle;
|
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 {
|
ul.sidebar-elements > li > a.sidebar-link > i.sidebar-icon {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
font-size: 19px;
|
font-size: 19px;
|
||||||
|
|
Loading…
Reference in New Issue