ExTeal.FieldFilter behaviour (ExTeal v0.21.0) View Source
Functionality for gathering and parsing filters for a resource index based on the fields present on the resource.
Link to this section Summary
Callbacks
Build a field filter by extending the incoming query with the following arguments
Type of filter component to use in the user interface.
Define the available operators for the filter and the behaviour of each.
Builds the map that allows the user interface to represent the field filter and all of it's configuration.
Functions
Default serialization of a field filter
Iterates over a resources fields, and serializes them into a response that can be used by the vue app to build some logic
Iterate over the fields from an index query, build the related field filter and apply their queries.
Link to this section Types
Specs
Specs
valid_type() :: module() | false
Link to this section Callbacks
Specs
filter(Ecto.Queryable.t(), map(), ExTeal.Field.t(), module()) :: Ecto.Queryable.t()
Build a field filter by extending the incoming query with the following arguments:
- The query being built (Ecto.Queryable from the Index module)
- The configuration of the field filter as a string keyed map:
- "operator" a string representing the operation selected by the user that is being performed
- "operand" a string or map representing the value to apply against the operand and query
- The field struct being queried
- The resource module for the resource being queried
Specs
interface_type() :: String.t() | nil
Type of filter component to use in the user interface.
Specs
operators(ExTeal.Field.t()) :: [map()]
Define the available operators for the filter and the behaviour of each.
Each available operator is defined by a map with the following keys:
op
(required) the operator being definedno_operand
(optional) set to true for an operator that does not require an operand.component
(optional) override the default operand component, which defaults to a string field.
Specs
serialize(ExTeal.Field.t(), module()) :: serialized_filter()
Builds the map that allows the user interface to represent the field filter and all of it's configuration.
Can be configured for customization on a per filter basis.
Link to this section Functions
Default serialization of a field filter
Iterates over a resources fields, and serializes them into a response that can be used by the vue app to build some logic
Specs
query(Ecto.Queryable.t(), [map()], module()) :: Ecto.Queryable.t()
Iterate over the fields from an index query, build the related field filter and apply their queries.