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

When used, includes all aspects of the functionality required to manage the resource.

Example usage in a ExTeal Resource:

defmodule ExampleWeb.ExTeal.BlogResource do
  use ExTeal.Resource

  alias Example.Content.Blog

  def resource, do: Blog

  def title, do: "blog"
end

Summary

Callbacks

Provide a list of action cards to render them above the resource index

Override the default ordering of the index.

Hide the Resource from the sidenav in the user interface, defaults to false.

If you would like to separate resources into different sidebar groups, you can override the nav_group/1 function on the resource.

Override the detail or edit link for a resource on the resource index.

Allows skipping sanitize for all fields on a resource

Specifies the field to use as the basis for a drag and drop interface for the collection.

Types

@type attributes() :: map()
@type id() :: String.t() | integer()
@type indexed_resource() :: struct() | pivot_resource()
@type orderable_key() ::
  :asc
  | :asc_nulls_first
  | :asc_nulls_last
  | :desc
  | :desc_nulls_first
  | :desc_nulls_last
@type orderable_option() :: {orderable_key(), atom()}
@type params() :: map()
@type pivot_resource() :: %{_pivot: struct(), _row: struct(), pivot: true}
@type record() :: struct()
@type records() :: [record()]
@type t() :: module()
@type validation_errors() :: Ecto.Changeset.t() | keyword()

Callbacks

@callback cards(Plug.Conn.t()) :: [module()]

Provide a list of action cards to render them above the resource index

@callback default_order() :: [orderable_option()]

Override the default ordering of the index.

@callback hide_from_nav() :: boolean()

Hide the Resource from the sidenav in the user interface, defaults to false.

@callback nav_group(Plug.Conn.t()) :: String.t() | nil

If you would like to separate resources into different sidebar groups, you can override the nav_group/1 function on the resource.

Link to this callback

navigate_to(arg1, t, indexed_resource)

View Source
@callback navigate_to(:detail | :edit, Plug.Conn.t(), indexed_resource()) :: %{
  resource_name: String.t(),
  resource_id: String.t()
}

Override the detail or edit link for a resource on the resource index.

When defining this callback, be aware that resources referenced by a many to many relationship will also call this function when rendering the index of that many to many.

@callback skip_sanitize() :: boolean() | nil

Allows skipping sanitize for all fields on a resource

@callback sortable_by() :: String.t() | nil

Specifies the field to use as the basis for a drag and drop interface for the collection.

Functions

Link to this function

map_to_json(resources, conn)

View Source