ExTeal.Resource.Model behaviour (ExTeal v0.21.0) View Source

Provides the model/0 callback used to customize the resource served.

This behaviour is used by all ExTeal actions.

Link to this section Summary

Callbacks

Array of default field filters to be used when there are no filters present

Must return the module implementing Ecto.Schema to be represented.

The fields that should be searched

Returns the singularized version of the title to display on forms.

Returns the subtitle to display in relationships.

Returns the thumbnail to display in search.

Returns the title to display in the side bar.

Returns the title to display in relationships.

Returns the uri to display in the side bar.

Link to this section Callbacks

Specs

default_filters() :: [map()] | nil

Array of default field filters to be used when there are no filters present

Specs

model() :: module()

Must return the module implementing Ecto.Schema to be represented.

Example:

def model, do: MyApp.Models.Post

Defaults to the name of the resource, for example the resource MyApp.V1.PostResource would serve the MyApp.Post model.

Used by the default implementations for handle_create/2, handle_update/3, and records/1.

Specs

search() :: [atom()]

The fields that should be searched

Specs

singular_title() :: String.t()

Returns the singularized version of the title to display on forms.

Link to this callback

subtitle_for_schema(struct)

View Source

Specs

subtitle_for_schema(struct()) :: String.t() | nil

Returns the subtitle to display in relationships.

Defaults to looking for name or title fields, falls back to the schemas name appended by it's id

Link to this callback

thumbnail_for_schema(struct)

View Source

Specs

thumbnail_for_schema(struct()) :: String.t() | nil

Returns the thumbnail to display in search.

Defaults to looking for name or title fields, falls back to the schemas name appended by it's id

Specs

title() :: String.t()

Returns the title to display in the side bar.

Defaults to finding the title from the resource modules name

Link to this callback

title_for_schema(struct)

View Source

Specs

title_for_schema(struct()) :: String.t() | nil

Returns the title to display in relationships.

Defaults to looking for name or title fields, falls back to the schemas name appended by it's id

Specs

uri() :: String.t()

Returns the uri to display in the side bar.

Defaults to finding the uri from the resource modules name

Link to this section Functions

Link to this function

model_from_resource(module)

View Source
Link to this function

title_for_schema_from_struct(struct)

View Source
Link to this function

title_from_resource(module)

View Source
Link to this function

uri_from_resource(module)

View Source