View Source Adminable behaviour (Adminable v0.4.0)

Behaviour to capture how to build admin interfaces and which fields to allow to edit

Configuration

  • Add use Adminable to your Ecto Schema. Optionally
defmodule MyApp.User do
  use Ecto.Schema
  import Ecto.{Query, Changeset}, warn: false
  use Adminable

  ...
end
  • optionally implement fields/0, create_changeset/2 and edit_changeset/2

  • Forward to Adminable.Router

scope "/admin" do
  pipe_through [:browser, :my, :other, :pipelines]

  forward("/", Adminable.Plug, [
    otp_app: :my_app,
    repo: MyApp.Repo,
    schemas: [MyApp.User],
    view_module: MyAppWeb.Adminable.AdminView
    layout: {MyAppWeb.LayoutView, "app.html"}
  ])
end

Arguments

  • otp_app - Your app
  • repo - Your app's Repo
  • schemas - The schemas to make Admin sections for
  • view_module - (Optional) The view_module to use to display pages. Uses Adminable's view module by default. You can export the view to modify using mix adminable.gen.view MyWebModule
  • layout - (Optional) The layout to use

Link to this section Summary

Callbacks

Returns a changeset used for creating new schemas

Returns a changeset used for editing existing schemas

A list of fields for to show and edit in Adminable. The primary key will be excluded from create and edit forms

Link to this section Callbacks

Link to this callback

create_changeset(any, any)

View Source

Specs

create_changeset(any(), any()) :: Ecto.Changeset.t()

Returns a changeset used for creating new schemas

Link to this callback

edit_changeset(any, any)

View Source

Specs

edit_changeset(any(), any()) :: Ecto.Changeset.t()

Returns a changeset used for editing existing schemas

Specs

fields() :: [atom()]

A list of fields for to show and edit in Adminable. The primary key will be excluded from create and edit forms