AshPhoenix.FilterForm (ash_phoenix v0.6.0-rc.0) View Source
Create a new filter form.
Options:
:params
- Initial parameters to create the form with The default value is%{}
.:remove_empty_groups?
- If true (the default), then any time a group would be made empty by removing a group or predicate, it is removed instead.
An empty form can still be added, this only affects a group if its last component is removed. The default value isfalse
.
Link to this section Summary
Functions
Adde a group to the filter.
Add a predicate to the filter.
Returns a flat list of all errors on all predicates in the filter.
Returns the list of available fields, which may be attribuets, calculations, or aggregates.
Converts the form into a filter, and filters the provided query or resource with that filter.
Same as filter/2
but raises on errors.
Returns the list of available predicates for the given resource, which may be functions or operators.
Removes the group or component with the given id
Remove the group with the given id
Remove the predicate with the given id
Returns a filter expression that can be provided to Ash.Query.filter/2
Same as to_filter/1
Updates the filter with the provided input and validates it.
Link to this section Functions
Adde a group to the filter.
Options:
:to
- The nested group id to add the group to.:operator
- The operator that the group should have internally. The default value is:and
.
add_predicate(form, field, operator_or_function, value, opts \\ [])
View SourceAdd a predicate to the filter.
Options:
:to
- The group id to add the predicate to. If not set, will be added to the top level group.
Returns a flat list of all errors on all predicates in the filter.
Returns the list of available fields, which may be attribuets, calculations, or aggregates.
Converts the form into a filter, and filters the provided query or resource with that filter.
Same as filter/2
but raises on errors.
Returns the list of available predicates for the given resource, which may be functions or operators.
Removes the group or component with the given id
Remove the group with the given id
Remove the predicate with the given id
Returns a filter expression that can be provided to Ash.Query.filter/2
To add this to a query, remember to use ^
, for example:
filter = AshPhoenix.FilterForm.to_filter(form)
Ash.Query.filter(MyApp.Post, ^filter)
Alternatively, you can use the shorthand: filter/2
.
Same as to_filter/1
Updates the filter with the provided input and validates it.
At present, no validation actually occurs, but this will eventually be added.