Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions src/Commands/GetInteractiveMenus.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ public function grouping($navigation)
}
}

foreach ($new_navigation as $index => $item) {
$new_navigation[$index]['addons'] = count($new_navigation[$index]['addons']) < 2 ? array_first($new_navigation[$index]['addons'])['sections'] : $new_navigation[$index]['addons'];
foreach ($item['addons'] as $addon_key => $addon) {
if (count($addon['sections']) < 2)
{
$new_navigation[$index]['addons'][$addon_key] = array_first($addon['sections']);
$new_navigation[$index]['addons'][$addon_key]['title'] = $addon['title'];
}
}
}

return $new_navigation;
}

Expand All @@ -131,7 +142,7 @@ public function buildSection($module)

if (!$sections && class_exists($sections = get_class($module->getObject()) . 'Sections')) {

$cp = new ControlPanel(collect([]),new SectionCollection(),new ShortcutCollection(),new NavigationCollection());
$cp = new ControlPanel(collect([]), new SectionCollection(), new ShortcutCollection(), new NavigationCollection());

$builder = new ControlPanelBuilder($cp);
$builder->setSections([]);
Expand Down Expand Up @@ -282,10 +293,16 @@ function checkActive($navigation)
{
foreach ($navigation as $group_key => $group) {
foreach ($group['addons'] as $addon_key => $addon) {
foreach ($addon['sections'] as $section_key => $section) {
$is_active_section = (request()->url() === $section['href']) ? true : false;
$is_active = (!Str::contains(request()->url(), $section['href'])) ? false : true;
$navigation[$group_key]['addons'][$addon_key]['sections'][$section_key]['active'] = $is_active_section;
if (isset($group['addons'][$addon_key]['sections'])) {
foreach ($addon['sections'] as $section_key => $section) {
$is_active_section = (request()->url() === $section['href']) ? true : false;
$is_active = (!Str::contains(request()->url(), $section['href'])) ? false : true;
$navigation[$group_key]['addons'][$addon_key]['sections'][$section_key]['active'] = $is_active_section;
$navigation[$group_key]['addons'][$addon_key]['active'] = $navigation[$group_key]['addons'][$addon_key]['active'] ?: $is_active;
$navigation[$group_key]['active'] = $navigation[$group_key]['active'] ?: $is_active;
}
} else {
$is_active = (!Str::contains(request()->url(), $addon['href'])) ? false : true;
$navigation[$group_key]['addons'][$addon_key]['active'] = $navigation[$group_key]['addons'][$addon_key]['active'] ?: $is_active;
$navigation[$group_key]['active'] = $navigation[$group_key]['active'] ?: $is_active;
}
Expand Down