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

serialized_filter() :: %{
  :as => String.t(),
  :field => String.t(),
  :label => String.t(),
  :operators => [map()],
  optional(any()) => any()
}

Specs

valid_type() :: module() | false

Link to this section Callbacks

Link to this callback

filter(t, map, t, module)

View Source

Specs

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 defined
  • no_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

Link to this function

default_serialization(field, interface_type, operators)

View Source

Default serialization of a field filter

Link to this function

for_resource(resource, conn)

View Source

Iterates over a resources fields, and serializes them into a response that can be used by the vue app to build some logic

Link to this function

query(query, filter_params, resource)

View Source

Specs

Iterate over the fields from an index query, build the related field filter and apply their queries.