From 5b88b0da8dad9708d5513f02de0d7b5a1194327d Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 19 May 2023 00:04:54 +0100 Subject: [PATCH] AlpineJS - Bulk Actions Fixes (#1218) * Start of AlpineJS Cleanup * Fix styling * Interim Fixes - Removing unnecessary variables * Fixes for Checkboxes * Theme to Conditional Class in Bulk Actions th & td * Adjust wrapper for no bulk actions * Wrapper tweak to cater for no bulk actions * ReorderingVisualsTest fix for AlpineJS * Fix pagination totals * Fix styling * Pagination - AlpineJS Tweaks * Fix PaginationCurrentItems * Bulk Actions - Indeterminate * Fix ReorderingVisualsTest again,changelog updated --------- Co-authored-by: lrljoe --- .gitignore | 1 + CHANGELOG.md | 24 +++++-- .../views/components/pagination.blade.php | 12 ++-- .../table/td/bulk-actions.blade.php | 40 ++++------- .../table/th/bulk-actions.blade.php | 48 ++++++-------- .../table/tr/bulk-actions.blade.php | 23 +++---- .../views/components/tools/toolbar.blade.php | 6 +- resources/views/components/wrapper.blade.php | 66 +++++++++---------- src/Traits/WithData.php | 10 ++- src/Traits/WithPagination.php | 1 + .../Traits/Visuals/ReorderingVisualsTest.php | 2 +- 11 files changed, 113 insertions(+), 120 deletions(-) diff --git a/.gitignore b/.gitignore index 05c756b00..043be3f9a 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ output.txt phpunit.xml.dist.bak phpunit.xml.dist.dev .github/workflows/code-cov.yml +.history/* diff --git a/CHANGELOG.md b/CHANGELOG.md index 89a81cb82..01380c88d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,24 @@ All notable changes to `laravel-livewire-tables` will be documented in this file ## [Unreleased] -### Fixes -- Bulk Actions (AlpineJS) - - Moving Table Head Checkbox to AlpineJS - - Using AlpineJS for calculating if all items have been selected - - Correcting missing x-cloak - +### Changed +- Fixes + - Bulk Actions (AlpineJS) + - Moving Table Head Checkbox to AlpineJS + - Using AlpineJS for calculating if all items have been selected + - Correcting missing x-cloak + - Added indeterminateCheckbox for TH for bulk actions + - Cleaned up ALpineJS functionality for Bulk Actions + - Repair of tests that were looking for wire:model that no longer existed + +- Enhancements + - Several new public variables for accessing pagination data cleanly, to avoid calling functions repeatedly across various blades. + - paginationTotalItemCount (Total number of items in the results across all page) + - paginationCurrentItems (Primary keys of items in the current page) + - paginationCurrentCount (Number of results on the current page) + +- Blades + - Several blades have had the classic Tables approach ($theme == 'tailwind', $theme == 'bootstrap) replaced with conditional classes using the @class([]) approach. This is to reduce the complexity of the blade files. ## [2.13.0] - 2023-05-17 diff --git a/resources/views/components/pagination.blade.php b/resources/views/components/pagination.blade.php index 51c932320..5ba6992cf 100644 --- a/resources/views/components/pagination.blade.php +++ b/resources/views/components/pagination.blade.php @@ -12,7 +12,7 @@ @endif @if ($theme === 'tailwind') -
+
@if ($component->paginationVisibilityIsEnabled())
@@ -23,7 +23,7 @@ @lang('to') {{ $rows->lastItem() }} @lang('of') - {{ $rows->total() }} + @lang('results')

@elseif ($component->paginationIsEnabled() && $component->isPaginationMethod('simple')) @@ -49,7 +49,7 @@ @endif
@elseif ($theme === 'bootstrap-4') -
+
@if ($component->paginationVisibilityIsEnabled()) @if ($component->paginationIsEnabled() && $component->isPaginationMethod('standard') && $rows->lastPage() > 1)
@@ -63,7 +63,7 @@ @lang('to') {{ $rows->count() ? $rows->lastItem() : 0 }} @lang('of') - {{ $rows->total() }} + @lang('results')
@@ -92,7 +92,7 @@ @endif
@elseif ($theme === 'bootstrap-5') -
+
@if ($component->paginationVisibilityIsEnabled()) @if ($component->paginationIsEnabled() && $component->isPaginationMethod('standard') && $rows->lastPage() > 1)
@@ -106,7 +106,7 @@ @lang('to') {{ $rows->count() ? $rows->lastItem() : 0 }} @lang('of') - {{ $rows->total() }} + @lang('results')
diff --git a/resources/views/components/table/td/bulk-actions.blade.php b/resources/views/components/table/td/bulk-actions.blade.php index 34b7a6c73..d5b7af025 100644 --- a/resources/views/components/table/td/bulk-actions.blade.php +++ b/resources/views/components/table/td/bulk-actions.blade.php @@ -6,38 +6,22 @@ $theme = $component->getTheme(); @endphp - @if ($theme === 'tailwind') - -
- -
-
- @elseif ($theme === 'bootstrap-4') - + +
$theme === "tailwind", + "form-check" => $theme === "bootstrap-5", + ]) + > $theme === "tailwind", + "form-check-input" => $theme === "bootstrap-5", + ]) /> - - @elseif ($theme === 'bootstrap-5') - -
- -
-
- @endif +
+
@endif diff --git a/resources/views/components/table/th/bulk-actions.blade.php b/resources/views/components/table/th/bulk-actions.blade.php index 457d58cdc..e0fdead7b 100644 --- a/resources/views/components/table/th/bulk-actions.blade.php +++ b/resources/views/components/table/th/bulk-actions.blade.php @@ -5,33 +5,27 @@ $theme = $component->getTheme(); @endphp - @if ($theme === 'tailwind') - -
- -
-
- @elseif ($theme === 'bootstrap-4') - - +
$theme === 'tailwind', + 'form-check' => $theme === 'bootstrap-5', + ]) + > + $theme === 'tailwind', + 'form-check-input' => $theme === 'bootstrap-5', + ]) /> - - @elseif ($theme === 'bootstrap-5') - -
- -
-
- @endif +
+
@endif diff --git a/resources/views/components/table/tr/bulk-actions.blade.php b/resources/views/components/table/tr/bulk-actions.blade.php index 3eb147765..1107a6216 100644 --- a/resources/views/components/table/tr/bulk-actions.blade.php +++ b/resources/views/components/table/tr/bulk-actions.blade.php @@ -6,7 +6,6 @@ $table = $component->getTableName(); $theme = $component->getTheme(); $colspan = $component->getColspanCount(); - $selected = $component->getSelectedCount(); $selectAll = $component->selectAllIsEnabled(); $simplePagination = $component->paginationMethod == 'simple' ? true : false; @endphp @@ -16,15 +15,14 @@ wire:key="bulk-select-message-{{ $table }}" class="bg-indigo-50 dark:bg-gray-900 dark:text-white" x-cloak - x-show="shouldShowBulkActionSelect" - x-effect="updateTotalItemCount({{ $rows->total() ?? 'unknown' }})" + x-show="selectedItems.length > 0" > -