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

[data-grid] filter+sorter sequence support #320

Closed
vvval opened this issue May 13, 2020 · 1 comment · Fixed by #365
Closed

[data-grid] filter+sorter sequence support #320

vvval opened this issue May 13, 2020 · 1 comment · Fixed by #365
Assignees

Comments

@vvval
Copy link
Member

vvval commented May 13, 2020

emulates filter bc we have only addFilter or addSorter setters

class SortedFilter implements SequenceInterface, FilterInterface
{
    private string $value;

    /** @var SpecificationInterface[] */
    private array $specifications;

    public function __construct(string $value, SpecificationInterface ...$specifications)
    {
        $this->value = $value;
        $this->specifications = $specifications;
    }

    /**
     * @return SpecificationInterface[]
     */
    public function getSpecifications(): array
    {
        return $this->specifications;
    }

    public function getValue(): string
    {
        return $this->value;
    }

    public function withValue($value): ?SpecificationInterface
    {
        return $this;
    }
}
@vvval
Copy link
Member Author

vvval commented May 13, 2020

Usage:

$schema->addFilter(
    'filter',
    new Filter\Select(
        [
            'upcoming'      => new SortedFilter(
                'upcoming',
                new Filter\Gt('date', new DateTimeImmutable('now')),
                new AscSorter('date')
            ),
            'mostReviewed'  => new SortedFilter(
                'mostReviewed',
                new Filter\Lte('date', new DateTimeImmutable('now')),
                new DescSorter('count_reviews')
            )
        ]
    )
);

@vvval vvval self-assigned this May 13, 2020
@SerafimArts SerafimArts transferred this issue from spiral/data-grid Sep 19, 2020
@SerafimArts SerafimArts changed the title filter+sorter sequence support [data-grid] filter+sorter sequence support Sep 19, 2020
@vvval vvval linked a pull request Dec 16, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant