refine icon indicating copy to clipboard operation
refine copied to clipboard

[FEAT] Add support for `and` conditional filter

Open IgnusG opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. Now that the conditional or filter is available (see https://github.com/pankod/refine/issues/1417) it would be cool to have a complementary and filter such that the following query becomes possible:

OR(
  AND(
    {title} == "The Great Divide",
    {age} < 10,
  ),
  AND(
    {title} == "The New Era",
    {age} < 20,
  )
)

This would allow to construct complex filters for different situations. Currently it's only possible to do the following:

AND(
  OR(
    {title} == "The Great Divide",
    {title} == "The New Era",
  ),
  OR(
    {age} < 10,
    {age} < 20,
  )
)

One can notice however that these are not the same and the condition for the age is now not tied to the specific titles and in this example {age} < 10 actually being useless since {age} < 20 already satisfies it.

Describe the solution you'd like An additional and filter based on the same principle as the or filter.

Describe alternatives you've considered The top-level implicit AND that already exists is good but does limit the queries we can construct if we need to narrow down results individually.

IgnusG avatar Mar 10 '22 14:03 IgnusG

Hey @IgnusG , Great idea! Thank you, let's see what we can do

omeraplak avatar Mar 11 '22 11:03 omeraplak

I would like to work on this,

I just need to add support for and condition filter in packages/nestjsx-crud/src/index.ts Am I correct?

bhagatpratham avatar Oct 04 '22 08:10 bhagatpratham

Hey @bhagatpratham , refine only support OR filter. In addition we should add AND support

So the "and" option needs to be added to ConditionalFilter as well, https://github.com/pankod/refine/blob/next/packages/core/src/contexts/data/IDataContext.ts#L69

After adding it, we must implement it in the supporting dataProviders. @pankod/refine-nestjsx-crud is a good option https://github.com/pankod/refine/blob/next/packages/nestjsx-crud/src/index.ts#L100

omeraplak avatar Oct 04 '22 08:10 omeraplak

@omeraplak Can i work on this issue if not already taken?

Smartmind12 avatar Oct 06 '22 15:10 Smartmind12

@omeraplak Can i work on this issue if not already taken?

I guess no one has yet. If you plan to do so, we can assign it to you. When do you plan to do it?

omeraplak avatar Oct 06 '22 15:10 omeraplak

@omeraplak Can i work on this issue if not already taken?

I guess no one has yet. If you plan to do so, we can assign it to you. When do you plan to do it?

I would like to work on it just now!

Smartmind12 avatar Oct 06 '22 15:10 Smartmind12

Hey @IgnusG , I hope you are very well! We've released and conditional filters!

https://refine.dev/docs/advanced-tutorials/data-provider/handling-filters/#conditionalfilters

omeraplak avatar Oct 17 '22 13:10 omeraplak

Thanks @omeraplak, that's amazing! Great work @omeraplak and @yildirayunlu 🎉

IgnusG avatar Oct 17 '22 17:10 IgnusG