|
|
|
@ -48,6 +48,7 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.FormComponent do
|
|
|
|
|
|
|
|
|
|
<:actions>
|
|
|
|
|
<.button phx-disable-with="Saving...">Save Author</.button>
|
|
|
|
|
<.button phx-click="cancel" phx-target={@myself} class="me-auto">Cancel</.button>
|
|
|
|
|
</:actions>
|
|
|
|
|
</.simple_form>
|
|
|
|
|
</div>
|
|
|
|
@ -84,6 +85,17 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.FormComponent do
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def handle_event("cancel", _params, socket) do
|
|
|
|
|
author = socket.assigns.author
|
|
|
|
|
author_id = if author == nil, do: nil, else: author.id
|
|
|
|
|
|
|
|
|
|
socket =
|
|
|
|
|
socket
|
|
|
|
|
|> push_redirect(to: patch_url(socket.assigns.action, author_id))
|
|
|
|
|
|
|
|
|
|
{:noreply, socket}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
defp notify_parent(msg), do: send(self(), {__MODULE__, msg})
|
|
|
|
|
|
|
|
|
|
defp assign_form(%{assigns: %{author: author}} = socket) do
|
|
|
|
|