Skip to content

Commit f6b3ca5

Browse files
committed
Added helpers for bulk reset
### 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 parent ab61d76 commit f6b3ca5

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
44

55
## [Unreleased]
66

7+
## [1.5.1] - 2021-05-02
8+
9+
### Added
10+
11+
- Added clear search method.
12+
13+
### Changed
14+
15+
- Changed resetAll method to include search and page and moved to parent component.
16+
- Refactored search method to use new resetSearch.
17+
718
## [1.5.0] - 2021-05-02
819

920
### Added
@@ -286,7 +297,8 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
286297

287298
- Initial release
288299

289-
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.5.0...development
300+
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.5.1...development
301+
[1.5.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.4.0...v1.5.1
290302
[1.5.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.4.0...v1.5.0
291303
[1.4.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.3.1...v1.4.0
292304
[1.3.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.3.0...v1.3.1

src/DataTableComponent.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,18 @@ public function getRowsProperty()
157157
return $this->rowsQuery()->get();
158158
}
159159

160+
/**
161+
* Reset all the criteria
162+
*/
163+
public function resetAll(): void
164+
{
165+
$this->resetFilters();
166+
$this->resetSearch();
167+
$this->resetSorts();
168+
$this->resetBulk();
169+
$this->resetPage();
170+
}
171+
160172
/**
161173
* The view to render each row of the table.
162174
*

src/Traits/WithFilters.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,6 @@ public function updatingFilters(): void
6767
$this->resetPage();
6868
}
6969

70-
/**
71-
* Reset all the filters
72-
*/
73-
public function resetAll(): void
74-
{
75-
$this->resetFilters();
76-
$this->resetSorts();
77-
$this->resetBulk();
78-
}
79-
8070
/**
8171
* Define the filters array
8272
*

src/Traits/WithSearch.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,18 @@ trait WithSearch
3535
public function updatedFilters(): void
3636
{
3737
if (isset($this->filters['search']) && $this->filters['search'] === '') {
38-
$this->filters['search'] = null;
38+
$this->resetSearch();
3939
}
4040
}
4141

42+
/**
43+
* Clear the search filter specifically
44+
*/
45+
public function resetSearch(): void
46+
{
47+
$this->filters['search'] = null;
48+
}
49+
4250
/**
4351
* Build Livewire model options for the search input
4452
*

0 commit comments

Comments
 (0)