Skip to content

Commit

Permalink
Fix listing filters
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Dec 20, 2024
1 parent 7822e57 commit bf3568a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion resources/js/components/data-list/Filters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<field-filter
ref="fieldFilter"
:config="fieldFilter"
:values="activeFilters.fields || {}"
:values="activeFilters['runway-fields'] || {}"
:badges="fieldFilterBadges"
@changed="$emit('changed', {handle: 'runway-fields', values: $event})"
@cleared="creating = false"
Expand Down
1 change: 1 addition & 0 deletions resources/js/components/resources/Listing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

<div>
<data-list-filters
ref="filters"
:filters="filters"
:active-preset="activePreset"
:active-preset-payload="activePresetPayload"
Expand Down
6 changes: 4 additions & 2 deletions src/Scopes/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ public function visibleTo($key): bool
public function apply($query, $values): void
{
$this->getFields()
->filter(fn (Field $field, string $handle) => Arr::has($values, $handle))
->each(function (Field $field, string $handle) use ($query, $values) {
->filter(function ($field, $handle) use ($values) {
return isset($values[$handle]);
})
->each(function ($field, $handle) use ($query, $values) {
$filter = $field->fieldtype()->filter();
$values = $filter->fields()->addValues($values[$handle])->process()->values();
$filter->apply($query, $handle, $values);
Expand Down

0 comments on commit bf3568a

Please sign in to comment.