|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Epesi\Base\Layout; |
|
4
|
|
|
|
|
5
|
|
|
use atk4\ui\jQuery; |
|
6
|
|
|
use Illuminate\Support\Arr; |
|
7
|
|
|
use Epesi\Core\Integration\ModuleView; |
|
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Implements a classic 100% width admin layout. |
|
11
|
|
|
* |
|
12
|
|
|
* Optional left menu in inverse with fixed width is most suitable for contextual navigation or |
|
13
|
|
|
* providing core object list (e.g. folders in mail) |
|
14
|
|
|
* |
|
15
|
|
|
* Another menu on the top for actions that can have a pull-down menus. |
|
16
|
|
|
* |
|
17
|
|
|
* A top-right spot is for user icon or personal menu, labels or stats. |
|
18
|
|
|
* |
|
19
|
|
|
* On top of the content there is automated title showing page title but can also work as a bread-crumb or container for buttons. |
|
20
|
|
|
* |
|
21
|
|
|
* Footer for a short copyright notice and perhaps some debug elements. |
|
22
|
|
|
* |
|
23
|
|
|
* Spots: |
|
24
|
|
|
* - LeftMenu (has_menuLeft) |
|
25
|
|
|
* - Menu |
|
26
|
|
|
* - RightMenu (has_menuRight) |
|
27
|
|
|
* - Footer |
|
28
|
|
|
* |
|
29
|
|
|
* - Content |
|
30
|
|
|
*/ |
|
31
|
|
|
class LayoutView extends ModuleView |
|
32
|
|
|
{ |
|
33
|
|
|
public $menuLeft; // vertical menu |
|
34
|
|
|
public $menu; // horizontal menu |
|
35
|
|
|
public $menuRight; // vertical pull-down |
|
36
|
|
|
public $actionBar; |
|
37
|
|
|
public $locationBar; |
|
38
|
|
|
|
|
39
|
|
|
public $burger = true; // burger menu item |
|
40
|
|
|
|
|
41
|
|
|
/* |
|
42
|
|
|
* Whether or not left Menu is visible on Page load. |
|
43
|
|
|
*/ |
|
44
|
|
|
public $isMenuLeftVisible = true; |
|
45
|
|
|
|
|
46
|
|
|
public $defaultTemplate = 'layout/admin.html'; |
|
47
|
|
|
|
|
48
|
|
|
protected $location; |
|
49
|
|
|
|
|
50
|
|
|
public function init() |
|
51
|
|
|
{ |
|
52
|
|
|
parent::init(); |
|
53
|
|
|
|
|
54
|
|
|
$this->setMenu(); |
|
55
|
|
|
$this->setActionBar(); |
|
56
|
|
|
|
|
57
|
|
|
// if (request()->pjax()) return; |
|
58
|
|
|
|
|
59
|
|
|
$this->setMenuLeft(); |
|
60
|
|
|
$this->setMenuRight(); |
|
61
|
|
|
|
|
62
|
|
|
$this->setVersion(); |
|
63
|
|
|
|
|
64
|
|
|
// $this->js(true, null, 'body')->niceScroll(); |
|
65
|
|
|
// $this->js(true, null, new jsExpression('window'))->on('pageshow', new jsFunction(['event'], [ |
|
66
|
|
|
// new jsExpression(' |
|
67
|
|
|
// if (event.originalEvent.persisted) { |
|
68
|
|
|
// window.location.reload(); |
|
69
|
|
|
// }')])); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function setMenu() |
|
73
|
|
|
{ |
|
74
|
|
|
if ($this->menu) return; |
|
75
|
|
|
|
|
76
|
|
|
//.ui.sidebar, |
|
77
|
|
|
$this->menu = $this->add(['Menu', 'atk-topMenu fixed horizontal', 'element' => 'header'], 'TopMenu'); |
|
78
|
|
|
|
|
79
|
|
|
$this->app->addStyle(''); |
|
80
|
|
|
|
|
81
|
|
|
// company logo |
|
82
|
|
|
$this->menu->add(['class' => ['epesi-logo']])->add(['Image', url('img/tsm_logo_agile.png')]); |
|
83
|
|
|
|
|
84
|
|
|
if ($this->burger) { |
|
85
|
|
|
/** @scrutinizer ignore-call */ |
|
86
|
|
|
$this->burger = $this->menu->addItem(['class' => ['icon atk-leftMenuTrigger']]); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
// home icon |
|
90
|
|
|
$this->menu->addItem(['class' => ['icon epesi-home']], url('view/dashboard'))->add(['Icon', 'home']); |
|
91
|
|
|
|
|
92
|
|
|
// location bar |
|
93
|
|
|
$this->locationBar = $this->menu->add(['View', ['ui' => 'epesi-location']]); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function setLocation($crumbs) |
|
97
|
|
|
{ |
|
98
|
|
|
$this->location = $crumbs; |
|
99
|
|
|
|
|
100
|
|
|
$crumb = $this->locationBar->add('BreadCrumb'); |
|
101
|
|
|
foreach ($crumbs as $level) { |
|
102
|
|
|
$label = $level['label']?? $level; |
|
103
|
|
|
$link = $level['link']?? null; |
|
104
|
|
|
|
|
105
|
|
|
$crumb->addCrumb($label, $link); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
$crumb->popTitle(); |
|
109
|
|
|
|
|
110
|
|
|
$this->app->title = implode(' > ', Arr::prepend($crumbs, config('epesi.app.title', 'EPESI'))); |
|
111
|
|
|
|
|
112
|
|
|
return $this; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
public function getLocation() |
|
116
|
|
|
{ |
|
117
|
|
|
return $this->location; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
public function setMenuRight() |
|
121
|
|
|
{ |
|
122
|
|
|
if ($this->menuRight) return; |
|
123
|
|
|
|
|
124
|
|
|
$this->menuRight = $this->menu->add(new Seeds\RightMenu([ |
|
125
|
|
|
'ui' => false |
|
126
|
|
|
]), 'RightMenu')->addClass('right menu')->removeClass('item'); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
public function setMenuLeft() |
|
130
|
|
|
{ |
|
131
|
|
|
if ($this->menuLeft) return; |
|
132
|
|
|
|
|
133
|
|
|
$this->menuLeft = $this->add(new Seeds\NavMenu('left vertical labeled sidebar'), 'LeftMenu'); |
|
134
|
|
|
|
|
135
|
|
|
if (! $this->burger) return; |
|
136
|
|
|
|
|
137
|
|
|
if (! session()->get('menu', 1)) { |
|
138
|
|
|
$this->isMenuLeftVisible = false; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
$this->burger->add(['Icon', 'content'])->on('click', [ |
|
142
|
|
|
(new jQuery('.ui.left.sidebar'))->toggleClass('visible'), |
|
|
|
|
|
|
143
|
|
|
(new jQuery('.epesi-logo'))->toggleClass('expanded'), |
|
144
|
|
|
(new jQuery('body'))->toggleClass('atk-leftMenu-visible'), |
|
145
|
|
|
$this->burger->add('jsCallback')->set(function($j, $visible) { |
|
146
|
|
|
session()->put('menu', $visible? 1: 0); |
|
147
|
|
|
session()->save(); |
|
148
|
|
|
}, [new \atk4\ui\jsExpression( '$("#' . $this->menuLeft->id . '").hasClass("visible")? 1: 0' )]) |
|
149
|
|
|
]); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
public function setActionBar() |
|
153
|
|
|
{ |
|
154
|
|
|
if ($this->actionBar) return; |
|
155
|
|
|
|
|
156
|
|
|
$this->actionBar = $this->add(new Seeds\ActionBar(), 'ActionBar'); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
public function setVersion() |
|
160
|
|
|
{ |
|
161
|
|
|
$this->template->trySet('version', $this->app->version); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* {@inheritdoc} |
|
166
|
|
|
*/ |
|
167
|
|
|
|
|
168
|
|
|
public function renderView() |
|
169
|
|
|
{ |
|
170
|
|
|
if ($this->menuLeft && $this->isMenuLeftVisible) { |
|
171
|
|
|
$this->menuLeft->addClass('visible'); |
|
172
|
|
|
} |
|
173
|
|
|
parent::renderView(); |
|
174
|
|
|
} |
|
175
|
|
|
} |
|
176
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths