Incant.Resource (incant v0.1.0)

Copy Markdown

Defines a code-first admin resource.

Resources describe table columns, filters, row actions, forms, and the data source used by the generic LiveView renderer.

defmodule MyApp.Admin.Resources.Product do
  use Incant.Resource,
    schema: MyApp.Catalog.Product,
    repo: MyApp.Repo

  changeset &MyApp.Catalog.Product.changeset/2

  table do
    column :name, link: true
    column :status, as: :badge
    filter :status, :select, options: [:draft, :active]
    action :edit
  end
end

Summary

Functions

action(name, opts \\ [])

(macro)

actions(list)

(macro)

bulk(name, opts \\ [])

(macro)

changeset(callback)

(macro)

column(name, opts \\ [])

(macro)

field(name, type \\ :auto, opts \\ [])

(macro)

filter(name, type \\ :auto, opts \\ [])

(macro)

form(opts \\ [], list)

(macro)

index(callback)

(macro)

index_callback(module, callback)

normalize_action_opts(module, opts)

normalize_callback(module, callback)

normalize_filter_opts(module, name, opts)

page(name, opts \\ [])

(macro)

query(callback)

(macro)

query_transformer(callback)

(macro)

read(callback)

(macro)

read_callback(module, callback)

resource_id(module, opts \\ [])

row(name, opts \\ [])

(macro)

row_detail(name, opts \\ [])

(macro)

search(callback_or_fields)

(macro)

table(opts \\ [], list)

(macro)

transformer(name, opts \\ [])

(macro)

transformer(name, opts, list)

(macro)