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

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

Link to this section 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.

Link to this section Types

Specs

attributes() :: map()

Specs

id() :: String.t() | integer()

Specs

indexed_resource() ::
  struct() | %{_pivot: struct(), _row: struct(), pivot: true}

Specs

orderable_key() ::
  :asc
  | :asc_nulls_first
  | :asc_nulls_last
  | :desc
  | :desc_nulls_first
  | :desc_nulls_last

Specs

orderable_option() :: {orderable_key(), atom()}

Specs

params() :: map()

Specs

record() :: struct()

Specs

records() :: [record()]

Specs

t() :: module()

Specs

validation_errors() :: Ecto.Changeset.t() | keyword()

Link to this section Callbacks

Specs

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

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

Specs

default_order() :: [orderable_option()]

Override the default ordering of the index.

Specs

hide_from_nav() :: boolean()

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

Specs

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

Specs

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.

Specs

skip_sanitize() :: boolean() | nil

Allows skipping sanitize for all fields on a resource

Specs

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

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

Link to this section Functions

Link to this function

map_to_json(resources, conn)

View Source