|
|
|
@ -44,23 +44,6 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Index do
|
|
|
|
|
params={@params}
|
|
|
|
|
/>
|
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
<.modal
|
|
|
|
|
:if={@live_action in [:new, :edit]}
|
|
|
|
|
id="author-modal"
|
|
|
|
|
show
|
|
|
|
|
on_cancel={JS.patch(~p"/authors")}
|
|
|
|
|
>
|
|
|
|
|
<.live_component
|
|
|
|
|
module={DecentralisedBookIndexWeb.AuthorLive.FormComponent}
|
|
|
|
|
id={(@author && @author.id) || :new}
|
|
|
|
|
title={@page_title}
|
|
|
|
|
current_user={@current_user}
|
|
|
|
|
action={@live_action}
|
|
|
|
|
author={@author}
|
|
|
|
|
patch={~p"/authors"}
|
|
|
|
|
/>
|
|
|
|
|
</.modal>
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -118,18 +101,8 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Index do
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
|
def handle_info({DecentralisedBookIndexWeb.AuthorLive.FormComponent, {:saved, author}}, socket) do
|
|
|
|
|
{:noreply, stream_insert(socket, :authors, author)}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
|
def handle_event("delete", %{"id" => id}, socket) do
|
|
|
|
|
author =
|
|
|
|
|
Ash.get!(DecentralisedBookIndex.Metadata.Author, id, actor: socket.assigns.current_user)
|
|
|
|
|
|
|
|
|
|
Ash.destroy!(author, actor: socket.assigns.current_user)
|
|
|
|
|
|
|
|
|
|
{:noreply, stream_delete(socket, :authors, author)}
|
|
|
|
|
def handle_info({DecentralisedBookIndexWeb.AuthorLive.FormComponent, {:saved, _author}}, socket) do
|
|
|
|
|
{:noreply, socket}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
defp sort_options do
|
|
|
|
|