@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | public function __construct($parent) |
| 15 | 15 | { |
| 16 | - $this->parent = $parent; |
|
| 16 | + $this->parent = $parent; |
|
| 17 | 17 | |
| 18 | 18 | parent::__construct('$(this).atkCreateModal([arg])', [ |
| 19 | 19 | 'arg' => [ |
@@ -25,29 +25,29 @@ discard block |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | protected function getURL() |
| 28 | - { |
|
| 29 | - return $this->parent->add('VirtualPage')->set(Closure::fromCallable([$this, 'getContents']))->getJSURL('cut'); |
|
| 30 | - } |
|
| 28 | + { |
|
| 29 | + return $this->parent->add('VirtualPage')->set(Closure::fromCallable([$this, 'getContents']))->getJSURL('cut'); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - protected function getContents(VirtualPage $vp) |
|
| 33 | - { |
|
| 34 | - $vp->add([ |
|
| 35 | - new LaunchButton([ |
|
| 36 | - 'label' => 'Test Button 1', |
|
| 37 | - 'icon' => 'user' |
|
| 38 | - ]) |
|
| 39 | - ])->link(URL::to('/')); |
|
| 40 | - $vp->add([ |
|
| 41 | - new LaunchButton([ |
|
| 42 | - 'label' => 'Test Button 2', |
|
| 43 | - 'icon' => 'car' |
|
| 44 | - ]) |
|
| 45 | - ]); |
|
| 46 | - $vp->add([ |
|
| 47 | - new LaunchButton([ |
|
| 48 | - 'label' => 'Test Button 3', |
|
| 49 | - 'icon' => 'bus' |
|
| 50 | - ]) |
|
| 51 | - ]); |
|
| 52 | - } |
|
| 32 | + protected function getContents(VirtualPage $vp) |
|
| 33 | + { |
|
| 34 | + $vp->add([ |
|
| 35 | + new LaunchButton([ |
|
| 36 | + 'label' => 'Test Button 1', |
|
| 37 | + 'icon' => 'user' |
|
| 38 | + ]) |
|
| 39 | + ])->link(URL::to('/')); |
|
| 40 | + $vp->add([ |
|
| 41 | + new LaunchButton([ |
|
| 42 | + 'label' => 'Test Button 2', |
|
| 43 | + 'icon' => 'car' |
|
| 44 | + ]) |
|
| 45 | + ]); |
|
| 46 | + $vp->add([ |
|
| 47 | + new LaunchButton([ |
|
| 48 | + 'label' => 'Test Button 3', |
|
| 49 | + 'icon' => 'bus' |
|
| 50 | + ]) |
|
| 51 | + ]); |
|
| 52 | + } |
|
| 53 | 53 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class ActionBar extends Menu |
| 9 | 9 | { |
| 10 | - public $ui = 'actionbar menu'; |
|
| 10 | + public $ui = 'actionbar menu'; |
|
| 11 | 11 | |
| 12 | 12 | protected static $buttons = []; |
| 13 | 13 | |
@@ -46,12 +46,12 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public function renderView() |
| 49 | - { |
|
| 50 | - $this->elements = collect($this->elements)->sortByDesc(function ($element) { |
|
| 51 | - return $element->weight ?? 10; |
|
| 52 | - })->toArray(); |
|
| 49 | + { |
|
| 50 | + $this->elements = collect($this->elements)->sortByDesc(function ($element) { |
|
| 51 | + return $element->weight ?? 10; |
|
| 52 | + })->toArray(); |
|
| 53 | 53 | |
| 54 | - return parent::renderView(); |
|
| 54 | + return parent::renderView(); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | public static function addMenuButton($menu) |
| 83 | 83 | { |
| 84 | - return self::instance()->addMenu($menu); |
|
| 84 | + return self::instance()->addMenu($menu); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public static function clear() |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | public function renderView() |
| 49 | 49 | { |
| 50 | - $this->elements = collect($this->elements)->sortByDesc(function ($element) { |
|
| 50 | + $this->elements = collect($this->elements)->sortByDesc(function($element) { |
|
| 51 | 51 | return $element->weight ?? 10; |
| 52 | 52 | })->toArray(); |
| 53 | 53 | |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public static function addItemButton($button, $defaults = []) |
| 65 | 65 | { |
| 66 | - $button = is_string($button)? self::getPredefined($button): $button; |
|
| 66 | + $button = is_string($button) ? self::getPredefined($button) : $button; |
|
| 67 | 67 | |
| 68 | - $button = is_array($button)? new ActionBarItem($button): $button; |
|
| 68 | + $button = is_array($button) ? new ActionBarItem($button) : $button; |
|
| 69 | 69 | |
| 70 | 70 | $actionBar = self::instance(); |
| 71 | 71 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class NavMenu extends BaseMenu |
| 10 | 10 | { |
| 11 | - public $ui = 'inverted nav menu'; |
|
| 11 | + public $ui = 'inverted nav menu'; |
|
| 12 | 12 | |
| 13 | 13 | public function init() |
| 14 | 14 | { |
@@ -58,12 +58,12 @@ discard block |
||
| 58 | 58 | self::addItems($submenu, collect($subitems)); |
| 59 | 59 | } |
| 60 | 60 | elseif ($subitems = $entry['group'] ?? []) { |
| 61 | - $subgroup = $menu->addGroup($entry['item']); |
|
| 61 | + $subgroup = $menu->addGroup($entry['item']); |
|
| 62 | 62 | |
| 63 | 63 | self::addItems($subgroup, collect($subitems)); |
| 64 | 64 | } |
| 65 | 65 | else { |
| 66 | - $menu->addItem($entry['item'], $entry['action'] ?? ''); |
|
| 66 | + $menu->addItem($entry['item'], $entry['action'] ?? ''); |
|
| 67 | 67 | } |
| 68 | 68 | }); |
| 69 | 69 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | $this->addHeader($this->app->title); |
| 18 | 18 | |
| 19 | 19 | $items = collect(); |
| 20 | - foreach(NavMenuJoint::collect() as $joint) { |
|
| 20 | + foreach (NavMenuJoint::collect() as $joint) { |
|
| 21 | 21 | $items = $items->merge($joint->items()); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -34,13 +34,13 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | public static function addItems($menu, Collection $items) |
| 36 | 36 | { |
| 37 | - $items->sort(function ($entry1, $entry2) { |
|
| 37 | + $items->sort(function($entry1, $entry2) { |
|
| 38 | 38 | $weight1 = $entry1['weight']?? 10; |
| 39 | 39 | $weight2 = $entry2['weight']?? 10; |
| 40 | 40 | |
| 41 | 41 | return $weight1 <=> $weight2; |
| 42 | 42 | })->map(function($entry, $caption) use ($menu) { |
| 43 | - if (! ($entry['access'] ?? true)) return; |
|
| 43 | + if (!($entry['access'] ?? true)) return; |
|
| 44 | 44 | |
| 45 | 45 | if (!is_array($entry)) { |
| 46 | 46 | $entry = ['action' => $entry]; |
@@ -41,7 +41,9 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | return $weight1 <=> $weight2; |
| 43 | 43 | })->map(function($entry, $caption) use ($menu) { |
| 44 | - if (! ($entry['access'] ?? true)) return; |
|
| 44 | + if (! ($entry['access'] ?? true)) { |
|
| 45 | + return; |
|
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | if (!is_array($entry)) { |
| 47 | 49 | $entry = ['action' => $entry]; |
@@ -60,13 +62,11 @@ discard block |
||
| 60 | 62 | // $submenu->js = ['transition' => 'swing left', 'on' => 'click']; |
| 61 | 63 | |
| 62 | 64 | self::addItems($submenu, collect($subitems)); |
| 63 | - } |
|
| 64 | - elseif ($subitems = $entry['group'] ?? []) { |
|
| 65 | + } elseif ($subitems = $entry['group'] ?? []) { |
|
| 65 | 66 | $subgroup = $menu->addGroup($entry['item']); |
| 66 | 67 | |
| 67 | 68 | self::addItems($subgroup, collect($subitems)); |
| 68 | - } |
|
| 69 | - else { |
|
| 69 | + } else { |
|
| 70 | 70 | $menu->addItem($entry['item'], $entry['action'] ?? ''); |
| 71 | 71 | } |
| 72 | 72 | }); |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | 'icon' => 'th' |
| 40 | 40 | ], new LaunchPad($this)); |
| 41 | 41 | |
| 42 | - foreach(UserMenuJoint::collect() as $joint) { |
|
| 43 | - foreach ($joint->tools()?: [] as $tool) { |
|
| 42 | + foreach (UserMenuJoint::collect() as $joint) { |
|
| 43 | + foreach ($joint->tools() ?: [] as $tool) { |
|
| 44 | 44 | $this->addTool($tool); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - foreach ($joint->entries()?: [] as $entry) { |
|
| 47 | + foreach ($joint->entries() ?: [] as $entry) { |
|
| 48 | 48 | $this->addEntry($entry); |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | 'item' => ['Logout', 'icon' => 'sign out', 'attr' => ['onclick' => "event.preventDefault();$('#logout-form').submit();"]], |
| 63 | 63 | 'action' => url('logout'), |
| 64 | 64 | 'group' => '10000:user', |
| 65 | - 'callback' => function ($item){ |
|
| 65 | + 'callback' => function($item) { |
|
| 66 | 66 | $logoutForm = $item->add(['View', 'attr' => ['method' => 'POST', 'action' => url('logout')]])->setElement('form')->addStyle(['display' => 'none']); |
| 67 | 67 | $logoutForm->id = 'logout-form'; |
| 68 | 68 | $logoutForm->add(['View', 'attr' => ['type' => 'hidden', 'name' => '_token', 'value' => csrf_token()]])->setElement('input'); |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public function getUserMenuLabel() |
| 81 | 81 | { |
| 82 | - return $this->userMenuLabel?: Auth::user()->name; |
|
| 82 | + return $this->userMenuLabel ?: Auth::user()->name; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | public function addEntry($entry) |
| 86 | 86 | { |
| 87 | 87 | $entry = collect(array_merge(['item' => $entry, 'group' => '00500:general', 'weight' => 10], $entry)); |
| 88 | 88 | |
| 89 | - if (! $entry->get('item')) return; |
|
| 89 | + if (!$entry->get('item')) return; |
|
| 90 | 90 | |
| 91 | 91 | $this->entries->add($entry); |
| 92 | 92 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | $item = $this->userMenu->addItem($entry['item'], $entry->get('action')); |
| 116 | 116 | |
| 117 | - if (! $callback = $entry->get('callback')) continue; |
|
| 117 | + if (!$callback = $entry->get('callback')) continue; |
|
| 118 | 118 | |
| 119 | 119 | $callback($item); |
| 120 | 120 | } |
@@ -73,7 +73,9 @@ discard block |
||
| 73 | 73 | { |
| 74 | 74 | $entry = collect(array_merge(['item' => $entry, 'group' => '00500:general', 'weight' => 10], $entry)); |
| 75 | 75 | |
| 76 | - if (! $entry->get('item')) return; |
|
| 76 | + if (! $entry->get('item')) { |
|
| 77 | + return; |
|
| 78 | + } |
|
| 77 | 79 | |
| 78 | 80 | $this->entries->add($entry); |
| 79 | 81 | } |
@@ -94,14 +96,18 @@ discard block |
||
| 94 | 96 | { |
| 95 | 97 | $empty = true; |
| 96 | 98 | foreach ($this->entries->groupBy('group')->sortKeys() as $group) { |
| 97 | - if (!$empty) $this->userMenu->addDivider(); |
|
| 99 | + if (!$empty) { |
|
| 100 | + $this->userMenu->addDivider(); |
|
| 101 | + } |
|
| 98 | 102 | |
| 99 | 103 | foreach ($group->sortBy('weight') as $entry) { |
| 100 | 104 | $empty = false; |
| 101 | 105 | |
| 102 | 106 | $item = $this->userMenu->addItem($entry['item'], $entry->get('action')); |
| 103 | 107 | |
| 104 | - if (! $callback = $entry->get('callback')) continue; |
|
| 108 | + if (! $callback = $entry->get('callback')) { |
|
| 109 | + continue; |
|
| 110 | + } |
|
| 105 | 111 | |
| 106 | 112 | $callback($item); |
| 107 | 113 | } |
@@ -7,40 +7,40 @@ |
||
| 7 | 7 | |
| 8 | 8 | class ActionBarItem extends Item |
| 9 | 9 | { |
| 10 | - public $weight = 10; |
|
| 10 | + public $weight = 10; |
|
| 11 | 11 | |
| 12 | - public $callback; |
|
| 12 | + public $callback; |
|
| 13 | 13 | |
| 14 | - public $hint; |
|
| 14 | + public $hint; |
|
| 15 | 15 | |
| 16 | - public function renderView() |
|
| 17 | - { |
|
| 18 | - $this->addCallback(); |
|
| 16 | + public function renderView() |
|
| 17 | + { |
|
| 18 | + $this->addCallback(); |
|
| 19 | 19 | |
| 20 | - if ($this->hint) { |
|
| 21 | - $this->attr['title'] = $this->hint; |
|
| 22 | - } |
|
| 20 | + if ($this->hint) { |
|
| 21 | + $this->attr['title'] = $this->hint; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - parent::renderView(); |
|
| 25 | - } |
|
| 24 | + parent::renderView(); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - public function callback($callable) |
|
| 28 | - { |
|
| 29 | - $this->callback = $callable; |
|
| 27 | + public function callback($callable) |
|
| 28 | + { |
|
| 29 | + $this->callback = $callable; |
|
| 30 | 30 | |
| 31 | - return $this; |
|
| 32 | - } |
|
| 31 | + return $this; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - public function addCallback() |
|
| 35 | - { |
|
| 36 | - if (is_callable($callable = $this->callback)) { |
|
| 37 | - $callable = $this->add('jsCallback')->set($callable); |
|
| 38 | - } |
|
| 34 | + public function addCallback() |
|
| 35 | + { |
|
| 36 | + if (is_callable($callable = $this->callback)) { |
|
| 37 | + $callable = $this->add('jsCallback')->set($callable); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - if ($callable instanceof jsCallback) { |
|
| 41 | - $this->on('click', $callable); |
|
| 42 | - } |
|
| 40 | + if ($callable instanceof jsCallback) { |
|
| 41 | + $this->on('click', $callable); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - return $this; |
|
| 45 | - } |
|
| 44 | + return $this; |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -30,36 +30,36 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | class LayoutView extends ModuleView |
| 32 | 32 | { |
| 33 | - public $menuLeft; // vertical menu |
|
| 34 | - public $menu; // horizontal menu |
|
| 35 | - public $menuRight; // vertical pull-down |
|
| 36 | - public $actionBar; |
|
| 37 | - public $locationBar; |
|
| 33 | + public $menuLeft; // vertical menu |
|
| 34 | + public $menu; // horizontal menu |
|
| 35 | + public $menuRight; // vertical pull-down |
|
| 36 | + public $actionBar; |
|
| 37 | + public $locationBar; |
|
| 38 | 38 | |
| 39 | - public $burger = true; // burger menu item |
|
| 39 | + public $burger = true; // burger menu item |
|
| 40 | 40 | |
| 41 | - /* |
|
| 41 | + /* |
|
| 42 | 42 | * Whether or not left Menu is visible on Page load. |
| 43 | 43 | */ |
| 44 | - public $isMenuLeftVisible = true; |
|
| 44 | + public $isMenuLeftVisible = true; |
|
| 45 | 45 | |
| 46 | - public $defaultTemplate = 'layout/admin.html'; |
|
| 46 | + public $defaultTemplate = 'layout/admin.html'; |
|
| 47 | 47 | |
| 48 | - protected $location; |
|
| 48 | + protected $location; |
|
| 49 | 49 | |
| 50 | - public function init() |
|
| 51 | - { |
|
| 52 | - parent::init(); |
|
| 50 | + public function init() |
|
| 51 | + { |
|
| 52 | + parent::init(); |
|
| 53 | 53 | |
| 54 | - $this->setMenu(); |
|
| 55 | - $this->setActionBar(); |
|
| 54 | + $this->setMenu(); |
|
| 55 | + $this->setActionBar(); |
|
| 56 | 56 | |
| 57 | 57 | // if (request()->pjax()) return; |
| 58 | 58 | |
| 59 | - $this->setMenuLeft(); |
|
| 60 | - $this->setMenuRight(); |
|
| 59 | + $this->setMenuLeft(); |
|
| 60 | + $this->setMenuRight(); |
|
| 61 | 61 | |
| 62 | - $this->setVersion(); |
|
| 62 | + $this->setVersion(); |
|
| 63 | 63 | |
| 64 | 64 | // $this->js(true, null, 'body')->niceScroll(); |
| 65 | 65 | |
@@ -68,26 +68,26 @@ discard block |
||
| 68 | 68 | // if (event.originalEvent.persisted) { |
| 69 | 69 | // window.location.reload(); |
| 70 | 70 | // }')])); |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - public function setMenu() |
|
| 74 | - { |
|
| 75 | - if ($this->menu) return; |
|
| 73 | + public function setMenu() |
|
| 74 | + { |
|
| 75 | + if ($this->menu) return; |
|
| 76 | 76 | |
| 77 | - $this->menu = $this->add(['Menu', 'atk-topMenu fixed horizontal', 'element' => 'header'], 'TopMenu'); |
|
| 77 | + $this->menu = $this->add(['Menu', 'atk-topMenu fixed horizontal', 'element' => 'header'], 'TopMenu'); |
|
| 78 | 78 | |
| 79 | - // company logo |
|
| 80 | - // see \Epesi\Core\Controller::logo |
|
| 81 | - $this->menu->add(['class' => ['epesi-logo'], 'style' => ['width' => '167px']])->add(['Image', url('logo')])->setStyle(['max-height' => '32px']); |
|
| 79 | + // company logo |
|
| 80 | + // see \Epesi\Core\Controller::logo |
|
| 81 | + $this->menu->add(['class' => ['epesi-logo'], 'style' => ['width' => '167px']])->add(['Image', url('logo')])->setStyle(['max-height' => '32px']); |
|
| 82 | 82 | |
| 83 | - if ($this->burger) { |
|
| 84 | - /** @scrutinizer ignore-call */ |
|
| 85 | - $this->burger = $this->menu->addItem(['class' => ['icon atk-leftMenuTrigger']]); |
|
| 86 | - } |
|
| 83 | + if ($this->burger) { |
|
| 84 | + /** @scrutinizer ignore-call */ |
|
| 85 | + $this->burger = $this->menu->addItem(['class' => ['icon atk-leftMenuTrigger']]); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | // home icon redirects to /home path |
| 89 | 89 | // see \Epesi\Core\Controller::home |
| 90 | - $this->menu->addItem(['class' => ['icon epesi-home']], url('home'))->add(['Icon', 'home']); |
|
| 90 | + $this->menu->addItem(['class' => ['icon epesi-home']], url('home'))->add(['Icon', 'home']); |
|
| 91 | 91 | |
| 92 | 92 | // location bar |
| 93 | 93 | $this->locationBar = $this->menu->add(['View', ['ui' => 'epesi-location']]); |
@@ -130,50 +130,50 @@ discard block |
||
| 130 | 130 | ]), 'RightMenu')->addClass('right menu')->removeClass('item'); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - public function setMenuLeft() |
|
| 134 | - { |
|
| 135 | - if ($this->menuLeft) return; |
|
| 133 | + public function setMenuLeft() |
|
| 134 | + { |
|
| 135 | + if ($this->menuLeft) return; |
|
| 136 | 136 | |
| 137 | - $this->menuLeft = $this->add(new View\NavMenu('left vertical labeled sidebar'), 'LeftMenu'); |
|
| 137 | + $this->menuLeft = $this->add(new View\NavMenu('left vertical labeled sidebar'), 'LeftMenu'); |
|
| 138 | 138 | |
| 139 | - if (! $this->burger) return; |
|
| 139 | + if (! $this->burger) return; |
|
| 140 | 140 | |
| 141 | - if (! session()->get('menu', 1)) { |
|
| 142 | - $this->isMenuLeftVisible = false; |
|
| 143 | - } |
|
| 141 | + if (! session()->get('menu', 1)) { |
|
| 142 | + $this->isMenuLeftVisible = false; |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - $this->burger->add(['Icon', 'content'])->on('click', [ |
|
| 146 | - (new jQuery('.ui.left.sidebar'))->toggleClass('visible'), |
|
| 147 | - (new jQuery('.epesi-logo'))->toggleClass('expanded'), |
|
| 148 | - (new jQuery('body'))->toggleClass('atk-leftMenu-visible'), |
|
| 149 | - $this->burger->add('jsCallback')->set(function($j, $visible) { |
|
| 150 | - session()->put('menu', $visible? 1: 0); |
|
| 151 | - session()->save(); |
|
| 152 | - }, [new \atk4\ui\jsExpression( '$("#' . $this->menuLeft->id . '").hasClass("visible")? 1: 0' )]) |
|
| 153 | - ]); |
|
| 154 | - } |
|
| 145 | + $this->burger->add(['Icon', 'content'])->on('click', [ |
|
| 146 | + (new jQuery('.ui.left.sidebar'))->toggleClass('visible'), |
|
| 147 | + (new jQuery('.epesi-logo'))->toggleClass('expanded'), |
|
| 148 | + (new jQuery('body'))->toggleClass('atk-leftMenu-visible'), |
|
| 149 | + $this->burger->add('jsCallback')->set(function($j, $visible) { |
|
| 150 | + session()->put('menu', $visible? 1: 0); |
|
| 151 | + session()->save(); |
|
| 152 | + }, [new \atk4\ui\jsExpression( '$("#' . $this->menuLeft->id . '").hasClass("visible")? 1: 0' )]) |
|
| 153 | + ]); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - public function setActionBar() |
|
| 157 | - { |
|
| 158 | - if ($this->actionBar) return; |
|
| 156 | + public function setActionBar() |
|
| 157 | + { |
|
| 158 | + if ($this->actionBar) return; |
|
| 159 | 159 | |
| 160 | - $this->actionBar = $this->add(View\ActionBar::class, 'ActionBar'); |
|
| 161 | - } |
|
| 160 | + $this->actionBar = $this->add(View\ActionBar::class, 'ActionBar'); |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - public function setVersion() |
|
| 164 | - { |
|
| 165 | - $this->template->trySet('version', $this->app->version); |
|
| 166 | - } |
|
| 163 | + public function setVersion() |
|
| 164 | + { |
|
| 165 | + $this->template->trySet('version', $this->app->version); |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * {@inheritdoc} |
|
| 170 | - */ |
|
| 168 | + /** |
|
| 169 | + * {@inheritdoc} |
|
| 170 | + */ |
|
| 171 | 171 | |
| 172 | - public function renderView() |
|
| 173 | - { |
|
| 174 | - if ($this->menuLeft && $this->isMenuLeftVisible) { |
|
| 175 | - $this->menuLeft->addClass('visible'); |
|
| 176 | - } |
|
| 177 | - parent::renderView(); |
|
| 178 | - } |
|
| 172 | + public function renderView() |
|
| 173 | + { |
|
| 174 | + if ($this->menuLeft && $this->isMenuLeftVisible) { |
|
| 175 | + $this->menuLeft->addClass('visible'); |
|
| 176 | + } |
|
| 177 | + parent::renderView(); |
|
| 178 | + } |
|
| 179 | 179 | } |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | class LayoutView extends ModuleView |
| 32 | 32 | { |
| 33 | - public $menuLeft; // vertical menu |
|
| 34 | - public $menu; // horizontal menu |
|
| 35 | - public $menuRight; // vertical pull-down |
|
| 33 | + public $menuLeft; // vertical menu |
|
| 34 | + public $menu; // horizontal menu |
|
| 35 | + public $menuRight; // vertical pull-down |
|
| 36 | 36 | public $actionBar; |
| 37 | 37 | public $locationBar; |
| 38 | 38 | |
| 39 | - public $burger = true; // burger menu item |
|
| 39 | + public $burger = true; // burger menu item |
|
| 40 | 40 | |
| 41 | 41 | /* |
| 42 | 42 | * Whether or not left Menu is visible on Page load. |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $this->menu->addItem(['class' => ['icon epesi-home']], url('home'))->add(['Icon', 'home']); |
| 91 | 91 | |
| 92 | 92 | // location bar |
| 93 | - $this->locationBar = $this->menu->add(['View', ['ui' => 'epesi-location']]); |
|
| 93 | + $this->locationBar = $this->menu->add(['View', ['ui' => 'epesi-location']]); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | public function setLocation($crumbs) |
@@ -136,20 +136,20 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | $this->menuLeft = $this->add(new View\NavMenu('left vertical labeled sidebar'), 'LeftMenu'); |
| 138 | 138 | |
| 139 | - if (! $this->burger) return; |
|
| 139 | + if (!$this->burger) return; |
|
| 140 | 140 | |
| 141 | - if (! session()->get('menu', 1)) { |
|
| 141 | + if (!session()->get('menu', 1)) { |
|
| 142 | 142 | $this->isMenuLeftVisible = false; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $this->burger->add(['Icon', 'content'])->on('click', [ |
|
| 145 | + $this->burger->add(['Icon', 'content'])->on('click', [ |
|
| 146 | 146 | (new jQuery('.ui.left.sidebar'))->toggleClass('visible'), |
| 147 | 147 | (new jQuery('.epesi-logo'))->toggleClass('expanded'), |
| 148 | 148 | (new jQuery('body'))->toggleClass('atk-leftMenu-visible'), |
| 149 | 149 | $this->burger->add('jsCallback')->set(function($j, $visible) { |
| 150 | - session()->put('menu', $visible? 1: 0); |
|
| 150 | + session()->put('menu', $visible ? 1 : 0); |
|
| 151 | 151 | session()->save(); |
| 152 | - }, [new \atk4\ui\jsExpression( '$("#' . $this->menuLeft->id . '").hasClass("visible")? 1: 0' )]) |
|
| 152 | + }, [new \atk4\ui\jsExpression('$("#' . $this->menuLeft->id . '").hasClass("visible")? 1: 0')]) |
|
| 153 | 153 | ]); |
| 154 | 154 | } |
| 155 | 155 | |
@@ -72,7 +72,9 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | public function setMenu() |
| 74 | 74 | { |
| 75 | - if ($this->menu) return; |
|
| 75 | + if ($this->menu) { |
|
| 76 | + return; |
|
| 77 | + } |
|
| 76 | 78 | |
| 77 | 79 | $this->menu = $this->add(['Menu', 'atk-topMenu fixed horizontal', 'element' => 'header'], 'TopMenu'); |
| 78 | 80 | |
@@ -123,7 +125,9 @@ discard block |
||
| 123 | 125 | |
| 124 | 126 | public function setMenuRight() |
| 125 | 127 | { |
| 126 | - if ($this->menuRight) return; |
|
| 128 | + if ($this->menuRight) { |
|
| 129 | + return; |
|
| 130 | + } |
|
| 127 | 131 | |
| 128 | 132 | $this->menuRight = $this->menu->add(new View\RightMenu([ |
| 129 | 133 | 'ui' => false |
@@ -132,11 +136,15 @@ discard block |
||
| 132 | 136 | |
| 133 | 137 | public function setMenuLeft() |
| 134 | 138 | { |
| 135 | - if ($this->menuLeft) return; |
|
| 139 | + if ($this->menuLeft) { |
|
| 140 | + return; |
|
| 141 | + } |
|
| 136 | 142 | |
| 137 | 143 | $this->menuLeft = $this->add(new View\NavMenu('left vertical labeled sidebar'), 'LeftMenu'); |
| 138 | 144 | |
| 139 | - if (! $this->burger) return; |
|
| 145 | + if (! $this->burger) { |
|
| 146 | + return; |
|
| 147 | + } |
|
| 140 | 148 | |
| 141 | 149 | if (! session()->get('menu', 1)) { |
| 142 | 150 | $this->isMenuLeftVisible = false; |
@@ -155,7 +163,9 @@ discard block |
||
| 155 | 163 | |
| 156 | 164 | public function setActionBar() |
| 157 | 165 | { |
| 158 | - if ($this->actionBar) return; |
|
| 166 | + if ($this->actionBar) { |
|
| 167 | + return; |
|
| 168 | + } |
|
| 159 | 169 | |
| 160 | 170 | $this->actionBar = $this->add(View\ActionBar::class, 'ActionBar'); |
| 161 | 171 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | protected $validationRules = []; |
| 18 | 18 | |
| 19 | 19 | public function addElements($elements, $parent = null) { |
| 20 | - $parent = $parent?: $this; |
|
| 20 | + $parent = $parent ?: $this; |
|
| 21 | 21 | |
| 22 | 22 | foreach ($elements as $name => $desc) { |
| 23 | 23 | $name = $desc['name']?? $name; |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | switch ($desc['type']?? 'field') { |
| 28 | 28 | case 'field': |
| 29 | - $desc = is_string($desc)? [ |
|
| 29 | + $desc = is_string($desc) ? [ |
|
| 30 | 30 | 'decorator' => [$desc] |
| 31 | - ]: $desc; |
|
| 31 | + ] : $desc; |
|
| 32 | 32 | |
| 33 | 33 | $field = $parent->addField($name, $desc['decorator']?? [], $desc['options']?? []); |
| 34 | 34 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | public function addFieldsDisplayRules($fieldsDisplayRules) { |
| 80 | - $this->setFieldsDisplayRules(array_merge($this->fieldsDisplayRules?: [], $fieldsDisplayRules)); |
|
| 80 | + $this->setFieldsDisplayRules(array_merge($this->fieldsDisplayRules ?: [], $fieldsDisplayRules)); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | public function addGroupDisplayRules($groupDisplayRules) { |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | public function addFieldRules($field, $rules = []) { |
| 92 | - if (! $rules) return; |
|
| 92 | + if (!$rules) return; |
|
| 93 | 93 | |
| 94 | 94 | $this->fieldRules[$field] = $rules['rules']?? [ |
| 95 | 95 | 'identifier' => $field, |
@@ -109,17 +109,17 @@ discard block |
||
| 109 | 109 | 'fields' => $this->fieldRules |
| 110 | 110 | ]); |
| 111 | 111 | |
| 112 | - $this->onSubmit(function ($form) use ($callback) { |
|
| 112 | + $this->onSubmit(function($form) use ($callback) { |
|
| 113 | 113 | $errors = []; |
| 114 | - foreach ($this->validationRules?: [] as $ruleCallback) { |
|
| 115 | - if (! is_callable($ruleCallback)) continue; |
|
| 114 | + foreach ($this->validationRules ?: [] as $ruleCallback) { |
|
| 115 | + if (!is_callable($ruleCallback)) continue; |
|
| 116 | 116 | |
| 117 | 117 | $ruleErrors = $ruleCallback($form); |
| 118 | 118 | |
| 119 | - $errors = array_merge($errors, $ruleErrors?: []); |
|
| 119 | + $errors = array_merge($errors, $ruleErrors ?: []); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - return $errors?: $callback($this); |
|
| 122 | + return $errors ?: $callback($this); |
|
| 123 | 123 | }); |
| 124 | 124 | |
| 125 | 125 | return $this; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | public function confirmLeave($confirm = true) |
| 134 | 134 | { |
| 135 | - $this->canLeave = ! $confirm; |
|
| 135 | + $this->canLeave = !$confirm; |
|
| 136 | 136 | |
| 137 | 137 | return $this; |
| 138 | 138 | } |
@@ -89,7 +89,9 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | public function addFieldRules($field, $rules = []) { |
| 92 | - if (! $rules) return; |
|
| 92 | + if (! $rules) { |
|
| 93 | + return; |
|
| 94 | + } |
|
| 93 | 95 | |
| 94 | 96 | $this->fieldRules[$field] = $rules['rules']?? [ |
| 95 | 97 | 'identifier' => $field, |
@@ -112,7 +114,9 @@ discard block |
||
| 112 | 114 | $this->onSubmit(function ($form) use ($callback) { |
| 113 | 115 | $errors = []; |
| 114 | 116 | foreach ($this->validationRules?: [] as $ruleCallback) { |
| 115 | - if (! is_callable($ruleCallback)) continue; |
|
| 117 | + if (! is_callable($ruleCallback)) { |
|
| 118 | + continue; |
|
| 119 | + } |
|
| 116 | 120 | |
| 117 | 121 | $ruleErrors = $ruleCallback($form); |
| 118 | 122 | |
@@ -8,79 +8,79 @@ |
||
| 8 | 8 | |
| 9 | 9 | class ActionButton extends View |
| 10 | 10 | { |
| 11 | - public $defaultTemplate = 'action_button.html'; |
|
| 11 | + public $defaultTemplate = 'action_button.html'; |
|
| 12 | 12 | |
| 13 | - public $ui = 'basic inverted action button'; |
|
| 13 | + public $ui = 'basic inverted action button'; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Icon that will appear on the button (top). |
|
| 17 | - * |
|
| 18 | - * @var string|array|Icon |
|
| 19 | - */ |
|
| 20 | - public $icon; |
|
| 15 | + /** |
|
| 16 | + * Icon that will appear on the button (top). |
|
| 17 | + * |
|
| 18 | + * @var string|array|Icon |
|
| 19 | + */ |
|
| 20 | + public $icon; |
|
| 21 | 21 | |
| 22 | - public $label; |
|
| 22 | + public $label; |
|
| 23 | 23 | |
| 24 | - public $element = 'a'; |
|
| 24 | + public $element = 'a'; |
|
| 25 | 25 | |
| 26 | - public $weight = 10; |
|
| 26 | + public $weight = 10; |
|
| 27 | 27 | |
| 28 | - public $callback; |
|
| 28 | + public $callback; |
|
| 29 | 29 | |
| 30 | - public function renderView() |
|
| 31 | - { |
|
| 32 | - $this->addIcon(); |
|
| 30 | + public function renderView() |
|
| 31 | + { |
|
| 32 | + $this->addIcon(); |
|
| 33 | 33 | |
| 34 | - $this->addLabel(); |
|
| 34 | + $this->addLabel(); |
|
| 35 | 35 | |
| 36 | - $this->addCallback(); |
|
| 36 | + $this->addCallback(); |
|
| 37 | 37 | |
| 38 | - parent::renderView(); |
|
| 39 | - } |
|
| 38 | + parent::renderView(); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - protected function addIcon() |
|
| 42 | - { |
|
| 43 | - if (! $icon = $this->getIcon()) return; |
|
| 41 | + protected function addIcon() |
|
| 42 | + { |
|
| 43 | + if (! $icon = $this->getIcon()) return; |
|
| 44 | 44 | |
| 45 | - $this->add($icon, 'Icon')->id = null; |
|
| 45 | + $this->add($icon, 'Icon')->id = null; |
|
| 46 | 46 | |
| 47 | - $this->addClass('icon'); |
|
| 47 | + $this->addClass('icon'); |
|
| 48 | 48 | |
| 49 | - return $this; |
|
| 50 | - } |
|
| 49 | + return $this; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - protected function addLabel() |
|
| 53 | - { |
|
| 54 | - $this->content = $this->label?: $this->content; |
|
| 52 | + protected function addLabel() |
|
| 53 | + { |
|
| 54 | + $this->content = $this->label?: $this->content; |
|
| 55 | 55 | |
| 56 | - return $this; |
|
| 57 | - } |
|
| 56 | + return $this; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - public function getIcon() |
|
| 60 | - { |
|
| 61 | - return is_object($this->icon)? $this->icon: new Icon($this->icon); |
|
| 62 | - } |
|
| 59 | + public function getIcon() |
|
| 60 | + { |
|
| 61 | + return is_object($this->icon)? $this->icon: new Icon($this->icon); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - public function callback($callable) |
|
| 65 | - { |
|
| 66 | - $this->callback = $callable; |
|
| 64 | + public function callback($callable) |
|
| 65 | + { |
|
| 66 | + $this->callback = $callable; |
|
| 67 | 67 | |
| 68 | - return $this; |
|
| 69 | - } |
|
| 68 | + return $this; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - public function addCallback() |
|
| 72 | - { |
|
| 73 | - if (!$callable = $this->callback) return; |
|
| 71 | + public function addCallback() |
|
| 72 | + { |
|
| 73 | + if (!$callable = $this->callback) return; |
|
| 74 | 74 | |
| 75 | - if (is_callable($callable)) { |
|
| 76 | - $callable = $this->add('jsCallback')->set($callable); |
|
| 77 | - } |
|
| 75 | + if (is_callable($callable)) { |
|
| 76 | + $callable = $this->add('jsCallback')->set($callable); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - if ($callable instanceof jsCallback) { |
|
| 80 | - $this->on('click', $callable); |
|
| 81 | - } |
|
| 79 | + if ($callable instanceof jsCallback) { |
|
| 80 | + $this->on('click', $callable); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - return $this; |
|
| 84 | - } |
|
| 83 | + return $this; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | 86 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | protected function addIcon() |
| 42 | 42 | { |
| 43 | - if (! $icon = $this->getIcon()) return; |
|
| 43 | + if (!$icon = $this->getIcon()) return; |
|
| 44 | 44 | |
| 45 | 45 | $this->add($icon, 'Icon')->id = null; |
| 46 | 46 | |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | protected function addLabel() |
| 53 | 53 | { |
| 54 | - $this->content = $this->label?: $this->content; |
|
| 54 | + $this->content = $this->label ?: $this->content; |
|
| 55 | 55 | |
| 56 | 56 | return $this; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function getIcon() |
| 60 | 60 | { |
| 61 | - return is_object($this->icon)? $this->icon: new Icon($this->icon); |
|
| 61 | + return is_object($this->icon) ? $this->icon : new Icon($this->icon); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public function callback($callable) |
@@ -40,7 +40,9 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | protected function addIcon() |
| 42 | 42 | { |
| 43 | - if (! $icon = $this->getIcon()) return; |
|
| 43 | + if (! $icon = $this->getIcon()) { |
|
| 44 | + return; |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | $this->add($icon, 'Icon')->id = null; |
| 46 | 48 | |
@@ -70,7 +72,9 @@ discard block |
||
| 70 | 72 | |
| 71 | 73 | public function addCallback() |
| 72 | 74 | { |
| 73 | - if (!$callable = $this->callback) return; |
|
| 75 | + if (!$callable = $this->callback) { |
|
| 76 | + return; |
|
| 77 | + } |
|
| 74 | 78 | |
| 75 | 79 | if (is_callable($callable)) { |
| 76 | 80 | $callable = $this->add('jsCallback')->set($callable); |
@@ -6,8 +6,8 @@ |
||
| 6 | 6 | { |
| 7 | 7 | public $defaultTemplate = 'launch_button.html'; |
| 8 | 8 | |
| 9 | - public $ui = 'basic launch pjax button'; |
|
| 9 | + public $ui = 'basic launch pjax button'; |
|
| 10 | 10 | |
| 11 | - public $container = 'View'; |
|
| 11 | + public $container = 'View'; |
|
| 12 | 12 | |
| 13 | 13 | } |