Skip to content

Commit 6fe1c57

Browse files
authored
v3.4.8 (#1863)
## [v3.4.8] - 2024-08-18 ### New Features - Add an event dispatch for Filter Was Set when filterComponents is updated by @lrljoe in #1861
1 parent 9cb98cc commit 6fe1c57

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to `laravel-livewire-tables` will be documented in this file
44

5+
## [v3.4.8] - 2024-08-18
6+
### New Features
7+
- Add an event dispatch for Filter Was Set when filterComponents is updated by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1861
8+
59
## [v3.4.7] - 2024-08-18
610
### Bug Fixes
711
- Correct a locked property that is entangled in js, and add comments around some key properties to prevent reoccurrence by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1859

src/Traits/WithFilters.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Database\Eloquent\Builder;
66
use Illuminate\Support\Collection;
77
use Livewire\Attributes\Locked;
8+
use Rappasoft\LaravelLivewireTables\Events\FilterApplied;
89
use Rappasoft\LaravelLivewireTables\Traits\Configuration\FilterConfiguration;
910
use Rappasoft\LaravelLivewireTables\Traits\Helpers\FilterHelpers;
1011

@@ -103,6 +104,10 @@ public function updatedFilterComponents(string|array|null $value, string $filter
103104
} elseif ($filter) {
104105
$this->callHook('filterUpdated', ['filter' => $filter->getKey(), 'value' => $value]);
105106
$this->callTraitHook('filterUpdated', ['filter' => $filter->getKey(), 'value' => $value]);
107+
if ($this->getEventStatusFilterApplied() && $filter->getKey() != null && $value != null) {
108+
event(new FilterApplied($this->getTableName(), $filter->getKey(), $value));
109+
}
110+
$this->dispatch('filter-was-set', tableName: $this->getTableName(), filterKey: $filter->getKey(), value: $value);
106111

107112
}
108113
}

tests/Traits/Visuals/FilterVisualsTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ public function test_filter_pills_show_when_enabled(): void
4949
->assertSee('Applied Filters');
5050
}
5151

52+
public function test_event_dispatched_when_filterComponents_set(): void
53+
{
54+
Livewire::test(PetsTable::class)
55+
->set('filterComponents.breed', [1])
56+
->assertDispatched('filter-was-set');
57+
}
58+
59+
public function test_event_dispatched_when_setFilter_dispatched(): void
60+
{
61+
Livewire::test(PetsTable::class)
62+
->dispatch('setFilter', filterKey: 'breed', value: [1])
63+
->assertDispatched('filter-was-set');
64+
}
65+
5266
public function test_filter_pills_show_when_visible(): void
5367
{
5468
Livewire::test(PetsTable::class)

0 commit comments

Comments
 (0)