Update the Book Show LiveView.
continuous-integration/drone/push Build is failing Details

dev
KKlochko 2 months ago
parent aaa18fd1b6
commit 7779308cc6

@ -31,34 +31,43 @@ defmodule DecentralisedBookIndexWeb.BookLive.Show do
</:actions> </:actions>
</.header> </.header>
<div class="flex flex-wrap flex-[2_1_auto] gap-5"> <div class="mb-4">
<%= if @book.cover_image_url != nil do %> <%= if @book.cover_image_url != nil do %>
<img class="w-36 shadow-lg mt-14 mx-auto md:mx-0 object-cover" src={@book.cover_image_url} alt={"#{@book.title} image"}/> <img class="w-36 shadow-lg mt-14 mx-auto object-cover" src={@book.cover_image_url} alt={"#{@book.title} image"}/>
<% else %> <% else %>
<div class="relative w-36 h-36 overflow-hidden mt-14 mx-auto md:mx-0"> <div class="relative w-36 h-36 overflow-hidden mt-14 mx-auto">
<svg class="w-36 h-36 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24"> <svg class="w-36 h-36 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
<path fill-rule="evenodd" d="M6 2a2 2 0 0 0-2 2v15a3 3 0 0 0 3 3h12a1 1 0 1 0 0-2h-2v-2h2a1 1 0 0 0 1-1V4a2 2 0 0 0-2-2h-8v16h5v2H7a1 1 0 1 1 0-2h1V2H6Z" clip-rule="evenodd"/> <path fill-rule="evenodd" d="M6 2a2 2 0 0 0-2 2v15a3 3 0 0 0 3 3h12a1 1 0 1 0 0-2h-2v-2h2a1 1 0 0 0 1-1V4a2 2 0 0 0-2-2h-8v16h5v2H7a1 1 0 1 1 0-2h1V2H6Z" clip-rule="evenodd"/>
</svg> </svg>
</div> </div>
<% end %> <% end %>
</div>
<.list> <div>
<:item title="Id">{@book.id}</:item> <dl>
<dt class="mb-2 font-semibold leading-none text-gray-900 dark:text-white">Description</dt>
<:item title="Title">{@book.title}</:item> <dd class="mb-4 font-light text-gray-500 sm:mb-5 dark:text-gray-400">{@book.description}</dd>
</dl>
<:item title="Description">{@book.description}</:item> <dl>
<dt class="mb-2 font-semibold leading-none text-gray-900 dark:text-white">Publisher</dt>
<:item title="Published">{@book.published}</:item> <dd class="mb-4 font-light text-gray-500 sm:mb-5 dark:text-gray-400">{@book.publisher.name}</dd>
</dl>
<:item title="Language">{@book.language}</:item> <dl>
<dt class="mb-2 font-semibold leading-none text-gray-900 dark:text-white">Published</dt>
<:item title="Format">{@book.format}</:item> <dd class="mb-4 font-light text-gray-500 sm:mb-5 dark:text-gray-400">{@book.published}</dd>
</dl>
<:item title="Page count">{@book.page_count}</:item> <dl>
<dt class="mb-2 font-semibold leading-none text-gray-900 dark:text-white">Format</dt>
<:item title="Cover image url">{@book.cover_image_url}</:item> <dd class="mb-4 font-light text-gray-500 sm:mb-5 dark:text-gray-400">{@book.format}</dd>
</.list> </dl>
<dl>
<dt class="mb-2 font-semibold leading-none text-gray-900 dark:text-white">Page Count</dt>
<dd class="mb-4 font-light text-gray-500 sm:mb-5 dark:text-gray-400">{@book.page_count}</dd>
</dl>
<dl>
<dt class="mb-2 font-semibold leading-none text-gray-900 dark:text-white">Language</dt>
<dd class="mb-4 font-light text-gray-500 sm:mb-5 dark:text-gray-400">{@book.language}</dd>
</dl>
</div> </div>
<%= if not Enum.empty?(@alternative_editions) do %> <%= if not Enum.empty?(@alternative_editions) do %>
@ -84,7 +93,7 @@ defmodule DecentralisedBookIndexWeb.BookLive.Show do
@impl true @impl true
def handle_params(%{"id" => id}, _, socket) do def handle_params(%{"id" => id}, _, socket) do
book = Ash.get!(Metadata.Book, id, actor: socket.assigns.current_user, load: [:author_roles]) book = Ash.get!(Metadata.Book, id, actor: socket.assigns.current_user, load: [:author_roles, :publisher])
alternative_editions = Metadata.get_book_alternative_editions!(book) alternative_editions = Metadata.get_book_alternative_editions!(book)
{:noreply, {:noreply,

Loading…
Cancel
Save