From 41714f337f567261f71c89f029936351d84d2979 Mon Sep 17 00:00:00 2001 From: Refringe Date: Thu, 15 Aug 2024 23:05:48 -0400 Subject: [PATCH] Filter Count A count of the number of filters currently applied is now displayed. --- app/Livewire/Mod/Index.php | 18 +++++++++++++++++- resources/views/livewire/mod/index.blade.php | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/Livewire/Mod/Index.php b/app/Livewire/Mod/Index.php index 34e0ecc..9b2b6e1 100644 --- a/app/Livewire/Mod/Index.php +++ b/app/Livewire/Mod/Index.php @@ -87,8 +87,24 @@ class Index extends Component public function resetFilters(): void { $this->query = ''; - $this->order = 'created'; $this->sptVersion = $this->getLatestMinorVersions()->pluck('version')->toArray(); $this->featured = 'include'; } + + /** + * Compute the count of active filters. + */ + public function getFilterCountProperty(): int + { + $count = 0; + if ($this->query !== '') { + $count++; + } + if ($this->featured !== 'include') { + $count++; + } + $count += count($this->sptVersion); + + return $count; + } } diff --git a/resources/views/livewire/mod/index.blade.php b/resources/views/livewire/mod/index.blade.php index e65b031..8b269c6 100644 --- a/resources/views/livewire/mod/index.blade.php +++ b/resources/views/livewire/mod/index.blade.php @@ -15,7 +15,7 @@ - {{ __('Filters') }} {{-- // TODO: Ideally, we should have a count of the number of filters here: "5 Filters" --}} + {{ $this->filterCount }} {{ __('Filters') }}