Skip to content

Commit

Permalink
Add active filters count to entries-updated event
Browse files Browse the repository at this point in the history
  • Loading branch information
afonic committed Jan 26, 2025
1 parent d0420c9 commit 07ff27d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Http/Livewire/LivewireCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,6 @@ public function render()

public function rendered()
{
$this->dispatch('entries-updated', count: $this->entriesCount);
$this->dispatch('entries-updated', count: $this->entriesCount, active: $this->getParamsCount());
}
}
7 changes: 7 additions & 0 deletions src/Http/Livewire/Traits/HandleParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ protected function handleCustomQueryStringParams(): array|bool
return false;
}

protected function getParamsCount(): int
{
return collect($this->params)->reject(function ($value, $key) {
return $key === 'sort' || $key === 'query_scope';
})->count();
}

protected function extractCollectionKeys($paramsCollection)
{
$collectionKeys = ['from', 'in', 'folder', 'use', 'collection'];
Expand Down

0 comments on commit 07ff27d

Please sign in to comment.