View Source ExTeal.Resource.Fields behaviour (ExTeal v0.28.1)
Provides the fields/0
callback used by the following ExTeal actions:
- ExTeal.Resource.Index
Summary
Functions
Apply the can_see function attached to a field to filter out the field from serialized responses.
Instead of returning the fields for an index table of a resource,
this function is called to render a simple belongs to field via a
ManyToManyBelongsTo
field.
Find the field on the resource that includes context for the relationship that is being queried.
Callbacks
@callback fields() :: [ExTeal.Field.t()]
Used to get the fields available to the current action.
All resources will override this:
def fields(), do: [
Id.make() |> sortable(),
Text.make('Name') |> sortable(),
DateTime.make(:updated_at, 'Last Updated At') |> hide_from_index()
]
Functions
@spec apply_can_see(ExTeal.Field.t(), Plug.Conn.t()) :: ExTeal.Field.t() | nil
Apply the can_see function attached to a field to filter out the field from serialized responses.
Instead of returning the fields for an index table of a resource,
this function is called to render a simple belongs to field via a
ManyToManyBelongsTo
field.
Given a many to many relationship between posts and tags, an index query for the tags associated with a post should return a single many to many belongs to field that represents a tag associated with the post. The field will then have options built up to make it behave like a belongs_to on the client side.
Find the field on the resource that includes context for the relationship that is being queried.