Add the update action for the Book FormComponent.
This commit is contained in:
@@ -42,6 +42,28 @@ defmodule DecentralisedBookIndexWeb.BookLive.FormComponent do
|
||||
/>
|
||||
<% end %>
|
||||
<%= if @form.source.type == :update do %>
|
||||
<.input field={@form[:title]} type="text" label="Title" />
|
||||
<.input field={@form[:cover_image_url]} type="text" label="Cover image url" />
|
||||
<.input
|
||||
field={@form[:description]}
|
||||
type="textarea"
|
||||
label="Description"
|
||||
/>
|
||||
<.bids_inputs form={@form} myself={@myself} />
|
||||
<.author_roles_inputs form={@form} myself={@myself} />
|
||||
<.input field={@form[:format]} type="text" label="Format" />
|
||||
<.input
|
||||
field={@form[:language]}
|
||||
type="text"
|
||||
label="Language"
|
||||
/>
|
||||
<.input field={@form[:page_count]} type="number" label="Page count" />
|
||||
<.input field={@form[:publisher_id]} type="text" label="Publisher" />
|
||||
<.input
|
||||
field={@form[:published]}
|
||||
type="date"
|
||||
label="Published"
|
||||
/>
|
||||
<% end %>
|
||||
|
||||
<:actions>
|
||||
@@ -253,6 +275,10 @@ defmodule DecentralisedBookIndexWeb.BookLive.FormComponent do
|
||||
defp assign_form(%{assigns: %{book: book}} = socket) do
|
||||
form =
|
||||
if book do
|
||||
book =
|
||||
book
|
||||
|> Ash.load!([:bids, :author_roles, :publisher])
|
||||
|
||||
AshPhoenix.Form.for_update(book, :update, as: "book", actor: socket.assigns.current_user)
|
||||
else
|
||||
AshPhoenix.Form.for_create(DecentralisedBookIndex.Metadata.Book, :create,
|
||||
|
||||
Reference in New Issue
Block a user