avo
avo copied to clipboard
Expand dynamic filter conditions
I start to see a pattern.
Maybe the conditions should not be an array of labels or
{key => label}
like we'd use on theselect
input, but have more advanced objects with settings and stuff.conditions: [{ id: :is_within, label: "Is within", is_range: true, small_label: "> x <" # this is displayed on the pill when the filter is collapsed }, { id: is_greater, label: "Greater than", small_label: ">=" }]
But maybe still have it work with a simple array or select-styled options.
[:is_within, :is_greater] # or {is_within: "Is within", is_greater: "Greater than"}
We'd also have to support some kind of fields switching for that. Maybe render two fields of that type instead of one and append
start
andend
to those ID's.So the
query
get's both of them.def filters dynamic_filter :date, conditions: [ { id: :is_within, label: "Is within", is_range: true, small_label: "> x <" # this is displayed on the pill when the filter is collapsed }, { id: is_greater, label: "Greater than", small_label: ">=" } ], query: -> { # Get these params and two fields in the UI for the `is_within` filter params[:date][:start] params[:date][:end] # this one and one field for the `is_greater` filter params[:date] query.DO_SOMETHING_WITH_THOSE_PARAMS } end
WDYT?
Originally posted by @adrianthedev in #3013