Skip to content

Commit

Permalink
Merge pull request #264 from rappasoft/develop
Browse files Browse the repository at this point in the history
Added helpers for bulk reset
  • Loading branch information
rappasoft authored May 2, 2021
2 parents 7829f0e + f6b3ca5 commit e2a62ec
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/DataTableComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
10 changes: 0 additions & 10 deletions src/Traits/WithFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
10 changes: 9 additions & 1 deletion src/Traits/WithSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit e2a62ec

Please sign in to comment.