Skip to content

Commit 7ec1ce3

Browse files
authored
Start removal of appliedFilters
1 parent 6bf0d09 commit 7ec1ce3

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

resources/views/components/tools/filters/date-range.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
x-ref="dateRangeInput"
1616
x-on:click="init"
1717
x-on:change="changedValue($refs.dateRangeInput.value)"
18-
value="{{ $filter->getDateString(isset($this->appliedFilters[$filterKey]) ? $this->appliedFilters[$filterKey] : '') }}"
18+
value="{{ $filter->getDateString(isset($this->filterComponents[$filterKey]) ? $this->filterComponents[$filterKey] : '') }}"
1919
wire:key="{{ $filter->generateWireKey($tableName, 'dateRange') }}"
2020
id="{{ $tableName }}-filter-dateRange-{{ $filterKey }}"
2121
@class([

src/Traits/Helpers/FilterHelpers.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ public function mountFilterHelpers(): void
2121
$this->restoreFilterValues();
2222

2323
foreach ($this->getFilters() as $filter) {
24-
if (! isset($this->appliedFilters[$filter->getKey()])) {
24+
if (! isset($this->filterComponents[$filter->getKey()])) {
2525
if ($filter->hasFilterDefaultValue()) {
2626
$this->setFilter($filter->getKey(), $filter->getFilterDefaultValue());
2727
} else {
2828
$this->resetFilter($filter);
2929
}
3030
} else {
31-
$this->setFilter($filter->getKey(), $this->appliedFilters[$filter->getKey()]);
31+
$this->setFilter($filter->getKey(), $this->filterComponents[$filter->getKey()]);
3232
}
3333
}
3434
}
@@ -139,7 +139,7 @@ public function getFilterByKey(string $key)
139139
#[On('set-filter')]
140140
public function setFilter(string $filterKey, string|array|null $value): void
141141
{
142-
$this->appliedFilters[$filterKey] = $this->filterComponents[$filterKey] = $value;
142+
$this->filterComponents[$filterKey] = $value;
143143

144144
$this->callHook('filterSet', ['filter' => $filterKey, 'value' => $value]);
145145
$this->callTraitHook('filterSet', ['filter' => $filterKey, 'value' => $value]);
@@ -228,7 +228,7 @@ public function hasAppliedVisibleFiltersForPills(): bool
228228
*/
229229
public function getAppliedFiltersWithValues(): array
230230
{
231-
return $this->appliedFilters = array_filter($this->getAppliedFilters(), function ($item, $key) {
231+
return $this->filterComponents = array_filter($this->getAppliedFilters(), function ($item, $key) {
232232
return ! $this->getFilterByKey($key)->isEmpty($item) && (is_array($item) ? count($item) : $item !== null);
233233
}, ARRAY_FILTER_USE_BOTH);
234234
}

src/Traits/Helpers/SessionStorageHelpers.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ public function storeFilterValues(): void
2323
{
2424
if ($this->shouldStoreFiltersInSession()) {
2525
$this->clearStoredFilterValues();
26-
session([$this->getFilterSessionKey() => $this->appliedFilters]);
26+
session([$this->getFilterSessionKey() => $this->filterComponents]);
2727
}
2828
}
2929

3030
public function restoreFilterValues(): void
3131
{
32-
if (empty($this->filterComponents) || empty($this->appliedFilters)) {
33-
$this->filterComponents = $this->appliedFilters = $this->getStoredFilterValues();
32+
if (empty($this->filterComponents)) {
33+
$this->filterComponents = $this->getStoredFilterValues();
3434
}
3535
}
3636

src/Traits/WithFilters.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ trait WithFilters
3535
// Set in JS
3636
public array $filterComponents = [];
3737

38-
// Set in Frontend
39-
public array $appliedFilters = [];
40-
4138
public array $filterGenericData = [];
4239

4340
protected ?Collection $filterCollection;
@@ -51,7 +48,6 @@ protected function queryStringWithFilters(): array
5148
{
5249
if ($this->queryStringIsEnabled() && $this->filtersAreEnabled()) {
5350
return [
54-
'appliedFilters' => ['except' => null, 'history' => false, 'keep' => false, 'as' => $this->getQueryStringAlias().'-filters'],
5551
'filterComponents' => ['except' => null, 'history' => false, 'keep' => false, 'as' => $this->getQueryStringAlias().'-filters'],
5652
];
5753
}

0 commit comments

Comments
 (0)