Skip to content

Commit

Permalink
Dispatch the clear-all-filters event from LfTags
Browse files Browse the repository at this point in the history
  • Loading branch information
afonic committed Jan 26, 2025
1 parent b780694 commit 1f95221
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/Http/Livewire/LfCheckboxFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function updatedSelected()
->to(LivewireCollection::class);
}

#[On('clear-all-filters')]
public function clear()
{
$this->selected = [];
Expand Down
1 change: 1 addition & 0 deletions src/Http/Livewire/LfDateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function filterOptions()
return $fieldOptions->only(['earliest_date', 'latest_date'])->all();
}

#[On('clear-all-filters')]
public function clear()
{
$this->selected = '';
Expand Down
1 change: 1 addition & 0 deletions src/Http/Livewire/LfDualRangeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function updatedSelectedMax($value)
$this->dispatchEvent();
}

#[On('clear-all-filters')]
public function clear(): void
{
$this->selectedMin = $this->min;
Expand Down
13 changes: 7 additions & 6 deletions src/Http/Livewire/LfRadioFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,20 @@ public function updatedSelected()
->to(LivewireCollection::class);
}

public function clear()
{
$this->selected = '';
$this->clearFilters();
}

public function rules()
{
return [
'selected' => ['required', Rule::in(array_keys($this->filterOptions()))],
];
}

#[On('clear-all-filters')]
public function clear()
{
$this->selected = '';
$this->clearFilters();
}

#[On('clear-option')]
public function clearOption($tag)
{
Expand Down
1 change: 1 addition & 0 deletions src/Http/Livewire/LfRangeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function setPresetValues($params)
}
}

#[On('clear-all-filters')]
public function clear(): void
{
$this->selected = $this->default ?? $this->min;
Expand Down
5 changes: 5 additions & 0 deletions src/Http/Livewire/LfTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ public function removeOption($field, $value)
$this->dispatch('clear-option', $tag);
}

public function clearAll()
{
$this->dispatch('clear-all-filters');
}

public function isNotTaggable($field)
{
return ! in_array($field, $this->fields);
Expand Down
1 change: 1 addition & 0 deletions src/Http/Livewire/LfTextFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function updatedSelected()
->to(LivewireCollection::class);
}

#[On('clear-all-filters')]
public function clear()
{
$this->selected = '';
Expand Down

0 comments on commit 1f95221

Please sign in to comment.