diff --git a/CHANGELOG.md b/CHANGELOG.md index c94621b..e27e605 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [5.0.2](https://github.com/Okipa/laravel-table/compare/5.0.1...5.0.2) + +2022-10-07 + +* Fixed wrong `form-select` class uses for Bootstrap 4 template selects: replaced them by `custom-select` +* Fixed Column action still displays original column value with ->when(false) : #103 + ## [5.0.1](https://github.com/Okipa/laravel-table/compare/5.0.0...5.0.1) 2022-09-26 diff --git a/resources/views/bootstrap-4/filter.blade.php b/resources/views/bootstrap-4/filter.blade.php index 77fa958..1a5f45f 100644 --- a/resources/views/bootstrap-4/filter.blade.php +++ b/resources/views/bootstrap-4/filter.blade.php @@ -1,5 +1,5 @@
- class(['custom-select', ...$class]) }}> @foreach($options as $optionValue => $optionLabel) diff --git a/resources/views/bootstrap-4/table.blade.php b/resources/views/bootstrap-4/table.blade.php index ec6cff6..0b58694 100644 --- a/resources/views/bootstrap-4/table.blade.php +++ b/resources/views/bootstrap-4/table.blade.php @@ -93,7 +93,7 @@ class="btn btn-sm btn-link text-secondary p-0" {!! config('laravel-table.icon.rows_number') !!}
- merge([ 'placeholder' => __('Number of rows per page'), 'aria-label' => __('Number of rows per page'), 'aria-describedby' => 'rows-number-per-page-icon', @@ -196,11 +196,11 @@ class="d-flex align-items-center" {{-- Row columns values --}} @foreach($columns as $column) @if($loop->first) - + {!! $orderColumn ? '' . config('laravel-table.icon.drag_drop') . '' : null !!}{{ $column->getValue($model, $tableColumnActionsArray) }} @else - + {{ $column->getValue($model, $tableColumnActionsArray) }} @endif diff --git a/resources/views/bootstrap-5/table.blade.php b/resources/views/bootstrap-5/table.blade.php index 2cd8c75..560d0e1 100644 --- a/resources/views/bootstrap-5/table.blade.php +++ b/resources/views/bootstrap-5/table.blade.php @@ -188,11 +188,11 @@ class="d-flex align-items-center" {{-- Row columns values --}} @foreach($columns as $column) @if($loop->first) - + {!! $orderColumn ? '' . config('laravel-table.icon.drag_drop') . '' : null !!}{{ $column->getValue($model, $tableColumnActionsArray) }} @else - + {{ $column->getValue($model, $tableColumnActionsArray) }} @endif diff --git a/src/Livewire/Table.php b/src/Livewire/Table.php index ab51d0e..2d73151 100644 --- a/src/Livewire/Table.php +++ b/src/Livewire/Table.php @@ -297,6 +297,9 @@ public function rowAction(string $identifier, string $modelKey, bool $requiresCo } $rowActionArray = collect($rowActionsArray)->where('identifier', $identifier)->first(); $rowActionInstance = AbstractRowAction::make($rowActionArray); + if (! $rowActionInstance->isAllowed()) { + return null; + } $model = app($rowActionArray['modelClass'])->findOrFail($modelKey); if ($requiresConfirmation) { return $this->emit( @@ -322,6 +325,9 @@ public function columnAction(string $identifier, string $modelKey, bool $require return null; } $columnActionInstance = AbstractColumnAction::make($columnActionArray); + if (! $columnActionInstance->isAllowed()) { + return null; + } $model = app($columnActionArray['modelClass'])->findOrFail($modelKey); if ($requiresConfirmation) { return $this->emit( diff --git a/src/Table.php b/src/Table.php index 87aec73..fe241bb 100644 --- a/src/Table.php +++ b/src/Table.php @@ -454,9 +454,6 @@ public function generateColumnActionsArray(): array ->filter(); foreach ($columnActions as $attribute => $columnAction) { $columnAction->setup($model, $attribute); - if (! $columnAction->isAllowed()) { - continue; - } $tableColumnActionsArray[] = json_decode(json_encode( $columnAction, JSON_THROW_ON_ERROR diff --git a/tests/Unit/Bootstrap4/ColumnActionTest.php b/tests/Unit/Bootstrap4/ColumnActionTest.php index d1d4494..a1ebd31 100644 --- a/tests/Unit/Bootstrap4/ColumnActionTest.php +++ b/tests/Unit/Bootstrap4/ColumnActionTest.php @@ -50,6 +50,10 @@ protected function columns(): array ->assertSeeHtmlInOrder([ '', '', + '', + $users->first()->name, + '', + '', '', 'email-verified-icon', '', + '', + '', '', 'toggle-on-icon', '', + '', '', '', + '', + $users->last()->name, + '', + '', '', 'email-unverified-icon', '', + '', + '', '', 'toggle-off-icon', '', + '', '', '', ]) diff --git a/tests/Unit/Bootstrap4/TableFiltersTest.php b/tests/Unit/Bootstrap4/TableFiltersTest.php index 7df9998..48dbc1b 100644 --- a/tests/Unit/Bootstrap4/TableFiltersTest.php +++ b/tests/Unit/Bootstrap4/TableFiltersTest.php @@ -66,7 +66,7 @@ protected function columns(): array '
', '
', '', '', @@ -99,7 +99,7 @@ protected function columns(): array '
', '
', '', '', @@ -139,7 +139,7 @@ protected function columns(): array '
', '
', '', diff --git a/tests/Unit/Bootstrap4/TableNumberOfRowsPerPageTest.php b/tests/Unit/Bootstrap4/TableNumberOfRowsPerPageTest.php index c9b2bd1..d661ad4 100644 --- a/tests/Unit/Bootstrap4/TableNumberOfRowsPerPageTest.php +++ b/tests/Unit/Bootstrap4/TableNumberOfRowsPerPageTest.php @@ -43,7 +43,7 @@ protected function columns(): array 'rows-number-icon', '', '
', - '', '', '