From ca4ddd547bcd57a5b7f0b763fcdbcc1ee622f4e3 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:00:51 +0100 Subject: [PATCH] V3 Develop to V3 Master (#1439) Co-authored-by: lrljoe * v3 - Adding CollapseAlways Option for Columns (#1403) * Add CollapseAlways & Fix ReorderColumn * Remove superfluous md:hidden from the icon * Tweaks for Column Collapsing For BS4/BS5 * Fix Collapsed on Bootstrap * Tweak Bootstrap Theme --------- Co-authored-by: lrljoe * Minor tweaks to blades for reorder cols (#1411) * V3 - Fix Reorder For Bootstrap (#1412) * Minor tweaks to blades for reorder cols * Bootstrap Reorder Toggle * Add DiscordBot (#1413) * Docs livewire namespace fix (#1420) * Fixed Livewire namespace in docs * Updated livewire url in docs * V3 - Fix Localisation (#1424) * Fix Localisations * Fix styling * Load Original and Publish Localisation Paths * Fix styling --------- Co-authored-by: lrljoe * v3 - Add Loading Placeholder (#1421) * Initial Loading Placeholder Code, Use Hourglass Spinner * Add wrappers, Class Merging, Colouring * Renaming Traits - Adding LoadingPlaceholder Tests, Add Placeholder Test Table * Update Docs for Placeholder --------- Co-authored-by: lrljoe * v3 - Column - Allow Enum in ReturnType for Column getContent/renderContent (#1436) * Fix Enum Column Return TypeHints * v3 - Add "Confirmation" Option to Bulk Actions (#1437) * Add BulkActionConfirms * Add wire:confirm capability to bulk actions * Update Changelog * Fix error with typehinting * Add Tests * Adding default confirmation message customisation * Update Default Message * Update Tests --------- Co-authored-by: lrljoe --------- Co-authored-by: lrljoe Co-authored-by: Anthony Rappa --- CHANGELOG.md | 9 ++- docs/bulk-actions/available-methods.md | 51 ++++++++++++++++ resources/lang/en.json | 1 + .../tools/toolbar/bootstrap.blade.php | 3 + .../tools/toolbar/tailwind.blade.php | 3 + .../BulkActionsConfiguration.php | 34 +++++++++++ src/Traits/Helpers/BulkActionsHelpers.php | 22 ++++++- src/Traits/WithBulkActions.php | 10 ++-- src/Views/Traits/Helpers/ColumnHelpers.php | 4 +- .../BulkActionsConfigurationTest.php | 59 +++++++++++++++++++ .../Traits/Helpers/BulkActionsHelpersTest.php | 24 ++++++++ 11 files changed, 210 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddd8715db..abfd018ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,14 @@ All notable changes to `laravel-livewire-tables` will be documented in this file -## [3.0.0-beta.4] - 2023-10-17 +## [3.0.0-beta.4] - 2023-10-25 +- Fix Return Type hinting for Column Rendering to allow Enum columns +- Add Bulk Action Confirmations, using wire:confirm + - setBulkActionConfirms + - setBulkActionConfirmMessage + - setBulkActionConfirmMessages + - setBulkActionDefaultConfirmationMessage + - Localisation for confirmation message - Introduction of Loading Placeholder - Docs livewire namespace fix [Here](https://github.com/rappasoft/laravel-livewire-tables/pull/1420) - Add CollapseAlways capability for Columns diff --git a/docs/bulk-actions/available-methods.md b/docs/bulk-actions/available-methods.md index 245e99a2b..41507dc24 100644 --- a/docs/bulk-actions/available-methods.md +++ b/docs/bulk-actions/available-methods.md @@ -133,3 +133,54 @@ public function configure(): void $this->setHideBulkActionsWhenEmptyDisabled(); } ``` + +## setBulkActionConfirms + +When a bulk action is included in the array passed to setBulkActionConfirms, the default wire:confirm pop-up will appear prior to executing the bulk action. The default message is: "Are you sure?". This should only be used if you wish to use the default message. + +```php +public function configure(): void +{ + $this->setBulkActionConfirms([ + 'delete', + 'reset' + ]); +} +``` +## setBulkActionDefaultConfirmationMessage + +You may use this method to over-ride the default message. To override the confirmation message for an individual Bulk Action, see the below setBulkActionConfirmMessage and setBulkActionConfirmMessages. You may also use the language files to do this. + +```php +public function configure(): void +{ + $this->setBulkActionDefaultConfirmationMessage('Are you certain?'); +} +``` + +## setBulkActionConfirmMessage + +You may use this method to specify a message other than the default message. + +```php +public function configure(): void +{ + $this->setBulkActionConfirmMessage('delete', 'Do you want to delete these items?'); +} +``` + +## setBulkActionConfirmMessages + +You may pass an array to this method, to more effectively update the confirmation message for a larger quantity of bulk actions. This expects an array keyed by the bulk action name, with the value being the message that will be displayed to the user. + +```php +public function configure(): void +{ + $this->setBulkActionConfirmMessages([ + 'delete' => 'Are you sure you want to delete these items?', + 'purge' => 'Are you sure you want to purge these items?', + 'reassign' => 'This will reassign selected items, are you sure?', + ]); +} +``` + diff --git a/resources/lang/en.json b/resources/lang/en.json index 0456f57e2..87b34925e 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -4,6 +4,7 @@ "Applied Filters": "Applied Filters", "Applied Sorting": "Applied Sorting", "Bulk Actions": "Bulk Actions", + "Bulk Actions Confirm": "Are you sure?", "Clear": "Clear", "Columns": "Columns", "Debugging Values": "Debugging Values", diff --git a/resources/views/components/tools/toolbar/bootstrap.blade.php b/resources/views/components/tools/toolbar/bootstrap.blade.php index 2cb4e0b98..ca8e516c8 100644 --- a/resources/views/components/tools/toolbar/bootstrap.blade.php +++ b/resources/views/components/tools/toolbar/bootstrap.blade.php @@ -220,6 +220,9 @@ hasConfirmationMessage($action)) + wire:confirm="{{ $component->getBulkActionConfirmMessage($action) }}" + @endif wire:key="{{ $tableName }}-bulk-action-{{ $action }}" @class([ 'dropdown-item' => $component->isBootstrap(), diff --git a/resources/views/components/tools/toolbar/tailwind.blade.php b/resources/views/components/tools/toolbar/tailwind.blade.php index 51a3e4ab0..7daa59c67 100644 --- a/resources/views/components/tools/toolbar/tailwind.blade.php +++ b/resources/views/components/tools/toolbar/tailwind.blade.php @@ -186,6 +186,9 @@ class="origin-top-right absolute right-0 mt-2 w-full md:w-48 rounded-md shadow-l @foreach ($component->getBulkActions() as $action => $title)