Skip to content

Commit a719f8f

Browse files
author
Muammer Top
authored
Merge pull request #10 from openclassify/vedatakdogan
update sidebar menu
2 parents 3ae1cef + 75dd101 commit a719f8f

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/Commands/GetInteractiveMenus.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ public function grouping($navigation)
120120
}
121121
}
122122

123+
foreach ($new_navigation as $index => $item) {
124+
$new_navigation[$index]['addons'] = count($new_navigation[$index]['addons']) < 2 ? array_first($new_navigation[$index]['addons'])['sections'] : $new_navigation[$index]['addons'];
125+
foreach ($item['addons'] as $addon_key => $addon) {
126+
if (count($addon['sections']) < 2)
127+
{
128+
$new_navigation[$index]['addons'][$addon_key] = array_first($addon['sections']);
129+
$new_navigation[$index]['addons'][$addon_key]['title'] = $addon['title'];
130+
}
131+
}
132+
}
133+
123134
return $new_navigation;
124135
}
125136

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

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

134-
$cp = new ControlPanel(collect([]),new SectionCollection(),new ShortcutCollection(),new NavigationCollection());
145+
$cp = new ControlPanel(collect([]), new SectionCollection(), new ShortcutCollection(), new NavigationCollection());
135146

136147
$builder = new ControlPanelBuilder($cp);
137148
$builder->setSections([]);
@@ -282,10 +293,16 @@ function checkActive($navigation)
282293
{
283294
foreach ($navigation as $group_key => $group) {
284295
foreach ($group['addons'] as $addon_key => $addon) {
285-
foreach ($addon['sections'] as $section_key => $section) {
286-
$is_active_section = (request()->url() === $section['href']) ? true : false;
287-
$is_active = (!Str::contains(request()->url(), $section['href'])) ? false : true;
288-
$navigation[$group_key]['addons'][$addon_key]['sections'][$section_key]['active'] = $is_active_section;
296+
if (isset($group['addons'][$addon_key]['sections'])) {
297+
foreach ($addon['sections'] as $section_key => $section) {
298+
$is_active_section = (request()->url() === $section['href']) ? true : false;
299+
$is_active = (!Str::contains(request()->url(), $section['href'])) ? false : true;
300+
$navigation[$group_key]['addons'][$addon_key]['sections'][$section_key]['active'] = $is_active_section;
301+
$navigation[$group_key]['addons'][$addon_key]['active'] = $navigation[$group_key]['addons'][$addon_key]['active'] ?: $is_active;
302+
$navigation[$group_key]['active'] = $navigation[$group_key]['active'] ?: $is_active;
303+
}
304+
} else {
305+
$is_active = (!Str::contains(request()->url(), $addon['href'])) ? false : true;
289306
$navigation[$group_key]['addons'][$addon_key]['active'] = $navigation[$group_key]['addons'][$addon_key]['active'] ?: $is_active;
290307
$navigation[$group_key]['active'] = $navigation[$group_key]['active'] ?: $is_active;
291308
}

0 commit comments

Comments
 (0)