From dc254a3a8636f9f7b073c57289000c7b63d6831b Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sun, 29 Oct 2023 02:55:46 +0000 Subject: [PATCH] v3.0.0-beta.11 Merge (#1499) * v3 - Fix - Correct setFilter behaviour (#1451) * Fix for setFilter * Update return types --------- Co-authored-by: lrljoe * Fixes for missing brackets (#1455) * v3 Toolbar - Splitting of Views/Blades (#1454) * Initial Commit - Full Split of Toolbar * Remove Confirms Code * Fix superfluous endif * Combining Blades - Stage 1 * More Merging * Bulk Actions - Icon Adjustment * Further clean up of toolbar - filter button * Stripping Toolbar Theme Distinctions * Adjust childElementOpen to respect hierachy * To remove files * Merge Column-Select into Single Blade * Clean Up Blades * Fix missing BootStrap Classes from Toolbar Blade (#1466) * Adding x-cloak where it is missing for x-show (#1463) * V3 - QueryString migration into Traits (#1465) * Initial migration of queryString to Traits * Lock $queryStringStatus * Return empty arrays for Traits * Add WithQueryString Trait * Add Config/Helper Traits to WithQueryString * Add default queryStringStatus --------- Co-authored-by: lrljoe * Update Changelog (#1467) * v3 DateRange - Icon Styling, FilterHelper Method (#1490) * DateRange - Icon Styling, FilterHelper Method * Add can_get_datestring test * Add non-array test for DateRangeFilter --------- Co-authored-by: lrljoe * V3 DateRangeFilter - Remove Icon, Add Placeholder (#1492) * Remove DateRangeFilter Icon * DateRangeFilter - Remove Icon & Add Placeholder * Use FilterHelper method to generate wire:key, add placeholder with docs (#1493) * For all Filters (Except MultiSelect currently), use the FilterHelper method to generate the wire:key rather than doing it in the blade. This centralises for future updates MultiSelectFilter will follow in due course, as it requires some tidying & updates. * Add placeholder config option to: DateRangeFilter, DateFilter, DateTimeFilter, NumberFilter and update docs to reflect the availability of the option * Clean up classes on Filters * Minor tweaks to toolbar/column select styling (#1494) --------- Co-authored-by: lrljoe --- CHANGELOG.md | 10 + docs/filter-types/filters-date.md | 9 +- docs/filter-types/filters-daterange.md | 3 +- docs/filter-types/filters-datetime.md | 9 +- docs/filter-types/filters-number.md | 5 +- .../tools/filters/date-range.blade.php | 68 ++-- .../components/tools/filters/date.blade.php | 5 +- .../tools/filters/datetime.blade.php | 3 +- .../filters/multi-select-dropdown.blade.php | 4 +- .../tools/filters/multi-select.blade.php | 2 +- .../components/tools/filters/number.blade.php | 3 +- .../components/tools/filters/select.blade.php | 2 +- .../tools/filters/text-field.blade.php | 2 +- .../views/components/tools/toolbar.blade.php | 6 +- .../toolbar/items/column-select.blade.php | 347 +++++++++--------- src/Views/Filters/DateRangeFilter.php | 20 + src/Views/Traits/Helpers/FilterHelpers.php | 5 + tests/Views/Filters/DateRangeFilterTest.php | 11 + .../Configuration/FilterConfigurationTest.php | 10 + .../Traits/Helpers/FilterHelpersTest.php | 26 ++ 20 files changed, 304 insertions(+), 246 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79748414e..2ffd5624a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to `laravel-livewire-tables` will be documented in this file +## [3.0.0-beta.11] - 2023-10-29 +- Update Date Range Icon Styling +- Migrate PHP from date-range blade into new DateRangeFilter method +- Add FilterHelper method for generating filter wire:keys +- Add Filter CustomPosition tests +- Add Placeholder config option for DateRangeFilter +- Add Placeholder config option for DateFilter, DateTimeFilter, NumberFilter +- Clean up classes on filters +- Minor tweaks to toolbar/column select styling + ## [3.0.0-beta.10] - 2023-10-27 - Changes to toolbar blade structure by @lrljoe in #[1454](https://github.com/rappasoft/laravel-livewire-tables/pull/1454) - Fix queryStringEnabled by @lrljoe in #[1465](https://github.com/rappasoft/laravel-livewire-tables/pull/1465) diff --git a/docs/filter-types/filters-date.md b/docs/filter-types/filters-date.md index bf2ca2b7b..488cda84f 100644 --- a/docs/filter-types/filters-date.md +++ b/docs/filter-types/filters-date.md @@ -18,7 +18,7 @@ public function filters(): array } ``` -Date filters have configs to set min and max, and to set the format for the Filter Pills +Date filters have configs to set min and max, to set the format for the Filter Pills, and to set a placeholder value ```php public function filters(): array @@ -26,9 +26,10 @@ public function filters(): array return [ DateFilter::make('Verified From') ->config([ - 'min' => '2020-01-01', - 'max' => '2021-12-31', - 'pillFormat' => 'd M Y', + 'min' => '2020-01-01', // Earliest Acceptable Date + 'max' => '2021-12-31', // Latest Acceptable Date + 'pillFormat' => 'd M Y', // Format for use in Filter Pills + 'placeholder' => 'Enter Date', // A placeholder value ]) ]; } diff --git a/docs/filter-types/filters-daterange.md b/docs/filter-types/filters-daterange.md index 3cd0c0b52..37d0ea552 100644 --- a/docs/filter-types/filters-daterange.md +++ b/docs/filter-types/filters-daterange.md @@ -18,7 +18,7 @@ public function filters(): array } ``` -DateRange filters have configs to set earliestDate and latestDate, to allow/disallow input, to set the input format, and display format, plus Filter Pills labels +DateRange filters have configs to set earliestDate and latestDate, to allow/disallow input, to set the input format, to set a placeholder value, display format, plus Filter Pills labels ```php public function filters(): array @@ -32,6 +32,7 @@ public function filters(): array 'dateFormat' => 'Y-m-d', // Date format that will be received by the filter 'earliestDate' => '2020-01-01', // The earliest acceptable date 'latestDate' => '2023-08-01', // The latest acceptable date + 'placeholder' => 'Enter Date Range', // A placeholder value ]) ->setFilterPillValues([0 => 'minDate', 1 => 'maxDate']) // The values that will be displayed for the Min/Max Date Values ->filter(function (Builder $builder, array $dateRange) { // Expects an array. diff --git a/docs/filter-types/filters-datetime.md b/docs/filter-types/filters-datetime.md index ac28ddecf..288d90b4b 100644 --- a/docs/filter-types/filters-datetime.md +++ b/docs/filter-types/filters-datetime.md @@ -18,7 +18,7 @@ public function filters(): array } ``` -DateTime filters have configs to set min and max, and to set the format for the Filter Pills +DateTime filters have configs to set min and max, to set the format for the Filter Pills, and to set a placeholder value ```php public function filters(): array @@ -26,9 +26,10 @@ public function filters(): array return [ DateTimeFilter::make('Verified From') ->config([ - 'min' => '2022-11-31 00:00:00', - 'max' => '2022-12-31 05:00:00', - 'pillFormat' => 'd M Y - H:i', + 'min' => '2022-11-31 00:00:00', // Earliest Acceptable DateTime + 'max' => '2022-12-31 05:00:00', // Latest Acceptable Date + 'pillFormat' => 'd M Y - H:i', // Format for use in Filter Pills + 'placeholder' => 'Enter Date Time', // A placeholder value ]) ]; } diff --git a/docs/filter-types/filters-number.md b/docs/filter-types/filters-number.md index 402878eaa..3b629dd0a 100644 --- a/docs/filter-types/filters-number.md +++ b/docs/filter-types/filters-number.md @@ -13,8 +13,9 @@ public function filters(): array return [ NumberFilter::make('Amount') ->config([ - 'min' => 0, - 'max' => 100, + 'min' => 0, // Minimum Value Accepted + 'max' => 100, // Maximum Value Accepted + 'placeholder' => 'Enter Number 0 - 100', // A placeholder value ]) ->filter(function(Builder $builder, string $value) { $builder->where('amount', '<', $value); diff --git a/resources/views/components/tools/filters/date-range.blade.php b/resources/views/components/tools/filters/date-range.blade.php index 3599eee69..bdca66903 100644 --- a/resources/views/components/tools/filters/date-range.blade.php +++ b/resources/views/components/tools/filters/date-range.blade.php @@ -1,53 +1,27 @@ @php - $filterKey = $filter->getKey(); - $filterConfigs = $filter->getConfigs(); - $dateString = ''; - $dateInput = isset($this->filters[$filterKey]) ? $this->filters[$filterKey] : ''; - if ($dateInput != '') { - if (is_array($dateInput)) { - $startDate = isset($dateInput['minDate']) ? $dateInput['minDate'] : (isset($dateInput[1]) ? $dateInput[1] : date('Y-m-d')); - $endDate = isset($dateInput['maxDate']) ? $dateInput['maxDate'] : (isset($dateInput[0]) ? $dateInput[0] : date('Y-m-d')); - $dateString = $startDate . ' to ' . $endDate; - } else { - $dateArray = explode(',', $dateInput); - $startDate = isset($dateArray[0]) ? $dateArray[0] : date('Y-m-d'); - $endDate = isset($dateArray[2]) ? $dateArray[2] : date('Y-m-d'); - $dateString = $startDate . ' to ' . $endDate; - } - } - @endphp
- - -
- - - -
$isTailwind, - 'd-inline-block w-100 mb-3 mb-md-0 input-group' => $isBootstrap, - ]) - > - $isTailwind, - 'd-inline-block form-control w-100 pr-2 transition duration-150 ease-in-out border border-gray rounded-sm shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-800 dark:text-white dark:border-gray-600' => $isBootstrap, - ]) - /> - - - -
- + +
$isTailwind, + 'd-inline-block w-100 mb-3 mb-md-0 input-group' => $isBootstrap, + ]) + > + $isTailwind, + 'd-inline-block w-100 form-control' => $isBootstrap, + ]) + @if($filter->hasConfig('placeholder')) placeholder="{{ $filter->getConfig('placeholder') }}" @endif + />
-
\ No newline at end of file +
diff --git a/resources/views/components/tools/filters/date.blade.php b/resources/views/components/tools/filters/date.blade.php index c23a7c120..947bb9b61 100644 --- a/resources/views/components/tools/filters/date.blade.php +++ b/resources/views/components/tools/filters/date.blade.php @@ -1,18 +1,17 @@
- -
$isTailwind, "mb-3 mb-md-0 input-group" => $isBootstrap, ])> hasConfig('min')) min="{{ $filter->getConfig('min') }}" @endif @if($filter->hasConfig('max')) max="{{ $filter->getConfig('max') }}" @endif + @if($filter->hasConfig('placeholder')) placeholder="{{ $filter->getConfig('placeholder') }}" @endif @class([ "block w-full border-gray-300 rounded-md shadow-sm transition duration-150 ease-in-out focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-800 dark:text-white dark:border-gray-600" => $isTailwind, "form-control" => $isBootstrap, diff --git a/resources/views/components/tools/filters/datetime.blade.php b/resources/views/components/tools/filters/datetime.blade.php index 2cb073275..d05f0e087 100644 --- a/resources/views/components/tools/filters/datetime.blade.php +++ b/resources/views/components/tools/filters/datetime.blade.php @@ -7,11 +7,12 @@ ])> hasConfig('min')) min="{{ $filter->getConfig('min') }}" @endif @if($filter->hasConfig('max')) max="{{ $filter->getConfig('max') }}" @endif + @if($filter->hasConfig('placeholder')) placeholder="{{ $filter->getConfig('placeholder') }}" @endif @class([ "block w-full border-gray-300 rounded-md shadow-sm transition duration-150 ease-in-out focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-800 dark:text-white dark:border-gray-600" => $isTailwind, "form-control" => $isBootstrap, diff --git a/resources/views/components/tools/filters/multi-select-dropdown.blade.php b/resources/views/components/tools/filters/multi-select-dropdown.blade.php index 705025aa6..2bd3466af 100644 --- a/resources/views/components/tools/filters/multi-select-dropdown.blade.php +++ b/resources/views/components/tools/filters/multi-select-dropdown.blade.php @@ -6,7 +6,7 @@
diff --git a/resources/views/components/tools/filters/multi-select.blade.php b/resources/views/components/tools/filters/multi-select.blade.php index aa49decc6..4e2ec329b 100644 --- a/resources/views/components/tools/filters/multi-select.blade.php +++ b/resources/views/components/tools/filters/multi-select.blade.php @@ -3,7 +3,7 @@ @if ($isTailwind) -
+
hasConfig('min')) min="{{ $filter->getConfig('min') }}" @endif @if($filter->hasConfig('max')) max="{{ $filter->getConfig('max') }}" @endif + @if($filter->hasConfig('placeholder')) placeholder="{{ $filter->getConfig('placeholder') }}" @endif @class([ "block w-full border-gray-300 rounded-md shadow-sm transition duration-150 ease-in-out focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-800 dark:text-white dark:border-gray-600" => $isTailwind, "form-control" => $isBootstrap, diff --git a/resources/views/components/tools/filters/select.blade.php b/resources/views/components/tools/filters/select.blade.php index 13c0f397d..55952ed88 100644 --- a/resources/views/components/tools/filters/select.blade.php +++ b/resources/views/components/tools/filters/select.blade.php @@ -7,7 +7,7 @@ ])> hasConfig('placeholder')) placeholder="{{ $filter->getConfig('placeholder') }}" @endif diff --git a/resources/views/components/tools/toolbar.blade.php b/resources/views/components/tools/toolbar.blade.php index ffbd37b1a..3a72811fe 100644 --- a/resources/views/components/tools/toolbar.blade.php +++ b/resources/views/components/tools/toolbar.blade.php @@ -52,10 +52,8 @@ @if ($component->showBulkActionsDropdownAlpine()) @endif - - @if ($component->columnSelectIsEnabled() && $component->isTailwind()) - - @elseif($component->columnSelectIsEnabled() && $component->isBootstrap()) + + @if ($component->columnSelectIsEnabled()) @endif diff --git a/resources/views/components/tools/toolbar/items/column-select.blade.php b/resources/views/components/tools/toolbar/items/column-select.blade.php index 561083351..9c1f1af60 100644 --- a/resources/views/components/tools/toolbar/items/column-select.blade.php +++ b/resources/views/components/tools/toolbar/items/column-select.blade.php @@ -1,192 +1,191 @@ @aware(['component', 'tableName']) @if ($component->isTailwind()) -