csf icon indicating copy to clipboard operation
csf copied to clipboard

Add support for grouping conditions with and/or operators

Open DiogoDoreto opened this issue 1 year ago • 6 comments

In our project we would benefit from extra conditions for our Story's controls, to better match our more complex polymorphic component parameters.

Please check the new tests for example usage.

DiogoDoreto avatar Feb 15 '24 10:02 DiogoDoreto

cc @tmeasday @shilman

kasperpeulen avatar Feb 15 '24 10:02 kasperpeulen

Cc @kylegach

shilman avatar Feb 15 '24 11:02 shilman

Nice work, @DiogoDoreto!

The API is as straightforward as I can imagine it being. I recommend that we only document one level of nesting, though, even if it's implemented recursively as it is here.

That said...

to better match our more complex polymorphic component parameters

I wonder if there's something better we could offer for this use case, that wouldn't require manually authoring a bunch of complex conditions. Whatever that is, it could likely be implemented as an auto-generation of this feature. So this PR is still valuable.

kylegach avatar Feb 16 '24 03:02 kylegach

Thanks, @kylegach!

Regarding your last point, what we really thought about initially was to have the options of a control to be dynamic and based on the values of other controls. Since this was a major change from the current requirement of being statically defined we tried to avoid it. The current solution is to multiply the number of controls with pre-calculated options and predefined rules for visibility — where multiple conditions come in handy. And yes, we are autogenerating those :)

DiogoDoreto avatar Feb 16 '24 07:02 DiogoDoreto

This would be great. Is anyone looking at this PR and going to see about merging it in?

darkgrayknight avatar Aug 02 '24 20:08 darkgrayknight