|
|
|
@ -2,6 +2,7 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Show do
|
|
|
|
|
use DecentralisedBookIndexWeb, :live_view
|
|
|
|
|
|
|
|
|
|
alias DecentralisedBookIndex.Accounts.Role
|
|
|
|
|
alias DecentralisedBookIndex.Metadata
|
|
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
|
def render(assigns) do
|
|
|
|
@ -96,6 +97,19 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Show do
|
|
|
|
|
</ul>
|
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
<%= if not Enum.empty?(@page.results) do %>
|
|
|
|
|
<h2 class="mb-2 text-lg font-semibold text-gray-900 dark:text-white mt-10">
|
|
|
|
|
Books
|
|
|
|
|
</h2>
|
|
|
|
|
<div class="flex flex-wrap flex-[3_1_auto]">
|
|
|
|
|
<%= for book <- @page.results do %>
|
|
|
|
|
<.book_card book={book} current_user={@current_user} />
|
|
|
|
|
<% end %>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<.pagination endpoint={~p"/authors/#{@author}"} page={@page} page_params={@page_params} params={@params} />
|
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
<.back navigate={~p"/authors"}>Back to authors</.back>
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
@ -106,19 +120,30 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Show do
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
|
def handle_params(%{"id" => id}, _, socket) do
|
|
|
|
|
def handle_params(%{"id" => id} = params, _, socket) do
|
|
|
|
|
author =
|
|
|
|
|
Ash.get!(DecentralisedBookIndex.Metadata.Author, id,
|
|
|
|
|
Ash.get!(Metadata.Author, id,
|
|
|
|
|
load: [:dbi_server],
|
|
|
|
|
actor: socket.assigns.current_user
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
alternative_names = DecentralisedBookIndex.Metadata.get_author_alternative_names!(author)
|
|
|
|
|
alternative_names = Metadata.get_author_alternative_names!(author)
|
|
|
|
|
|
|
|
|
|
page_params = AshPhoenix.LiveView.page_from_params(params, 10)
|
|
|
|
|
page =
|
|
|
|
|
Metadata.get_author_books!(author,
|
|
|
|
|
load: [:brief_description],
|
|
|
|
|
page: page_params ++ [count: true],
|
|
|
|
|
actor: socket.assigns.current_user
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
{:noreply,
|
|
|
|
|
socket
|
|
|
|
|
|> assign(:page_title, page_title(socket.assigns.live_action))
|
|
|
|
|
|> assign(:author, author)
|
|
|
|
|
|> assign(:page_params, page_params)
|
|
|
|
|
|> assign(:page, page)
|
|
|
|
|
|> assign(:params, params)
|
|
|
|
|
|> assign(:alternative_names, alternative_names)}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|