orchidsoftware / orchidsoftware/platform

Implement a simplified direct filtering syntax on a table

Open
#2,114 0 comments 0 reactions 1 assignee View on GitHub

@tabuna is already working on this.

Since Feb 7, 2022.

Dominant language
PHP
Stars
4.8k
Forks
662
Avg merge
1d 9h
Merged PRs (30d)
7

Description

Hi, I recently saw that in the table layout, we can now customize the filters ourselves for our tasks, by:

TD::make('example')->filter(Input::make())
And it's really great, but over time I ran into an inconvenience.

Therefore, I decided it for myself, but perhaps the idea of ​​​​such a solution will be useful to the project (I do not make a pull request yet, since this implementation is still at the testing stage and not completed).

The essence of the problem lies in the fact that sometimes we have data that we do not get directly from the model on which we build the table, but we form it through the ->render() method, so we want to filter it in a special way.

Let's take the following example:

 TD::make('user', __('User'))
        ->filter(Relation::make('users')
               ->fromModel(User::class, 'name')
               ->multiple()
        )
        ->render(function (Alarm $alarm) {
                return new Persona($alarm->user->presenter());;
        }),

We will have to copy the code that we put in the ->filter() method from the layout to the layout where we display users, which in my opinion, is not very convenient.

Also, it is currently not possible to place multiple fields in the filter, such as Relation and RadioButton, if we want to provide more filtering flexibility for the end user.

Another not unimportant fact is that by placing code in the ->filter() method, we increase the volume of instructions and the code becomes less readable.

My solution is as follows:

Leave the functionality that is currently present, but add the possibility of the following syntax:

TD::make('user', __('User'))
       ->filter( UserFilter::class)
       ->render(function (Alarm $alarm) {
               return new Persona($alarm->user->presenter());;
        }),

This will allow:

  • reuse and group recurring filter templates for a specific position.
  • Keep the convenience and readability of the code when using specific filters in tables
  • Add completely different fields to filter by the required field and process them as we need in the UserFilter::class

In the screenshot, I gave an example of what it can allow us to end up with

Снимок экрана 2022-02-07 в 18 10 53

It doesn't matter to me who implements it, I or someone else. It just seems to me that this is what is currently missing in direct filtering in tables, thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.