@@ -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 |
@@ -15,52 +15,52 @@ discard block |
||
15 | 15 | protected $validationRules = []; |
16 | 16 | |
17 | 17 | public function addElements($elements, $parent = null) { |
18 | - $parent = $parent?: $this; |
|
18 | + $parent = $parent ?: $this; |
|
19 | 19 | |
20 | 20 | foreach ($elements as $name => $desc) { |
21 | - $name = $desc['name']?? $name; |
|
21 | + $name = $desc['name'] ?? $name; |
|
22 | 22 | |
23 | - $this->addFieldRules($name, $desc['rules']?? []); |
|
23 | + $this->addFieldRules($name, $desc['rules'] ?? []); |
|
24 | 24 | |
25 | - switch ($desc['type']?? 'field') { |
|
25 | + switch ($desc['type'] ?? 'field') { |
|
26 | 26 | case 'field': |
27 | - $desc = is_string($desc)? [ |
|
27 | + $desc = is_string($desc) ? [ |
|
28 | 28 | 'decorator' => [$desc] |
29 | - ]: $desc; |
|
29 | + ] : $desc; |
|
30 | 30 | |
31 | - $field = $parent->addControl($name, $desc['decorator']?? [], $desc['options']?? []); |
|
31 | + $field = $parent->addControl($name, $desc['decorator'] ?? [], $desc['options'] ?? []); |
|
32 | 32 | |
33 | 33 | if ($default = $desc['default']) { |
34 | 34 | $field->set($default); |
35 | 35 | } |
36 | 36 | |
37 | - if ($desc['display']?? false) { |
|
37 | + if ($desc['display'] ?? false) { |
|
38 | 38 | $this->addFieldsDisplayRules([$name => $desc['display']]); |
39 | 39 | } |
40 | 40 | break; |
41 | 41 | |
42 | 42 | case 'group': |
43 | - $seed = $desc['seed']?? [$name]; |
|
43 | + $seed = $desc['seed'] ?? [$name]; |
|
44 | 44 | |
45 | 45 | $group = $parent->addGroup($seed); |
46 | 46 | |
47 | 47 | $this->addElements($desc['elements'], $group); |
48 | 48 | |
49 | - if ($desc['display']?? false) { |
|
49 | + if ($desc['display'] ?? false) { |
|
50 | 50 | $this->addGroupDisplayRules([$name => $desc['display']]); |
51 | 51 | } |
52 | 52 | break; |
53 | 53 | |
54 | 54 | case 'header': |
55 | - $seed = $desc['seed']?? [$name]; |
|
55 | + $seed = $desc['seed'] ?? [$name]; |
|
56 | 56 | |
57 | 57 | $parent->addHeader($seed); |
58 | 58 | break; |
59 | 59 | |
60 | 60 | case 'view': |
61 | - $seed = $desc['seed']?? ['Label', $name]; |
|
61 | + $seed = $desc['seed'] ?? ['Label', $name]; |
|
62 | 62 | |
63 | - $region = $desc['region']?? null; |
|
63 | + $region = $desc['region'] ?? null; |
|
64 | 64 | |
65 | 65 | $this->add($seed, $region); |
66 | 66 | break; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | public function addFieldsDisplayRules($fieldsDisplayRules) { |
78 | - $this->setControlsDisplayRules(array_merge($this->fieldsDisplayRules?: [], $fieldsDisplayRules)); |
|
78 | + $this->setControlsDisplayRules(array_merge($this->fieldsDisplayRules ?: [], $fieldsDisplayRules)); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | public function addGroupDisplayRules($groupDisplayRules) { |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | public function addFieldRules($field, $rules = []) { |
90 | - if (! $rules) return; |
|
90 | + if (!$rules) return; |
|
91 | 91 | |
92 | - $this->fieldRules[$field] = $rules['rules']?? [ |
|
92 | + $this->fieldRules[$field] = $rules['rules'] ?? [ |
|
93 | 93 | 'identifier' => $field, |
94 | 94 | 'rules' => $rules |
95 | 95 | ]; |
@@ -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 | } |
@@ -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) |
@@ -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(): void |
|
31 | - { |
|
32 | - $this->addIcon(); |
|
30 | + public function renderView(): void |
|
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 = JsCallback::addTo($this)->set($callable); |
|
77 | - } |
|
75 | + if (is_callable($callable)) { |
|
76 | + $callable = JsCallback::addTo($this)->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,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 = JsCallback::addTo($this)->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 | } |
@@ -41,6 +41,6 @@ |
||
41 | 41 | */ |
42 | 42 | public static function pluck($value, $key = null) |
43 | 43 | { |
44 | - return collect(self::create()->export())->pluck($value, $key); |
|
44 | + return collect(self::create()->export())->pluck($value, $key); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -23,7 +23,7 @@ |
||
23 | 23 | |
24 | 24 | $grid = $this->add([ |
25 | 25 | 'CRUD', |
26 | - 'menu' => ActionBar::instance(), |
|
26 | + 'menu' => ActionBar::instance(), |
|
27 | 27 | // 'model' => HomePage::create(), |
28 | 28 | 'displayFields' => ['path', 'role'], |
29 | 29 | 'editFields' => ['path', 'role'], |
@@ -50,7 +50,7 @@ |
||
50 | 50 | |
51 | 51 | // $plugin->extendList('path'); |
52 | 52 | |
53 | - $grid->addDragHandler()->onReorder(function ($order) { |
|
53 | + $grid->addDragHandler()->onReorder(function($order) { |
|
54 | 54 | foreach (HomePage::create() as $homepage) { |
55 | 55 | $homepage->save(['priority' => array_search($homepage['id'], $order)]); |
56 | 56 | } |
@@ -7,18 +7,18 @@ |
||
7 | 7 | |
8 | 8 | class SQL extends \atk4\data\Persistence\SQL |
9 | 9 | { |
10 | - /** |
|
11 | - * Take a laravel connection and pass it to ATK Data |
|
12 | - * |
|
13 | - * @return \atk4\data\Persistence\SQL |
|
14 | - */ |
|
15 | - public function __construct(DatabaseManager $database) |
|
16 | - { |
|
17 | - $pdo = $database->connection()->getPdo(); |
|
10 | + /** |
|
11 | + * Take a laravel connection and pass it to ATK Data |
|
12 | + * |
|
13 | + * @return \atk4\data\Persistence\SQL |
|
14 | + */ |
|
15 | + public function __construct(DatabaseManager $database) |
|
16 | + { |
|
17 | + $pdo = $database->connection()->getPdo(); |
|
18 | 18 | |
19 | - // temporary fix of atk4/data inability to handle PREPARE on 'is null' |
|
20 | - $pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true); |
|
19 | + // temporary fix of atk4/data inability to handle PREPARE on 'is null' |
|
20 | + $pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true); |
|
21 | 21 | |
22 | - parent::__construct(Connection::connect($pdo)); |
|
23 | - } |
|
22 | + parent::__construct(Connection::connect($pdo)); |
|
23 | + } |
|
24 | 24 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | public function __construct($parent) |
16 | 16 | { |
17 | - $this->parent = $parent; |
|
17 | + $this->parent = $parent; |
|
18 | 18 | |
19 | 19 | parent::__construct('$(this).atkCreateModal([arg])', [ |
20 | 20 | 'arg' => [ |
@@ -26,29 +26,29 @@ discard block |
||
26 | 26 | } |
27 | 27 | |
28 | 28 | protected function getURL() |
29 | - { |
|
30 | - return \atk4\ui\VirtualPage::addTo($this->parent)->set(Closure::fromCallable([$this, 'getContents']))->getJSURL('cut'); |
|
31 | - } |
|
29 | + { |
|
30 | + return \atk4\ui\VirtualPage::addTo($this->parent)->set(Closure::fromCallable([$this, 'getContents']))->getJSURL('cut'); |
|
31 | + } |
|
32 | 32 | |
33 | - protected function getContents(VirtualPage $vp) |
|
34 | - { |
|
35 | - $vp->add([ |
|
36 | - new LaunchButton([ |
|
37 | - 'label' => 'Test Button 1', |
|
38 | - 'icon' => 'user' |
|
39 | - ]) |
|
40 | - ])->link(URL::to('/')); |
|
41 | - $vp->add([ |
|
42 | - new LaunchButton([ |
|
43 | - 'label' => 'Test Button 2', |
|
44 | - 'icon' => 'car' |
|
45 | - ]) |
|
46 | - ]); |
|
47 | - $vp->add([ |
|
48 | - new LaunchButton([ |
|
49 | - 'label' => 'Test Button 3', |
|
50 | - 'icon' => 'bus' |
|
51 | - ]) |
|
52 | - ]); |
|
53 | - } |
|
33 | + protected function getContents(VirtualPage $vp) |
|
34 | + { |
|
35 | + $vp->add([ |
|
36 | + new LaunchButton([ |
|
37 | + 'label' => 'Test Button 1', |
|
38 | + 'icon' => 'user' |
|
39 | + ]) |
|
40 | + ])->link(URL::to('/')); |
|
41 | + $vp->add([ |
|
42 | + new LaunchButton([ |
|
43 | + 'label' => 'Test Button 2', |
|
44 | + 'icon' => 'car' |
|
45 | + ]) |
|
46 | + ]); |
|
47 | + $vp->add([ |
|
48 | + new LaunchButton([ |
|
49 | + 'label' => 'Test Button 3', |
|
50 | + 'icon' => 'bus' |
|
51 | + ]) |
|
52 | + ]); |
|
53 | + } |
|
54 | 54 | } |
@@ -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(): void |
|
17 | - { |
|
18 | - $this->addCallback(); |
|
16 | + public function renderView(): void |
|
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 = JsCallback::addTo($this)->set($callable); |
|
38 | - } |
|
34 | + public function addCallback() |
|
35 | + { |
|
36 | + if (is_callable($callable = $this->callback)) { |
|
37 | + $callable = JsCallback::addTo($this)->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 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | class ActionBar extends Menu |
10 | 10 | { |
11 | - public $ui = 'actionbar menu'; |
|
11 | + public $ui = 'actionbar menu'; |
|
12 | 12 | |
13 | 13 | protected static $buttons = []; |
14 | 14 | |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | public function renderView(): void |
50 | - { |
|
51 | - $this->elements = collect($this->elements)->sortByDesc(function ($element) { |
|
52 | - return $element->weight ?? 10; |
|
53 | - })->toArray(); |
|
50 | + { |
|
51 | + $this->elements = collect($this->elements)->sortByDesc(function ($element) { |
|
52 | + return $element->weight ?? 10; |
|
53 | + })->toArray(); |
|
54 | 54 | |
55 | - parent::renderView(); |
|
55 | + parent::renderView(); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | public static function addMenuButton($menu) |
84 | 84 | { |
85 | - return self::instance()->addMenu($menu); |
|
85 | + return self::instance()->addMenu($menu); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | public static function clear() |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | 'icon' => 'arrow left', |
23 | 23 | 'weight' => 10000, |
24 | 24 | 'attr' => [ |
25 | - 'href' => $_SERVER['HTTP_REFERER']?? 'javascript:window.history.back()' |
|
25 | + 'href' => $_SERVER['HTTP_REFERER'] ?? 'javascript:window.history.back()' |
|
26 | 26 | ], |
27 | 27 | ], |
28 | 28 | 'save' => [ |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | public function renderView(): void |
50 | 50 | { |
51 | - $this->elements = collect($this->elements)->sortByDesc(function ($element) { |
|
51 | + $this->elements = collect($this->elements)->sortByDesc(function($element) { |
|
52 | 52 | return $element->weight ?? 10; |
53 | 53 | })->toArray(); |
54 | 54 | |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public static function addItemButton($button, $defaults = []) |
66 | 66 | { |
67 | - $button = is_string($button)? self::getPredefined($button): $button; |
|
67 | + $button = is_string($button) ? self::getPredefined($button) : $button; |
|
68 | 68 | |
69 | - $button = is_array($button)? new ActionBarItem($button): $button; |
|
69 | + $button = is_array($button) ? new ActionBarItem($button) : $button; |
|
70 | 70 | |
71 | 71 | $actionBar = self::instance(); |
72 | 72 |