diff --git a/CHANGELOG.md b/CHANGELOG.md index f04a4d741..809dd7d86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ All notable changes to `laravel-livewire-tables` will be documented in this file ## [Unreleased] +## [1.5.1] - 2021-05-02 + +### Added + +- Added clear search method. + +### Changed + +- Changed resetAll method to include search and page and moved to parent component. +- Refactored search method to use new resetSearch. + ## [1.5.0] - 2021-05-02 ### Added @@ -286,7 +297,8 @@ All notable changes to `laravel-livewire-tables` will be documented in this file - Initial release -[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.5.0...development +[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.5.1...development +[1.5.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.4.0...v1.5.1 [1.5.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.4.0...v1.5.0 [1.4.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.3.1...v1.4.0 [1.3.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.3.0...v1.3.1 diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index 12009d9a2..43ba2f6ac 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -157,6 +157,18 @@ public function getRowsProperty() return $this->rowsQuery()->get(); } + /** + * Reset all the criteria + */ + public function resetAll(): void + { + $this->resetFilters(); + $this->resetSearch(); + $this->resetSorts(); + $this->resetBulk(); + $this->resetPage(); + } + /** * The view to render each row of the table. * diff --git a/src/Traits/WithFilters.php b/src/Traits/WithFilters.php index d3f786883..2b5e8cd37 100644 --- a/src/Traits/WithFilters.php +++ b/src/Traits/WithFilters.php @@ -67,16 +67,6 @@ public function updatingFilters(): void $this->resetPage(); } - /** - * Reset all the filters - */ - public function resetAll(): void - { - $this->resetFilters(); - $this->resetSorts(); - $this->resetBulk(); - } - /** * Define the filters array * diff --git a/src/Traits/WithSearch.php b/src/Traits/WithSearch.php index 52e380aef..beb3a424f 100644 --- a/src/Traits/WithSearch.php +++ b/src/Traits/WithSearch.php @@ -35,10 +35,18 @@ trait WithSearch public function updatedFilters(): void { if (isset($this->filters['search']) && $this->filters['search'] === '') { - $this->filters['search'] = null; + $this->resetSearch(); } } + /** + * Clear the search filter specifically + */ + public function resetSearch(): void + { + $this->filters['search'] = null; + } + /** * Build Livewire model options for the search input *