1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace Atk4\Ui\Layout;
6:
7: use Atk4\Ui\Js\Jquery;
8: use Atk4\Ui\Menu;
9: use Atk4\Ui\MenuItem;
10:
11: /**
12: * An Admin layout with enhanced left menu.
13: * This layout use jQuery plugin atk-sidenav.plugin.js
14: * Default value for this plugin is set for Maestro layout using maestro-sidenav.html template.
15: * Note that it is possible to change these default value if another template is use.
16: */
17: class Maestro extends Admin
18: {
19: /** @var string */
20: public $menuTemplate = 'layout/maestro-sidenav.html';
21:
22: #[\Override]
23: public function addMenuGroup($seed): Menu
24: {
25: $gr = $this->menuLeft->addGroup($seed, $this->menuTemplate)->addClass('atk-maestro-sidenav');
26: $gr->removeClass('item');
27:
28: return $gr;
29: }
30:
31: #[\Override]
32: public function addMenuItem($name, $action = null, $group = null): MenuItem
33: {
34: $i = parent::addMenuItem($name, $action, $group);
35: if (!$group) {
36: $i->addClass('atk-maestro-sidenav');
37: }
38:
39: return $i;
40: }
41:
42: #[\Override]
43: protected function renderView(): void
44: {
45: parent::renderView();
46:
47: // initialize all menu group at once
48: // since atkSideNav plugin default setting are for Maestro, no need to pass settings to initialize it
49: $js = (new Jquery('.atk-maestro-sidenav'))->atkSidenav();
50:
51: $this->js(true, $js);
52: }
53: }
54: