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
andedit_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 apprepo
- Your app's Reposchemas
- The schemas to make Admin sections forview_module
- (Optional) The view_module to use to display pages. Uses Adminable's view module by default. You can export the view to modify usingmix 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
Specs
create_changeset(any(), any()) :: Ecto.Changeset.t()
Returns a changeset used for creating new schemas
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