woylie / flop_phoenix

Components for pagination, sortable tables and filter forms using Phoenix, Ecto and Flop
MIT License
385 stars 43 forks source link

Support multiple field on a single input #335

Closed zoedsoupe closed 5 months ago

zoedsoupe commented 5 months ago

Is your feature request related to a problem? Please describe. I'm into a voluntary project called PEA Pescarte, it's basically a digital platform for a social and environmental project that aims to introduce autonomous fisherman. communities on there eat of the society.

The point is that we have a back office for project researchers that currently have 2 layouts that are a researcher table and the report listing/filtering. Both layouts follow the default ideia to have a table with sorting, filtering and searching, as can be seen following these figma links:

As can be seen, we have a single search input component that allows to filter the table based on some columns.

Describe the solution you'd like What i can imagine for this situation is an input to receive the search input data and query the table entities with ilike expressions. Maybe something like this:

    from(f in Foo,
      join: b in assoc(f, :bar),
      where: ilike(f.col_1, ^"%#{search}%") or ilike(f.col_2, ^"%#{search}%")
      preload: [bar: b]
    )

Describe alternatives you've considered Yeah, i could easily implement a very specific search input for these entities and make my own Ecto query, but i would like to discuss more possibilities and alternatives using flop.

Additional context N/A

woylie commented 5 months ago

Hi @zoedsoupe,

this is already possible with compound fields: https://hexdocs.pm/flop/Flop.Schema.html#module-compound-fields