From b09c351b5b0b4c524c684c3f0df4d5d35ff072af Mon Sep 17 00:00:00 2001 From: LRLJoe Date: Tue, 3 Dec 2024 23:08:22 +0000 Subject: [PATCH 1/5] Add initial commit with basic tests --- .../table/tr/bulk-actions.blade.php | 206 +++++++----------- .../BulkActionStylingConfiguration.php | 13 ++ src/Traits/Styling/HasBulkActionsStyling.php | 3 + .../Helpers/BulkActionStylingHelpers.php | 15 ++ .../BulkActionsStylingConfigurationTest.php | 1 + 5 files changed, 115 insertions(+), 123 deletions(-) diff --git a/resources/views/components/table/tr/bulk-actions.blade.php b/resources/views/components/table/tr/bulk-actions.blade.php index 11ecc95a8..4b85d49a6 100644 --- a/resources/views/components/table/tr/bulk-actions.blade.php +++ b/resources/views/components/table/tr/bulk-actions.blade.php @@ -1,4 +1,4 @@ -@aware([ 'tableName','isTailwind','isBootstrap']) +@aware([ 'tableName']) @if ($this->bulkActionsAreEnabled() && $this->hasBulkActions()) @php @@ -7,134 +7,94 @@ $simplePagination = $this->isPaginationMethod('simple'); @endphp - @if ($isTailwind) - - - - - - - - @elseif ($isBootstrap) - - - + + + + @endif diff --git a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php index 9c61f9eba..12b1d31d7 100644 --- a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php @@ -73,4 +73,17 @@ public function setBulkActionsThCheckboxAttributes(array $bulkActionsThCheckboxA return $this; } + + /** + * Used to set attributes for the Bulk Actions Row Buttons + * + */ + #[Computed] + public function setBulkActionsRowButtonAttributes(array $bulkActionsRowButtonAttributes): self + { + $this->setCustomAttributes('bulkActionsRowButtonAttributes', $bulkActionsRowButtonAttributes); + + return $this; + } + } diff --git a/src/Traits/Styling/HasBulkActionsStyling.php b/src/Traits/Styling/HasBulkActionsStyling.php index c1f1b1aca..34eb5ecf0 100644 --- a/src/Traits/Styling/HasBulkActionsStyling.php +++ b/src/Traits/Styling/HasBulkActionsStyling.php @@ -25,4 +25,7 @@ trait HasBulkActionsStyling protected array $bulkActionsMenuAttributes = ['default-colors' => true, 'default-styling' => true]; protected array $bulkActionsMenuItemAttributes = ['default-colors' => true, 'default-styling' => true]; + + protected array $bulkActionsRowButtonAttributes = ['default-colors' => true, 'default-styling' => true]; + } diff --git a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php index 6c100c345..f64099b25 100644 --- a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php +++ b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php @@ -3,6 +3,7 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers; use Livewire\Attributes\Computed; +use Illuminate\View\ComponentAttributeBag; trait BulkActionStylingHelpers { @@ -93,4 +94,18 @@ public function getBulkActionsTdCheckboxAttributes(): array return $this->getCustomAttributes('bulkActionsTdCheckboxAttributes'); } + + /** + * Used to get attributes for the Bulk Actions Row Buttons + * + * @return array + */ + #[Computed] + public function getBulkActionsRowButtonAttributes(): array + { + return $this->getCustomAttributes('bulkActionsRowButtonAttributes', true); + + } + + } diff --git a/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php b/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php index fb321a1c4..019c13d22 100644 --- a/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php +++ b/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php @@ -32,6 +32,7 @@ public static function providesBulkActionMethodsToTest(): array 'BulkActionsThCheckboxAttributes', 'BulkActionsTdAttributes', 'BulkActionsTdCheckboxAttributes', + 'BulkActionsRowButtonAttributes', ]; } From c69c414e0349e60891e67aec45eeb29e9c49e2b8 Mon Sep 17 00:00:00 2001 From: lrljoe Date: Tue, 3 Dec 2024 23:08:54 +0000 Subject: [PATCH 2/5] Fix styling --- .../Styling/Configuration/BulkActionStylingConfiguration.php | 2 -- src/Traits/Styling/HasBulkActionsStyling.php | 1 - src/Traits/Styling/Helpers/BulkActionStylingHelpers.php | 4 +--- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php index 12b1d31d7..96cd5353f 100644 --- a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php @@ -76,7 +76,6 @@ public function setBulkActionsThCheckboxAttributes(array $bulkActionsThCheckboxA /** * Used to set attributes for the Bulk Actions Row Buttons - * */ #[Computed] public function setBulkActionsRowButtonAttributes(array $bulkActionsRowButtonAttributes): self @@ -85,5 +84,4 @@ public function setBulkActionsRowButtonAttributes(array $bulkActionsRowButtonAtt return $this; } - } diff --git a/src/Traits/Styling/HasBulkActionsStyling.php b/src/Traits/Styling/HasBulkActionsStyling.php index 34eb5ecf0..07bf1f133 100644 --- a/src/Traits/Styling/HasBulkActionsStyling.php +++ b/src/Traits/Styling/HasBulkActionsStyling.php @@ -27,5 +27,4 @@ trait HasBulkActionsStyling protected array $bulkActionsMenuItemAttributes = ['default-colors' => true, 'default-styling' => true]; protected array $bulkActionsRowButtonAttributes = ['default-colors' => true, 'default-styling' => true]; - } diff --git a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php index f64099b25..1599d9917 100644 --- a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php +++ b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php @@ -2,8 +2,8 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers; -use Livewire\Attributes\Computed; use Illuminate\View\ComponentAttributeBag; +use Livewire\Attributes\Computed; trait BulkActionStylingHelpers { @@ -106,6 +106,4 @@ public function getBulkActionsRowButtonAttributes(): array return $this->getCustomAttributes('bulkActionsRowButtonAttributes', true); } - - } From 0541611cd737e38ad14479ec2a19dbb7cef6a897 Mon Sep 17 00:00:00 2001 From: LRLJoe Date: Tue, 3 Dec 2024 23:16:59 +0000 Subject: [PATCH 3/5] Adjust for AttributeBag --- .../views/components/table/tr/bulk-actions.blade.php | 8 ++++---- .../Styling/Helpers/BulkActionStylingHelpers.php | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/resources/views/components/table/tr/bulk-actions.blade.php b/resources/views/components/table/tr/bulk-actions.blade.php index 4b85d49a6..e63d18df2 100644 --- a/resources/views/components/table/tr/bulk-actions.blade.php +++ b/resources/views/components/table/tr/bulk-actions.blade.php @@ -28,7 +28,7 @@ wire:loading.attr="disabled" type="button" {{ - $attributes->merge($this->getBulkActionsRowButtonAttributes)->class([ + $this->getBulkActionsRowButtonAttributesBag->class([ 'ml-1 underline text-sm leading-5 font-medium focus:outline-none focus:underline transition duration-150 ease-in-out' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true), 'text-blue-600 text-gray-700 focus:text-gray-800 dark:text-white dark:hover:text-gray-400' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-colors'] ?? true), 'btn btn-primary btn-sm' => $this->isBootstrap && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true) @@ -54,7 +54,7 @@ wire:loading.attr="disabled" type="button" {{ - $attributes->merge($this->getBulkActionsRowButtonAttributes)->class([ + $this->getBulkActionsRowButtonAttributesBag->class([ 'ml-1 underline text-sm leading-5 font-medium focus:outline-none focus:underline transition duration-150 ease-in-out' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true), 'text-blue-600 text-gray-700 focus:text-gray-800 dark:text-white dark:hover:text-gray-400' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-colors'] ?? true), 'btn btn-primary btn-sm' => $this->isBootstrap && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true) @@ -69,7 +69,7 @@ wire:loading.attr="disabled" type="button" {{ - $attributes->merge($this->getBulkActionsRowButtonAttributes)->class([ + $this->getBulkActionsRowButtonAttributesBag->class([ 'ml-1 underline text-sm leading-5 font-medium focus:outline-none focus:underline transition duration-150 ease-in-out' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true), 'text-blue-600 text-gray-700 focus:text-gray-800 dark:text-white dark:hover:text-gray-400' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-colors'] ?? true), 'btn btn-primary btn-sm' => $this->isBootstrap && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true) @@ -84,7 +84,7 @@ wire:loading.attr="disabled" type="button" {{ - $attributes->merge($this->getBulkActionsRowButtonAttributes)->class([ + $this->getBulkActionsRowButtonAttributesBag->class([ 'ml-1 underline text-sm leading-5 font-medium focus:outline-none focus:underline transition duration-150 ease-in-out' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true), 'text-blue-600 text-gray-700 focus:text-gray-800 dark:text-white dark:hover:text-gray-400' => $this->isTailwind && ($this->getBulkActionsRowButtonAttributes['default-colors'] ?? true), 'btn btn-primary btn-sm' => $this->isBootstrap && ($this->getBulkActionsRowButtonAttributes['default-styling'] ?? true) diff --git a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php index 1599d9917..7a513958d 100644 --- a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php +++ b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php @@ -2,8 +2,8 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers; -use Illuminate\View\ComponentAttributeBag; use Livewire\Attributes\Computed; +use Illuminate\View\ComponentAttributeBag; trait BulkActionStylingHelpers { @@ -106,4 +106,12 @@ public function getBulkActionsRowButtonAttributes(): array return $this->getCustomAttributes('bulkActionsRowButtonAttributes', true); } + + #[Computed] + public function getBulkActionsRowButtonAttributesBag(): ComponentAttributeBag + { + return $this->getCustomAttributesBagFromArray($this->getBulkActionsRowButtonAttributes()); + } + + } From 639d37a9f79ea1b57db65a39910239030f4e210f Mon Sep 17 00:00:00 2001 From: lrljoe Date: Tue, 3 Dec 2024 23:17:27 +0000 Subject: [PATCH 4/5] Fix styling --- src/Traits/Styling/Helpers/BulkActionStylingHelpers.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php index 7a513958d..adc3cea89 100644 --- a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php +++ b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php @@ -2,8 +2,8 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers; -use Livewire\Attributes\Computed; use Illuminate\View\ComponentAttributeBag; +use Livewire\Attributes\Computed; trait BulkActionStylingHelpers { @@ -112,6 +112,4 @@ public function getBulkActionsRowButtonAttributesBag(): ComponentAttributeBag { return $this->getCustomAttributesBagFromArray($this->getBulkActionsRowButtonAttributes()); } - - } From 5ad3f4991258c679307cae97d3b8048044ce2c9a Mon Sep 17 00:00:00 2001 From: LRLJoe Date: Tue, 3 Dec 2024 23:18:08 +0000 Subject: [PATCH 5/5] Remove Computed from Set --- .../Styling/Configuration/BulkActionStylingConfiguration.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php index 96cd5353f..6f74ed5a3 100644 --- a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php @@ -77,7 +77,6 @@ public function setBulkActionsThCheckboxAttributes(array $bulkActionsThCheckboxA /** * Used to set attributes for the Bulk Actions Row Buttons */ - #[Computed] public function setBulkActionsRowButtonAttributes(array $bulkActionsRowButtonAttributes): self { $this->setCustomAttributes('bulkActionsRowButtonAttributes', $bulkActionsRowButtonAttributes);