Update the Book form to add fields: cover image url and publisher id.
This commit is contained in:
@@ -19,6 +19,7 @@ defmodule DecentralisedBookIndexWeb.BookLive.FormComponent do
|
|||||||
>
|
>
|
||||||
<%= if @form.source.type == :create do %>
|
<%= if @form.source.type == :create do %>
|
||||||
<.input field={@form[:title]} type="text" label="Title" />
|
<.input field={@form[:title]} type="text" label="Title" />
|
||||||
|
<.input field={@form[:cover_image_url]} type="text" label="Cover image url" />
|
||||||
<.input
|
<.input
|
||||||
field={@form[:description]}
|
field={@form[:description]}
|
||||||
type="text"
|
type="text"
|
||||||
@@ -26,11 +27,15 @@ defmodule DecentralisedBookIndexWeb.BookLive.FormComponent do
|
|||||||
/>
|
/>
|
||||||
<.bids_inputs form={@form} myself={@myself} />
|
<.bids_inputs form={@form} myself={@myself} />
|
||||||
<.author_roles_inputs form={@form} myself={@myself} />
|
<.author_roles_inputs form={@form} myself={@myself} />
|
||||||
<.input field={@form[:format]} type="text" label="Format" /><.input
|
<.input field={@form[:format]} type="text" label="Format" />
|
||||||
|
<.input
|
||||||
field={@form[:language]}
|
field={@form[:language]}
|
||||||
type="text"
|
type="text"
|
||||||
label="Language"
|
label="Language"
|
||||||
/><.input field={@form[:page_count]} type="number" label="Page count" /><.input
|
/>
|
||||||
|
<.input field={@form[:page_count]} type="number" label="Page count" />
|
||||||
|
<.input field={@form[:publisher_id]} type="text" label="Publisher" />
|
||||||
|
<.input
|
||||||
field={@form[:published]}
|
field={@form[:published]}
|
||||||
type="date"
|
type="date"
|
||||||
label="Published"
|
label="Published"
|
||||||
@@ -49,7 +54,7 @@ defmodule DecentralisedBookIndexWeb.BookLive.FormComponent do
|
|||||||
|
|
||||||
def bids_inputs(assigns) do
|
def bids_inputs(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<h2>Book Ids</h2>
|
<h2>Book ids</h2>
|
||||||
|
|
||||||
<table class="w-full">
|
<table class="w-full">
|
||||||
<thead class="border-b border-zinc-100">
|
<thead class="border-b border-zinc-100">
|
||||||
@@ -235,10 +240,6 @@ defmodule DecentralisedBookIndexWeb.BookLive.FormComponent do
|
|||||||
AshPhoenix.Form.for_update(book, :update, as: "book", actor: socket.assigns.current_user)
|
AshPhoenix.Form.for_update(book, :update, as: "book", actor: socket.assigns.current_user)
|
||||||
else
|
else
|
||||||
AshPhoenix.Form.for_create(DecentralisedBookIndex.Metadata.Book, :create,
|
AshPhoenix.Form.for_create(DecentralisedBookIndex.Metadata.Book, :create,
|
||||||
transform_params: fn _form, params, _context ->
|
|
||||||
Map.put(params, "author_roles", ["d880b385-5df6-4127-a49c-16f9070ea066"])
|
|
||||||
Map.put(params, "publishers", ["9ca6f110-8ef4-494b-9979-f5b016d0f45e"])
|
|
||||||
end,
|
|
||||||
as: "book",
|
as: "book",
|
||||||
actor: socket.assigns.current_user
|
actor: socket.assigns.current_user
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user