Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix table filters #2862

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/Screen/TD.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class TD extends Cell
public const FILTER_DATE_RANGE = 'dateRange';
public const FILTER_NUMBER_RANGE = 'numberRange';
public const FILTER_SELECT = 'select';
public const FILTER_SELECT_NOT_MULTIPLE = 'selectNotMultiple';
/**
* @var string|null|int
*/
Expand Down Expand Up @@ -264,11 +265,12 @@ protected function buildFilter(): ?Field
protected function detectConstantFilter(string $filter): Field
{
$input = match ($filter) {
self::FILTER_DATE_RANGE => DateRange::make()->disableMobile(),
self::FILTER_NUMBER_RANGE => NumberRange::make(),
self::FILTER_SELECT => Select::make()->options($this->filterOptions)->multiple(),
self::FILTER_DATE => DateTimer::make()->inline()->format('Y-m-d'),
default => Input::make()->type($filter),
self::FILTER_DATE_RANGE => DateRange::make()->disableMobile(),
self::FILTER_NUMBER_RANGE => NumberRange::make(),
self::FILTER_SELECT => Select::make()->options($this->filterOptions)->multiple(),
self::FILTER_DATE => DateTimer::make()->format('Y-m-d'),
self::FILTER_SELECT_NOT_MULTIPLE => Select::make()->options($this->filterOptions)->empty(),
default => Input::make()->type($filter),
};

return $input;
Expand Down Expand Up @@ -394,6 +396,6 @@ protected function buildFilterString(): ?string
return implode(', ', $filter);
}

return $filter;
return $this->filterOptions[$filter] ?? $filter;
}
}