@@ -142,7 +142,9 @@ discard block |
||
142 | 142 | |
143 | 143 | public function addMenu() |
144 | 144 | { |
145 | - if ($this->isLocked()) return; |
|
145 | + if ($this->isLocked()) { |
|
146 | + return; |
|
147 | + } |
|
146 | 148 | |
147 | 149 | $dashboardId = $this->dashboard()->id; |
148 | 150 | |
@@ -165,14 +167,18 @@ discard block |
||
165 | 167 | $dashboardMenu->addItem([__('Rename dashboard'), 'icon' => 'i cursor'])->on('click', $modal->show()); |
166 | 168 | |
167 | 169 | // there is only one admin default dashboard |
168 | - if ($this->admin) return; |
|
170 | + if ($this->admin) { |
|
171 | + return; |
|
172 | + } |
|
169 | 173 | |
170 | 174 | // ***** add ***** // |
171 | 175 | $modal = $this->add(['Modal', 'title' => __('Add Dashboard')])->set(\Closure::fromCallable([$this, 'addDashboard'])); |
172 | 176 | |
173 | 177 | $dashboardMenu->addItem([__('Add dashboard'), 'icon' => 'add'])->on('click', $modal->show()); |
174 | 178 | |
175 | - if ($this->isSingleDashboard()) return; |
|
179 | + if ($this->isSingleDashboard()) { |
|
180 | + return; |
|
181 | + } |
|
176 | 182 | |
177 | 183 | // ***** reorder ***** // |
178 | 184 | $modal = $this->add(['Modal', 'title' => __('Reorder Dashboards')])->set(\Closure::fromCallable([$this, 'reorderDashboards'])); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public function body() |
26 | 26 | { |
27 | - if (! $this->isSingleDashboard()) { |
|
27 | + if (!$this->isSingleDashboard()) { |
|
28 | 28 | $this->location($this->dashboard()->name); |
29 | 29 | } |
30 | 30 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $applets = $dashboard->applets()->orderBy('column')->orderBy('row')->get(); |
44 | 44 | |
45 | - $columns = $this->add(['Columns', 'id' => 'dashboard', 'ui' => 'three stackable grid' . ($this->isLocked()? ' locked': '')]); |
|
45 | + $columns = $this->add(['Columns', 'id' => 'dashboard', 'ui' => 'three stackable grid' . ($this->isLocked() ? ' locked' : '')]); |
|
46 | 46 | |
47 | 47 | foreach ([1, 2, 3] as $columnId) { |
48 | 48 | /** @scrutinizer ignore-call */ |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | ] |
56 | 56 | ]); |
57 | 57 | |
58 | - foreach ($applets->where('column', $columnId) as $applet ) { |
|
58 | + foreach ($applets->where('column', $columnId) as $applet) { |
|
59 | 59 | $col->add([ |
60 | 60 | new Applet(), |
61 | 61 | 'appletId' => $applet->id, |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | - if (! $this->isLocked()) { |
|
69 | + if (!$this->isLocked()) { |
|
70 | 70 | $columns->js(true)->find('.sortable')->sortable([ |
71 | 71 | 'cursor' => 'move', |
72 | 72 | 'handle' => '.panel-sortable-handle', |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | ]) |
85 | 85 | ])); |
86 | 86 | |
87 | - $columns->js(true)->find('.applet-close')->click(new jsFunction(['e'], [new jsExpression('if (confirm("' . __('Delete this applet?') . '")) {$(e.target).closest(".applet").fadeOut(400, function(){var col = $(this).closest(".column.sortable");this.remove();col.trigger("sortupdate");})}')])); |
|
87 | + $columns->js(true)->find('.applet-close')->click(new jsFunction(['e'], [new jsExpression('if (confirm("' . __('Delete this applet?') . '")) {$(e.target).closest(".applet").fadeOut(400, function(){var col = $(this).closest(".column.sortable");this.remove();col.trigger("sortupdate");})}')])); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | $this->columns = $columns; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | ] |
132 | 132 | ]); |
133 | 133 | |
134 | - foreach ( AppletJoint::collect() as $applet ) { |
|
134 | + foreach (AppletJoint::collect() as $applet) { |
|
135 | 135 | $col->add([ |
136 | 136 | new Applet(), |
137 | 137 | 'appletId' => 'new_' . str_ireplace('\\', '-', get_class($applet)), |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | { |
261 | 261 | $dashboard = Dashboard::find($dashboardId); |
262 | 262 | |
263 | - return $dashboard->delete()? [ |
|
263 | + return $dashboard->delete() ? [ |
|
264 | 264 | $this->notify(__('Dashboard ":name" deleted, redirecting ...', ['name' => $dashboard->name])), |
265 | 265 | new jsExpression('window.setTimeout(function() {window.location.replace([])}, 1200)', [self::selfLink()]) |
266 | - ]: $this->notifyError(__('Error deleting dashboard')); |
|
266 | + ] : $this->notifyError(__('Error deleting dashboard')); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | public function reorderDashboards($view) |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $grid = $view->add(['Grid', 'paginator' => false, 'menu' => false]); |
283 | 283 | $grid->setModel(new \atk4\data\Model(new \atk4\data\Persistence_Static($rows))); |
284 | 284 | |
285 | - $grid->addDragHandler()->onReorder(function ($order) use ($dashboards) { |
|
285 | + $grid->addDragHandler()->onReorder(function($order) use ($dashboards) { |
|
286 | 286 | $result = true; |
287 | 287 | foreach ($dashboards as $dashboard) { |
288 | 288 | $dashboard->position = array_search($dashboard->id, $order); |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $result &= $dashboard->save(); |
291 | 291 | } |
292 | 292 | |
293 | - return $result? $this->notify(__('Dashboards reordered!')): $this->notifyError(__('Error saving order!')); |
|
293 | + return $result ? $this->notify(__('Dashboards reordered!')) : $this->notifyError(__('Error saving order!')); |
|
294 | 294 | }); |
295 | 295 | |
296 | 296 | $view->add(['View', 'ui' => 'buttons'])->add(['Button', __('Done'), 'primary'])->on('click', new jsExpression('location.reload()')); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | |
368 | 368 | public function isLocked() |
369 | 369 | { |
370 | - return $this->locked || ! Auth::user()->can('edit dashboard'); |
|
370 | + return $this->locked || !Auth::user()->can('edit dashboard'); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | protected function isSingleDashboard() |
@@ -383,18 +383,18 @@ discard block |
||
383 | 383 | */ |
384 | 384 | protected function dashboard() |
385 | 385 | { |
386 | - if (! is_object($this->dashboard)) { |
|
387 | - $this->dashboard = $this->dashboard? Dashboard::find($this->dashboard): $this->defaultUserDashboard(); |
|
386 | + if (!is_object($this->dashboard)) { |
|
387 | + $this->dashboard = $this->dashboard ? Dashboard::find($this->dashboard) : $this->defaultUserDashboard(); |
|
388 | 388 | } |
389 | 389 | |
390 | - return $this->dashboard?: abort(404); |
|
390 | + return $this->dashboard ?: abort(404); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | protected function defaultUserDashboard() |
394 | 394 | { |
395 | 395 | $userDashboard = $this->userDashboards()->orderBy('position')->first(); |
396 | 396 | |
397 | - if (! $userDashboard) { |
|
397 | + if (!$userDashboard) { |
|
398 | 398 | $this->lock(); |
399 | 399 | |
400 | 400 | $userDashboard = $this->defaultSystemDashboard(); |
@@ -418,6 +418,6 @@ discard block |
||
418 | 418 | */ |
419 | 419 | protected function userId() |
420 | 420 | { |
421 | - return $this->admin? 0: Auth::id(); |
|
421 | + return $this->admin ? 0 : Auth::id(); |
|
422 | 422 | } |
423 | 423 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | $this->set($joint->info())->setAttr('searchkey', strtolower($joint->caption() . ';' . $joint->info())); |
29 | 29 | } |
30 | 30 | else { |
31 | - if (! $this->locked) { |
|
31 | + if (!$this->locked) { |
|
32 | 32 | $this->addControl('close', 'applet-close')->setAttr('title', __('Close applet')); |
33 | 33 | } |
34 | 34 |
@@ -26,8 +26,7 @@ |
||
26 | 26 | |
27 | 27 | if ($this->admin) { |
28 | 28 | $this->set($joint->info())->setAttr('searchkey', strtolower($joint->caption() . ';' . $joint->info())); |
29 | - } |
|
30 | - else { |
|
29 | + } else { |
|
31 | 30 | if (! $this->locked) { |
32 | 31 | $this->addControl('close', 'applet-close')->setAttr('title', __('Close applet')); |
33 | 32 | } |
@@ -21,12 +21,12 @@ |
||
21 | 21 | ]; |
22 | 22 | } |
23 | 23 | |
24 | - return $ret? [ |
|
25 | - __('DASHBOARD') => count($ret) > 1? [ |
|
24 | + return $ret ? [ |
|
25 | + __('DASHBOARD') => count($ret) > 1 ? [ |
|
26 | 26 | 'access' => true, |
27 | 27 | 'group' => $ret, |
28 | 28 | 'weight' => -10000 |
29 | - ]: array_merge(reset($ret), ['weight' => -10000]), |
|
30 | - ]: []; |
|
29 | + ] : array_merge(reset($ret), ['weight' => -10000]), |
|
30 | + ] : []; |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | \ No newline at end of file |
@@ -31,7 +31,7 @@ |
||
31 | 31 | { |
32 | 32 | // create user default dashboard as copy of the system default |
33 | 33 | User::created(function(User $user) { |
34 | - if (! $defaultDashboard = Dashboard::where('user_id', 0)->first()) return; |
|
34 | + if (!$defaultDashboard = Dashboard::where('user_id', 0)->first()) return; |
|
35 | 35 | |
36 | 36 | $userDefaultDashboard = $defaultDashboard->replicate(); |
37 | 37 |
@@ -31,7 +31,9 @@ |
||
31 | 31 | { |
32 | 32 | // create user default dashboard as copy of the system default |
33 | 33 | User::created(function(User $user) { |
34 | - if (! $defaultDashboard = Dashboard::where('user_id', 0)->first()) return; |
|
34 | + if (! $defaultDashboard = Dashboard::where('user_id', 0)->first()) { |
|
35 | + return; |
|
36 | + } |
|
35 | 37 | |
36 | 38 | $userDefaultDashboard = $defaultDashboard->replicate(); |
37 | 39 |
@@ -15,14 +15,14 @@ |
||
15 | 15 | { |
16 | 16 | $this->down(); |
17 | 17 | |
18 | - Schema::create('dashboards', function (Blueprint $table) { |
|
18 | + Schema::create('dashboards', function(Blueprint $table) { |
|
19 | 19 | $table->increments('id'); |
20 | 20 | $table->unsignedInteger('user_id'); |
21 | 21 | $table->string('name', 64); |
22 | 22 | $table->smallInteger('position')->default(0); |
23 | 23 | }); |
24 | 24 | |
25 | - Schema::create('dashboard_applets', function (Blueprint $table) { |
|
25 | + Schema::create('dashboard_applets', function(Blueprint $table) { |
|
26 | 26 | $table->increments('id'); |
27 | 27 | $table->unsignedInteger('dashboard_id'); |
28 | 28 | $table->string('class', 512); |
@@ -6,42 +6,42 @@ |
||
6 | 6 | |
7 | 7 | class CreateDashboardTables extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
15 | - { |
|
16 | - $this->down(); |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
15 | + { |
|
16 | + $this->down(); |
|
17 | 17 | |
18 | - Schema::create('dashboards', function (Blueprint $table) { |
|
19 | - $table->increments('id'); |
|
20 | - $table->unsignedInteger('user_id'); |
|
21 | - $table->string('name', 64); |
|
22 | - $table->smallInteger('position')->default(0); |
|
23 | - }); |
|
18 | + Schema::create('dashboards', function (Blueprint $table) { |
|
19 | + $table->increments('id'); |
|
20 | + $table->unsignedInteger('user_id'); |
|
21 | + $table->string('name', 64); |
|
22 | + $table->smallInteger('position')->default(0); |
|
23 | + }); |
|
24 | 24 | |
25 | - Schema::create('dashboard_applets', function (Blueprint $table) { |
|
26 | - $table->increments('id'); |
|
27 | - $table->unsignedInteger('dashboard_id'); |
|
28 | - $table->string('class', 512); |
|
29 | - $table->smallInteger('column')->default(1); |
|
30 | - $table->smallInteger('row')->default(0); |
|
31 | - $table->text('options')->nullable(); |
|
25 | + Schema::create('dashboard_applets', function (Blueprint $table) { |
|
26 | + $table->increments('id'); |
|
27 | + $table->unsignedInteger('dashboard_id'); |
|
28 | + $table->string('class', 512); |
|
29 | + $table->smallInteger('column')->default(1); |
|
30 | + $table->smallInteger('row')->default(0); |
|
31 | + $table->text('options')->nullable(); |
|
32 | 32 | |
33 | - $table->foreign('dashboard_id')->references('id')->on('dashboards'); |
|
34 | - }); |
|
35 | - } |
|
33 | + $table->foreign('dashboard_id')->references('id')->on('dashboards'); |
|
34 | + }); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Reverse the migrations. |
|
39 | - * |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public function down() |
|
43 | - { |
|
44 | - Schema::dropIfExists('dashboard_applets'); |
|
45 | - Schema::dropIfExists('dashboards'); |
|
46 | - } |
|
37 | + /** |
|
38 | + * Reverse the migrations. |
|
39 | + * |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public function down() |
|
43 | + { |
|
44 | + Schema::dropIfExists('dashboard_applets'); |
|
45 | + Schema::dropIfExists('dashboards'); |
|
46 | + } |
|
47 | 47 | } |
@@ -6,31 +6,31 @@ |
||
6 | 6 | |
7 | 7 | class CreateCommondataTable extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
15 | - { |
|
16 | - Schema::create('commondata', function (Blueprint $table) { |
|
17 | - $table->bigIncrements('id'); |
|
18 | - $table->nestedSet(); |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
15 | + { |
|
16 | + Schema::create('commondata', function (Blueprint $table) { |
|
17 | + $table->bigIncrements('id'); |
|
18 | + $table->nestedSet(); |
|
19 | 19 | |
20 | - $table->string('key', 64); |
|
21 | - $table->text('value')->nullable(); |
|
22 | - $table->integer('position')->nullable()->default(0); |
|
23 | - $table->smallInteger('readonly')->nullable()->default(0); |
|
24 | - }); |
|
25 | - } |
|
20 | + $table->string('key', 64); |
|
21 | + $table->text('value')->nullable(); |
|
22 | + $table->integer('position')->nullable()->default(0); |
|
23 | + $table->smallInteger('readonly')->nullable()->default(0); |
|
24 | + }); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Reverse the migrations. |
|
29 | - * |
|
30 | - * @return void |
|
31 | - */ |
|
32 | - public function down() |
|
33 | - { |
|
34 | - Schema::dropIfExists('commondata'); |
|
35 | - } |
|
27 | + /** |
|
28 | + * Reverse the migrations. |
|
29 | + * |
|
30 | + * @return void |
|
31 | + */ |
|
32 | + public function down() |
|
33 | + { |
|
34 | + Schema::dropIfExists('commondata'); |
|
35 | + } |
|
36 | 36 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('commondata', function (Blueprint $table) { |
|
16 | + Schema::create('commondata', function(Blueprint $table) { |
|
17 | 17 | $table->bigIncrements('id'); |
18 | 18 | $table->nestedSet(); |
19 | 19 |
@@ -7,198 +7,198 @@ |
||
7 | 7 | use Illuminate\Database\Eloquent\Collection; |
8 | 8 | |
9 | 9 | class CommonData extends Model { |
10 | - use NodeTrait; |
|
10 | + use NodeTrait; |
|
11 | 11 | |
12 | - protected $table = 'commondata'; |
|
13 | - public $timestamps = false; |
|
14 | - protected static $unguarded = true; |
|
12 | + protected $table = 'commondata'; |
|
13 | + public $timestamps = false; |
|
14 | + protected static $unguarded = true; |
|
15 | 15 | |
16 | - public static function getId($path, $clearCache = false) |
|
17 | - { |
|
18 | - static $cache; |
|
16 | + public static function getId($path, $clearCache = false) |
|
17 | + { |
|
18 | + static $cache; |
|
19 | 19 | |
20 | - $parentId = null; |
|
21 | - foreach(explode('/', trim($path,'/')) as $nodeKey) { |
|
22 | - if ($nodeKey === '') continue; //ignore empty paths |
|
20 | + $parentId = null; |
|
21 | + foreach(explode('/', trim($path,'/')) as $nodeKey) { |
|
22 | + if ($nodeKey === '') continue; //ignore empty paths |
|
23 | 23 | |
24 | - if (empty($cache[$parentId][$nodeKey])) { |
|
25 | - if (! $node = self::where('parent_id', $parentId)->where('key', $nodeKey)->first()) { |
|
26 | - return false; |
|
27 | - } |
|
24 | + if (empty($cache[$parentId][$nodeKey])) { |
|
25 | + if (! $node = self::where('parent_id', $parentId)->where('key', $nodeKey)->first()) { |
|
26 | + return false; |
|
27 | + } |
|
28 | 28 | |
29 | - $cache[$parentId][$nodeKey] = $node->id; |
|
30 | - } |
|
29 | + $cache[$parentId][$nodeKey] = $node->id; |
|
30 | + } |
|
31 | 31 | |
32 | - $parentId = $id = $cache[$parentId][$nodeKey]; |
|
33 | - } |
|
32 | + $parentId = $id = $cache[$parentId][$nodeKey]; |
|
33 | + } |
|
34 | 34 | |
35 | - return $id; |
|
36 | - } |
|
35 | + return $id; |
|
36 | + } |
|
37 | 37 | |
38 | - public static function newId($path, $readonly = false) |
|
39 | - { |
|
40 | - if (! $path = trim($path,'/')) return false; |
|
38 | + public static function newId($path, $readonly = false) |
|
39 | + { |
|
40 | + if (! $path = trim($path,'/')) return false; |
|
41 | 41 | |
42 | - $id = $parentId = null; |
|
43 | - foreach(explode('/', $path) as $nodeKey) { |
|
44 | - if ($nodeKey === '') continue; |
|
42 | + $id = $parentId = null; |
|
43 | + foreach(explode('/', $path) as $nodeKey) { |
|
44 | + if ($nodeKey === '') continue; |
|
45 | 45 | |
46 | - if (! $node = self::where('parent_id', $parentId)->where('key', $nodeKey)->first()) { |
|
47 | - $node = self::create([ |
|
48 | - 'parent_id' => $parentId, |
|
49 | - 'key' => $nodeKey, |
|
50 | - 'readonly' => $readonly, |
|
51 | - 'position' => self::where('parent_id', $parentId)->count() |
|
52 | - ], $parentId? self::find($parentId): null); |
|
53 | - } |
|
46 | + if (! $node = self::where('parent_id', $parentId)->where('key', $nodeKey)->first()) { |
|
47 | + $node = self::create([ |
|
48 | + 'parent_id' => $parentId, |
|
49 | + 'key' => $nodeKey, |
|
50 | + 'readonly' => $readonly, |
|
51 | + 'position' => self::where('parent_id', $parentId)->count() |
|
52 | + ], $parentId? self::find($parentId): null); |
|
53 | + } |
|
54 | 54 | |
55 | - $parentId = $id = $node->id; |
|
56 | - } |
|
55 | + $parentId = $id = $node->id; |
|
56 | + } |
|
57 | 57 | |
58 | - return $id; |
|
59 | - } |
|
58 | + return $id; |
|
59 | + } |
|
60 | 60 | |
61 | - public static function setValue($path, $value, $overwrite = true, $readonly = false) |
|
62 | - { |
|
63 | - if (! $id = self::getId($path)) { |
|
64 | - if (! $id = self::newId($path, $readonly)) return false; |
|
65 | - } else { |
|
66 | - if (! $overwrite) return false; |
|
67 | - } |
|
61 | + public static function setValue($path, $value, $overwrite = true, $readonly = false) |
|
62 | + { |
|
63 | + if (! $id = self::getId($path)) { |
|
64 | + if (! $id = self::newId($path, $readonly)) return false; |
|
65 | + } else { |
|
66 | + if (! $overwrite) return false; |
|
67 | + } |
|
68 | 68 | |
69 | - self::find($id)->update(compact('value', 'readonly')); |
|
69 | + self::find($id)->update(compact('value', 'readonly')); |
|
70 | 70 | |
71 | - return true; |
|
72 | - } |
|
71 | + return true; |
|
72 | + } |
|
73 | 73 | |
74 | - public static function getValue($path, $translate = false) |
|
75 | - { |
|
76 | - static $cache; |
|
74 | + public static function getValue($path, $translate = false) |
|
75 | + { |
|
76 | + static $cache; |
|
77 | 77 | |
78 | - $key = md5(serialize([$path, $translate])); |
|
78 | + $key = md5(serialize([$path, $translate])); |
|
79 | 79 | |
80 | - if (! isset($cache[$key])) { |
|
81 | - if(! $id = self::getId($path)) return false; |
|
80 | + if (! isset($cache[$key])) { |
|
81 | + if(! $id = self::getId($path)) return false; |
|
82 | 82 | |
83 | - $ret = self::find($id)->value; |
|
83 | + $ret = self::find($id)->value; |
|
84 | 84 | |
85 | - $cache[$key] = $translate? __($ret): $ret; |
|
86 | - } |
|
85 | + $cache[$key] = $translate? __($ret): $ret; |
|
86 | + } |
|
87 | 87 | |
88 | - return $cache[$key]; |
|
89 | - } |
|
88 | + return $cache[$key]; |
|
89 | + } |
|
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * Creates new array for common use. |
|
94 | - * |
|
95 | - * @param $path string |
|
96 | - * @param $array array initialization value |
|
97 | - * @param $overwrite bool whether method should overwrite if array already exists, otherwise the data will be appended |
|
98 | - * @param $readonly bool do not allow user to change this array from GUI |
|
99 | - */ |
|
100 | - public static function newArray($path, $array, $overwrite = false, $readonly = false) |
|
101 | - { |
|
102 | - self::validateArrayKeys($array); |
|
92 | + /** |
|
93 | + * Creates new array for common use. |
|
94 | + * |
|
95 | + * @param $path string |
|
96 | + * @param $array array initialization value |
|
97 | + * @param $overwrite bool whether method should overwrite if array already exists, otherwise the data will be appended |
|
98 | + * @param $readonly bool do not allow user to change this array from GUI |
|
99 | + */ |
|
100 | + public static function newArray($path, $array, $overwrite = false, $readonly = false) |
|
101 | + { |
|
102 | + self::validateArrayKeys($array); |
|
103 | 103 | |
104 | - $path = trim($path, '/'); |
|
104 | + $path = trim($path, '/'); |
|
105 | 105 | |
106 | 106 | if ($id = self::getId($path)) { |
107 | - if (! $overwrite) { |
|
108 | - self::extendArray($path, $array); |
|
109 | - return true; |
|
110 | - } |
|
107 | + if (! $overwrite) { |
|
108 | + self::extendArray($path, $array); |
|
109 | + return true; |
|
110 | + } |
|
111 | 111 | |
112 | - self::find($id)->delete(); |
|
113 | - } |
|
112 | + self::find($id)->delete(); |
|
113 | + } |
|
114 | 114 | |
115 | - if(! $id = self::newId($path, $readonly)) return false; |
|
115 | + if(! $id = self::newId($path, $readonly)) return false; |
|
116 | 116 | |
117 | - if ($overwrite) { |
|
118 | - self::find($id)->update(compact('readonly')); |
|
119 | - } |
|
117 | + if ($overwrite) { |
|
118 | + self::find($id)->update(compact('readonly')); |
|
119 | + } |
|
120 | 120 | |
121 | - foreach ($array as $key => $value) { |
|
122 | - self::setValue($path . '/' . $key, $value, true, $readonly); |
|
123 | - } |
|
121 | + foreach ($array as $key => $value) { |
|
122 | + self::setValue($path . '/' . $key, $value, true, $readonly); |
|
123 | + } |
|
124 | 124 | |
125 | - return true; |
|
126 | - } |
|
125 | + return true; |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * Extends common data array. |
|
130 | - * |
|
131 | - * @param $path string |
|
132 | - * @param $array array values to insert |
|
133 | - * @param $overwrite bool whether method should overwrite data if array key already exists, otherwise the data will be preserved |
|
134 | - */ |
|
135 | - public static function extendArray($path, $array, $overwrite=false, $readonly=false) |
|
136 | - { |
|
137 | - self::validateArrayKeys($array); |
|
128 | + /** |
|
129 | + * Extends common data array. |
|
130 | + * |
|
131 | + * @param $path string |
|
132 | + * @param $array array values to insert |
|
133 | + * @param $overwrite bool whether method should overwrite data if array key already exists, otherwise the data will be preserved |
|
134 | + */ |
|
135 | + public static function extendArray($path, $array, $overwrite=false, $readonly=false) |
|
136 | + { |
|
137 | + self::validateArrayKeys($array); |
|
138 | 138 | |
139 | - $path = trim($path, '/'); |
|
139 | + $path = trim($path, '/'); |
|
140 | 140 | |
141 | - if (! self::getId($path)){ |
|
142 | - return self::newArray($path, $array, $overwrite, $readonly); |
|
143 | - } |
|
141 | + if (! self::getId($path)){ |
|
142 | + return self::newArray($path, $array, $overwrite, $readonly); |
|
143 | + } |
|
144 | 144 | |
145 | - foreach ($array as $key => $value) { |
|
146 | - self::setValue($path . '/' . $key, $value, $overwrite, $readonly); |
|
147 | - } |
|
148 | - } |
|
145 | + foreach ($array as $key => $value) { |
|
146 | + self::setValue($path . '/' . $key, $value, $overwrite, $readonly); |
|
147 | + } |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * Returns common data array. |
|
152 | - * |
|
153 | - * @param string array name |
|
154 | - * @return mixed returns an array if such array exists, false otherwise |
|
155 | - */ |
|
156 | - public static function getArray($path, $sortColumn = 'position', $silent = false) |
|
157 | - { |
|
158 | - return self::getCollection($path, $silent)->sortBy($sortColumn)->pluck('value', 'key')->all(); |
|
159 | - } |
|
150 | + /** |
|
151 | + * Returns common data array. |
|
152 | + * |
|
153 | + * @param string array name |
|
154 | + * @return mixed returns an array if such array exists, false otherwise |
|
155 | + */ |
|
156 | + public static function getArray($path, $sortColumn = 'position', $silent = false) |
|
157 | + { |
|
158 | + return self::getCollection($path, $silent)->sortBy($sortColumn)->pluck('value', 'key')->all(); |
|
159 | + } |
|
160 | 160 | |
161 | - /** |
|
162 | - * Removes common data array or entry. |
|
163 | - * |
|
164 | - * @param $path string |
|
165 | - * @return true on success, false otherwise |
|
166 | - */ |
|
167 | - public static function deleteArray($path){ |
|
168 | - if (! $id = self::getId($path, true)) return false; |
|
161 | + /** |
|
162 | + * Removes common data array or entry. |
|
163 | + * |
|
164 | + * @param $path string |
|
165 | + * @return true on success, false otherwise |
|
166 | + */ |
|
167 | + public static function deleteArray($path){ |
|
168 | + if (! $id = self::getId($path, true)) return false; |
|
169 | 169 | |
170 | - self::find($id)->delete(); |
|
171 | - } |
|
170 | + self::find($id)->delete(); |
|
171 | + } |
|
172 | 172 | |
173 | - /** |
|
174 | - * Returns common data collection. |
|
175 | - * |
|
176 | - * @param $path string |
|
177 | - * @return Collection |
|
178 | - */ |
|
179 | - public static function getCollection($path, $silent = false) |
|
180 | - { |
|
181 | - static $cache; |
|
173 | + /** |
|
174 | + * Returns common data collection. |
|
175 | + * |
|
176 | + * @param $path string |
|
177 | + * @return Collection |
|
178 | + */ |
|
179 | + public static function getCollection($path, $silent = false) |
|
180 | + { |
|
181 | + static $cache; |
|
182 | 182 | |
183 | - if(isset($cache[$path])) { |
|
184 | - return $cache[$path]; |
|
185 | - } |
|
183 | + if(isset($cache[$path])) { |
|
184 | + return $cache[$path]; |
|
185 | + } |
|
186 | 186 | |
187 | - if (! $id = self::getId($path)) { |
|
188 | - if ($silent) return collection(); |
|
187 | + if (! $id = self::getId($path)) { |
|
188 | + if ($silent) return collection(); |
|
189 | 189 | |
190 | - new \Exception('Invalid CommonData::getArray() request: ' . $path); |
|
191 | - } |
|
190 | + new \Exception('Invalid CommonData::getArray() request: ' . $path); |
|
191 | + } |
|
192 | 192 | |
193 | - return $cache[$path] = self::where('parent_id', $id)->get(); |
|
194 | - } |
|
193 | + return $cache[$path] = self::where('parent_id', $id)->get(); |
|
194 | + } |
|
195 | 195 | |
196 | - protected static function validateArrayKeys($array) |
|
197 | - { |
|
198 | - foreach($array as $key => $value) { |
|
199 | - if (strpos($key, '/') === false) continue; |
|
196 | + protected static function validateArrayKeys($array) |
|
197 | + { |
|
198 | + foreach($array as $key => $value) { |
|
199 | + if (strpos($key, '/') === false) continue; |
|
200 | 200 | |
201 | - \Exception('Invalid common data key: '. $key); |
|
202 | - } |
|
203 | - } |
|
201 | + \Exception('Invalid common data key: '. $key); |
|
202 | + } |
|
203 | + } |
|
204 | 204 | } |
205 | 205 | \ No newline at end of file |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | static $cache; |
19 | 19 | |
20 | 20 | $parentId = null; |
21 | - foreach(explode('/', trim($path,'/')) as $nodeKey) { |
|
21 | + foreach (explode('/', trim($path, '/')) as $nodeKey) { |
|
22 | 22 | if ($nodeKey === '') continue; //ignore empty paths |
23 | 23 | |
24 | 24 | if (empty($cache[$parentId][$nodeKey])) { |
25 | - if (! $node = self::where('parent_id', $parentId)->where('key', $nodeKey)->first()) { |
|
25 | + if (!$node = self::where('parent_id', $parentId)->where('key', $nodeKey)->first()) { |
|
26 | 26 | return false; |
27 | 27 | } |
28 | 28 | |
@@ -37,19 +37,19 @@ discard block |
||
37 | 37 | |
38 | 38 | public static function newId($path, $readonly = false) |
39 | 39 | { |
40 | - if (! $path = trim($path,'/')) return false; |
|
40 | + if (!$path = trim($path, '/')) return false; |
|
41 | 41 | |
42 | 42 | $id = $parentId = null; |
43 | - foreach(explode('/', $path) as $nodeKey) { |
|
43 | + foreach (explode('/', $path) as $nodeKey) { |
|
44 | 44 | if ($nodeKey === '') continue; |
45 | 45 | |
46 | - if (! $node = self::where('parent_id', $parentId)->where('key', $nodeKey)->first()) { |
|
46 | + if (!$node = self::where('parent_id', $parentId)->where('key', $nodeKey)->first()) { |
|
47 | 47 | $node = self::create([ |
48 | 48 | 'parent_id' => $parentId, |
49 | 49 | 'key' => $nodeKey, |
50 | 50 | 'readonly' => $readonly, |
51 | 51 | 'position' => self::where('parent_id', $parentId)->count() |
52 | - ], $parentId? self::find($parentId): null); |
|
52 | + ], $parentId ? self::find($parentId) : null); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | $parentId = $id = $node->id; |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | |
61 | 61 | public static function setValue($path, $value, $overwrite = true, $readonly = false) |
62 | 62 | { |
63 | - if (! $id = self::getId($path)) { |
|
64 | - if (! $id = self::newId($path, $readonly)) return false; |
|
63 | + if (!$id = self::getId($path)) { |
|
64 | + if (!$id = self::newId($path, $readonly)) return false; |
|
65 | 65 | } else { |
66 | - if (! $overwrite) return false; |
|
66 | + if (!$overwrite) return false; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | self::find($id)->update(compact('value', 'readonly')); |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | |
78 | 78 | $key = md5(serialize([$path, $translate])); |
79 | 79 | |
80 | - if (! isset($cache[$key])) { |
|
81 | - if(! $id = self::getId($path)) return false; |
|
80 | + if (!isset($cache[$key])) { |
|
81 | + if (!$id = self::getId($path)) return false; |
|
82 | 82 | |
83 | 83 | $ret = self::find($id)->value; |
84 | 84 | |
85 | - $cache[$key] = $translate? __($ret): $ret; |
|
85 | + $cache[$key] = $translate ? __($ret) : $ret; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | return $cache[$key]; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $path = trim($path, '/'); |
105 | 105 | |
106 | 106 | if ($id = self::getId($path)) { |
107 | - if (! $overwrite) { |
|
107 | + if (!$overwrite) { |
|
108 | 108 | self::extendArray($path, $array); |
109 | 109 | return true; |
110 | 110 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | self::find($id)->delete(); |
113 | 113 | } |
114 | 114 | |
115 | - if(! $id = self::newId($path, $readonly)) return false; |
|
115 | + if (!$id = self::newId($path, $readonly)) return false; |
|
116 | 116 | |
117 | 117 | if ($overwrite) { |
118 | 118 | self::find($id)->update(compact('readonly')); |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | * @param $array array values to insert |
133 | 133 | * @param $overwrite bool whether method should overwrite data if array key already exists, otherwise the data will be preserved |
134 | 134 | */ |
135 | - public static function extendArray($path, $array, $overwrite=false, $readonly=false) |
|
135 | + public static function extendArray($path, $array, $overwrite = false, $readonly = false) |
|
136 | 136 | { |
137 | 137 | self::validateArrayKeys($array); |
138 | 138 | |
139 | 139 | $path = trim($path, '/'); |
140 | 140 | |
141 | - if (! self::getId($path)){ |
|
141 | + if (!self::getId($path)) { |
|
142 | 142 | return self::newArray($path, $array, $overwrite, $readonly); |
143 | 143 | } |
144 | 144 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param $path string |
165 | 165 | * @return true on success, false otherwise |
166 | 166 | */ |
167 | - public static function deleteArray($path){ |
|
168 | - if (! $id = self::getId($path, true)) return false; |
|
167 | + public static function deleteArray($path) { |
|
168 | + if (!$id = self::getId($path, true)) return false; |
|
169 | 169 | |
170 | 170 | self::find($id)->delete(); |
171 | 171 | } |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | { |
181 | 181 | static $cache; |
182 | 182 | |
183 | - if(isset($cache[$path])) { |
|
183 | + if (isset($cache[$path])) { |
|
184 | 184 | return $cache[$path]; |
185 | 185 | } |
186 | 186 | |
187 | - if (! $id = self::getId($path)) { |
|
187 | + if (!$id = self::getId($path)) { |
|
188 | 188 | if ($silent) return collection(); |
189 | 189 | |
190 | 190 | new \Exception('Invalid CommonData::getArray() request: ' . $path); |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | |
196 | 196 | protected static function validateArrayKeys($array) |
197 | 197 | { |
198 | - foreach($array as $key => $value) { |
|
198 | + foreach ($array as $key => $value) { |
|
199 | 199 | if (strpos($key, '/') === false) continue; |
200 | 200 | |
201 | - \Exception('Invalid common data key: '. $key); |
|
201 | + \Exception('Invalid common data key: ' . $key); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | } |
205 | 205 | \ No newline at end of file |
@@ -19,7 +19,10 @@ discard block |
||
19 | 19 | |
20 | 20 | $parentId = null; |
21 | 21 | foreach(explode('/', trim($path,'/')) as $nodeKey) { |
22 | - if ($nodeKey === '') continue; //ignore empty paths |
|
22 | + if ($nodeKey === '') { |
|
23 | + continue; |
|
24 | + } |
|
25 | + //ignore empty paths |
|
23 | 26 | |
24 | 27 | if (empty($cache[$parentId][$nodeKey])) { |
25 | 28 | if (! $node = self::where('parent_id', $parentId)->where('key', $nodeKey)->first()) { |
@@ -37,11 +40,15 @@ discard block |
||
37 | 40 | |
38 | 41 | public static function newId($path, $readonly = false) |
39 | 42 | { |
40 | - if (! $path = trim($path,'/')) return false; |
|
43 | + if (! $path = trim($path,'/')) { |
|
44 | + return false; |
|
45 | + } |
|
41 | 46 | |
42 | 47 | $id = $parentId = null; |
43 | 48 | foreach(explode('/', $path) as $nodeKey) { |
44 | - if ($nodeKey === '') continue; |
|
49 | + if ($nodeKey === '') { |
|
50 | + continue; |
|
51 | + } |
|
45 | 52 | |
46 | 53 | if (! $node = self::where('parent_id', $parentId)->where('key', $nodeKey)->first()) { |
47 | 54 | $node = self::create([ |
@@ -61,9 +68,13 @@ discard block |
||
61 | 68 | public static function setValue($path, $value, $overwrite = true, $readonly = false) |
62 | 69 | { |
63 | 70 | if (! $id = self::getId($path)) { |
64 | - if (! $id = self::newId($path, $readonly)) return false; |
|
71 | + if (! $id = self::newId($path, $readonly)) { |
|
72 | + return false; |
|
73 | + } |
|
65 | 74 | } else { |
66 | - if (! $overwrite) return false; |
|
75 | + if (! $overwrite) { |
|
76 | + return false; |
|
77 | + } |
|
67 | 78 | } |
68 | 79 | |
69 | 80 | self::find($id)->update(compact('value', 'readonly')); |
@@ -78,7 +89,9 @@ discard block |
||
78 | 89 | $key = md5(serialize([$path, $translate])); |
79 | 90 | |
80 | 91 | if (! isset($cache[$key])) { |
81 | - if(! $id = self::getId($path)) return false; |
|
92 | + if(! $id = self::getId($path)) { |
|
93 | + return false; |
|
94 | + } |
|
82 | 95 | |
83 | 96 | $ret = self::find($id)->value; |
84 | 97 | |
@@ -112,7 +125,9 @@ discard block |
||
112 | 125 | self::find($id)->delete(); |
113 | 126 | } |
114 | 127 | |
115 | - if(! $id = self::newId($path, $readonly)) return false; |
|
128 | + if(! $id = self::newId($path, $readonly)) { |
|
129 | + return false; |
|
130 | + } |
|
116 | 131 | |
117 | 132 | if ($overwrite) { |
118 | 133 | self::find($id)->update(compact('readonly')); |
@@ -165,7 +180,9 @@ discard block |
||
165 | 180 | * @return true on success, false otherwise |
166 | 181 | */ |
167 | 182 | public static function deleteArray($path){ |
168 | - if (! $id = self::getId($path, true)) return false; |
|
183 | + if (! $id = self::getId($path, true)) { |
|
184 | + return false; |
|
185 | + } |
|
169 | 186 | |
170 | 187 | self::find($id)->delete(); |
171 | 188 | } |
@@ -185,7 +202,9 @@ discard block |
||
185 | 202 | } |
186 | 203 | |
187 | 204 | if (! $id = self::getId($path)) { |
188 | - if ($silent) return collection(); |
|
205 | + if ($silent) { |
|
206 | + return collection(); |
|
207 | + } |
|
189 | 208 | |
190 | 209 | new \Exception('Invalid CommonData::getArray() request: ' . $path); |
191 | 210 | } |
@@ -196,7 +215,9 @@ discard block |
||
196 | 215 | protected static function validateArrayKeys($array) |
197 | 216 | { |
198 | 217 | foreach($array as $key => $value) { |
199 | - if (strpos($key, '/') === false) continue; |
|
218 | + if (strpos($key, '/') === false) { |
|
219 | + continue; |
|
220 | + } |
|
200 | 221 | |
201 | 222 | \Exception('Invalid common data key: '. $key); |
202 | 223 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | ActionBar::addButton('back')->link(url('view/system')); |
32 | 32 | |
33 | - $this->parentId = $this->stickyGet('parentId')?: null; |
|
33 | + $this->parentId = $this->stickyGet('parentId') ?: null; |
|
34 | 34 | |
35 | 35 | $this->displayBreadCrumb(); |
36 | 36 | |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | |
76 | 76 | $this->grid->setModel($model = $this->getModel()); |
77 | 77 | |
78 | - if ($model->action('count')->getOne() ) { |
|
78 | + if ($model->action('count')->getOne()) { |
|
79 | 79 | $this->grid->on('click', 'td', new jsExpression( |
80 | 80 | 'document.location=\'?parentId=\'+[]', |
81 | 81 | [(new jQuery())->closest('tr')->data('id')] |
82 | 82 | )); |
83 | 83 | } |
84 | 84 | |
85 | - $this->grid->addDragHandler()->onReorder(function ($order) { |
|
85 | + $this->grid->addDragHandler()->onReorder(function($order) { |
|
86 | 86 | $result = true; |
87 | 87 | foreach ($this->nodes()->get() as $node) { |
88 | 88 | $node->position = array_search($node->id, $order); |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | $result &= $node->save(); |
91 | 91 | } |
92 | 92 | |
93 | - $notifier = $result? $this->notify(__('Items reordered!')): $this->notifyError(__('Error saving order!')); |
|
93 | + $notifier = $result ? $this->notify(__('Items reordered!')) : $this->notifyError(__('Error saving order!')); |
|
94 | 94 | |
95 | 95 | return $this->grid->jsSave($notifier); |
96 | 96 | }); |
97 | 97 | |
98 | 98 | $this->addContolButton('update', $this->getUpdateModal(), 'edit'); |
99 | 99 | |
100 | - $this->addContolButton('delete', function ($jschain, $id) { |
|
100 | + $this->addContolButton('delete', function($jschain, $id) { |
|
101 | 101 | CommonData::find($id)->delete(); |
102 | 102 | |
103 | 103 | return $jschain->closest('tr')->transition('fade left'); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $ret .= $button->getHtml(); |
120 | 120 | } |
121 | 121 | |
122 | - return $ret;; |
|
122 | + return $ret; ; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | public function getUpdateModal() |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | |
129 | 129 | $grid->pageUpdate = $grid->add($grid->pageUpdate ?: $grid->pageDefault, ['short_name'=>'edit']); |
130 | 130 | |
131 | - $modal = new jsModal(__('Edit'), $grid->pageUpdate, [$grid->name => $grid->jsRow()->data('id'), $grid->name.'_sort' => $grid->getSortBy()]); |
|
131 | + $modal = new jsModal(__('Edit'), $grid->pageUpdate, [$grid->name => $grid->jsRow()->data('id'), $grid->name . '_sort' => $grid->getSortBy()]); |
|
132 | 132 | |
133 | - $grid->pageUpdate->set(function () { |
|
133 | + $grid->pageUpdate->set(function() { |
|
134 | 134 | $grid = $this->grid; |
135 | 135 | |
136 | 136 | $grid->model->load($grid->app->stickyGet($grid->name)); |
@@ -143,13 +143,13 @@ discard block |
||
143 | 143 | $grid->formUpdate->setModel($grid->model, $grid->fieldsUpdate ?: $grid->fieldsDefault); |
144 | 144 | |
145 | 145 | if ($sortBy = $grid->getSortBy()) { |
146 | - $grid->formUpdate->stickyGet($grid->name.'_sort', $sortBy); |
|
146 | + $grid->formUpdate->stickyGet($grid->name . '_sort', $sortBy); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | // set save handler with reload trigger |
150 | 150 | // adds default submit hook if it is not already set for this form |
151 | 151 | if (!$grid->formUpdate->hookHasCallbacks('submit')) { |
152 | - $grid->formUpdate->onSubmit(function ($form) { |
|
152 | + $grid->formUpdate->onSubmit(function($form) { |
|
153 | 153 | $form->model->save(); |
154 | 154 | |
155 | 155 | return $this->grid->jsSaveUpdate(); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | $this->grid->on('click', ".$class", $callback, [$this->grid->table->jsRow()->data('id')]); |
168 | 168 | |
169 | - $this->buttons[$name] = new \atk4\ui\Button($icon? compact('icon'): $name); |
|
169 | + $this->buttons[$name] = new \atk4\ui\Button($icon ? compact('icon') : $name); |
|
170 | 170 | |
171 | 171 | $this->buttons[$name]->app = $this->app; |
172 | 172 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | $rowsEmpty = []; |
195 | 195 | |
196 | - $model = new \atk4\data\Model($rows? new \atk4\data\Persistence_Static($rows): new \atk4\data\Persistence_Array($rowsEmpty)); |
|
196 | + $model = new \atk4\data\Model($rows ? new \atk4\data\Persistence_Static($rows) : new \atk4\data\Persistence_Array($rowsEmpty)); |
|
197 | 197 | |
198 | 198 | $captions = [ |
199 | 199 | 'position' => __('Position'), |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | ]; |
204 | 204 | |
205 | 205 | foreach ($captions as $key => $caption) { |
206 | - $field = $rows? $model->hasField($key): $model->addField($key); |
|
206 | + $field = $rows ? $model->hasField($key) : $model->addField($key); |
|
207 | 207 | |
208 | 208 | if ($key === 'readonly') { |
209 | 209 | $field->setDefaults(['ui' => ['visible' => false]]); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | public function getNodeForm() |
221 | 221 | { |
222 | - if (! $this->form) { |
|
222 | + if (!$this->form) { |
|
223 | 223 | $this->form = new Form(['buttonSave' => ['Button', __('Save'), 'primary']]); |
224 | 224 | |
225 | 225 | $this->form->addHook('submit', function($form) { |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | CommonData::create(array_merge($values, [ |
235 | 235 | 'position' => $this->nodes()->max('position') + 1 |
236 | - ]), $this->parentId? CommonData::find($this->parentId): null); |
|
236 | + ]), $this->parentId ? CommonData::find($this->parentId) : null); |
|
237 | 237 | |
238 | 238 | return $this->grid->jsSaveCreate(); |
239 | 239 | }); |
@@ -112,7 +112,9 @@ |
||
112 | 112 | |
113 | 113 | public function getControlButtonsHtml($row) |
114 | 114 | { |
115 | - if ($row['readonly']) return ''; |
|
115 | + if ($row['readonly']) { |
|
116 | + return ''; |
|
117 | + } |
|
116 | 118 | |
117 | 119 | $ret = ''; |
118 | 120 | foreach ($this->buttons as $button) { |