|
|
|
@ -32,6 +32,18 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.FormComponent do
|
|
|
|
|
/>
|
|
|
|
|
<% end %>
|
|
|
|
|
<%= if @form.source.type == :update do %>
|
|
|
|
|
<.input field={@form[:name]} type="text" label="Name" />
|
|
|
|
|
<.input field={@form[:avatar_url]} type="text" label="Cover image url" />
|
|
|
|
|
<.input
|
|
|
|
|
field={@form[:description]}
|
|
|
|
|
type="text"
|
|
|
|
|
label="Description"
|
|
|
|
|
/>
|
|
|
|
|
<.input
|
|
|
|
|
field={@form[:author_alias_registry_id]}
|
|
|
|
|
type="text"
|
|
|
|
|
label="Author alias registry"
|
|
|
|
|
/>
|
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
<:actions>
|
|
|
|
@ -63,7 +75,7 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.FormComponent do
|
|
|
|
|
socket =
|
|
|
|
|
socket
|
|
|
|
|
|> put_flash(:info, "Author #{socket.assigns.form.source.type}d successfully")
|
|
|
|
|
|> push_patch(to: socket.assigns.patch)
|
|
|
|
|
|> push_redirect(to: patch_url(socket.assigns.action, author.id))
|
|
|
|
|
|
|
|
|
|
{:noreply, socket}
|
|
|
|
|
|
|
|
|
@ -90,4 +102,12 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.FormComponent do
|
|
|
|
|
|
|
|
|
|
assign(socket, form: to_form(form))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
defp patch_url(action, author_id) do
|
|
|
|
|
case action do
|
|
|
|
|
:edit -> ~p"/authors/#{author_id}"
|
|
|
|
|
:new -> ~p"/authors"
|
|
|
|
|
_ -> ~p"/authors"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|