View Source ExTeal.FieldFilter behaviour (ExTeal v0.28.1)
Functionality for gathering and parsing filters for a resource index based on the fields present on the resource.
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.
Types
@type valid_type() :: module() | false
Callbacks
@callback 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
@callback interface_type() :: String.t() | nil
Type of filter component to use in the user interface.
@callback 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.
@callback 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.
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
@spec query(Ecto.Queryable.t(), [map()], module(), Plug.Conn.t()) :: Ecto.Queryable.t()
Iterate over the fields from an index query, build the related field filter and apply their queries.