Second, is taking its output, and mapping that to an Ash Query filter. There are numerous export options, see Export | React Query Builder, and I couldn’t tell which would be the best starting point.
k, I had stumbled on Ash.Query.html#filter_input/2 Ash.Query — ash v2.17.21 so I can munge it to conform to that.
I am using Liveview. I just didn’t want to spend a day or two making a simplistic version of the react query builder. Or were you going somewhere else with that? If I manage to get this PoC to beta, maybe I would rip out the react tools with custom liveview ones.
To construct the fields for the builder, something like MyApp.MyResource.spark_dsl_config[[:attributes]] seems like my best starting point. Agree?
So, we have the data structure for backing a filter form, but not the UI, meant to be used with live view. It can be a bit complicated to wield, but once you get it working it’s quite useful. Check out Ash.FilterForm. Maybe someone from the community can provide an example implementation/tips. I know @frankdugan3 has used it, among others. Would like to work up an example and better docs, haven’t had the chance.
Maintainer of React Query Builder here. I’m not familiar with this framework but this post came up in my Google alerts. If there’s anything I can do or questions I can answer about RQB, let me know!
FilterForm is pretty cool. Thanks for pointing that out!
The one shipped in ash_phoenix seems to be missing relationships. A demo you posted in Zach Daniel posted on LinkedIn shows relationships being used. Any thoughts on how that was accomplished?
The users of this feature are used to writing their own SQL, so I’m tempted to just let them write some JSON which gets converted to a Map that is compatible with Ash.Query.filter and just move one with life and build the UI later. This was one of those “if it is quick to implement, do it, otherwise move on” features.
That being said, can user text input, like first_name == "Zar" and last_name in ["Doz", "Daz"] and high_score > 10 be passed to any of the Ash filter or expr functions, or is that bonkers?