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

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

This behaviour is used by all ExTeal actions.

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.

Callbacks

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

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

@callback 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.

@callback search() :: [atom()]

The fields that should be searched

@callback 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
@callback 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
@callback 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

@callback 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
@callback 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

@callback uri() :: String.t()

Returns the uri to display in the side bar.

Defaults to finding the uri from the resource modules name

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