@@ -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'); |
|
| 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'); |
|
| 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'); |
|
| 30 | - $table->smallInteger('row'); |
|
| 31 | - $table->text('options'); |
|
| 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'); |
|
| 30 | + $table->smallInteger('row'); |
|
| 31 | + $table->text('options'); |
|
| 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 | } |
@@ -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'); |
| 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); |
@@ -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 | |