Update LiveViews and component to check if user can moderate.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -2,35 +2,40 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents.AuthorCard do
|
|||||||
use Phoenix.Component
|
use Phoenix.Component
|
||||||
use DecentralisedBookIndexWeb, :verified_routes
|
use DecentralisedBookIndexWeb, :verified_routes
|
||||||
|
|
||||||
|
alias DecentralisedBookIndex.Accounts.Role
|
||||||
|
|
||||||
attr(:author, :map, required: true)
|
attr(:author, :map, required: true)
|
||||||
|
attr :current_user, :map, default: nil
|
||||||
|
|
||||||
def author_card(assigns) do
|
def author_card(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<div class="w-full max-w-sm bg-white border border-gray-200 rounded-lg shadow-sm dark:bg-gray-800 dark:border-gray-700 mx-auto my-3">
|
<div class="w-full max-w-sm bg-white border border-gray-200 rounded-lg shadow-sm dark:bg-gray-800 dark:border-gray-700 mx-auto my-3">
|
||||||
<div class="flex justify-end px-4 pt-4">
|
<%= if @current_user != nil and Role.can_moderate?(@current_user.role) do %>
|
||||||
<button id={"dropdownButton#{@author.id}"} data-dropdown-toggle={"dropdown#{@author.id}"} class="inline-block text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:ring-4 focus:outline-none focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-1.5" type="button">
|
<div class="flex justify-end px-4 pt-4">
|
||||||
<span class="sr-only">Open dropdown</span>
|
<button id={"dropdownButton#{@author.id}"} data-dropdown-toggle={"dropdown#{@author.id}"} class="inline-block text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:ring-4 focus:outline-none focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-1.5" type="button">
|
||||||
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 3">
|
<span class="sr-only">Open dropdown</span>
|
||||||
<path d="M2 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm6.041 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM14 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Z"/>
|
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 3">
|
||||||
</svg>
|
<path d="M2 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm6.041 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM14 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Z"/>
|
||||||
</button>
|
</svg>
|
||||||
<!-- Dropdown menu -->
|
</button>
|
||||||
<div id={"dropdown#{@author.id}"} class="z-10 hidden text-base list-none bg-white divide-y divide-gray-100 rounded-lg shadow-sm w-44 dark:bg-gray-700">
|
<!-- Dropdown menu -->
|
||||||
<ul class="py-2" aria-labelledby="dropdownButton">
|
<div id={"dropdown#{@author.id}"} class="z-10 hidden text-base list-none bg-white divide-y divide-gray-100 rounded-lg shadow-sm w-44 dark:bg-gray-700">
|
||||||
<li>
|
<ul class="py-2" aria-labelledby="dropdownButton">
|
||||||
<.link navigate={~p"/authors/#{@author.id}/edit"}
|
<li>
|
||||||
class="flex items-center block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white"
|
<.link navigate={~p"/authors/#{@author.id}/edit"}
|
||||||
>
|
class="flex items-center block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white"
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-2 -ml-0.5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
>
|
||||||
<path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z"></path>
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-2 -ml-0.5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
||||||
<path fill-rule="evenodd" d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" clip-rule="evenodd"></path>
|
<path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z"></path>
|
||||||
</svg>
|
<path fill-rule="evenodd" d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" clip-rule="evenodd"></path>
|
||||||
Edit
|
</svg>
|
||||||
</.link>
|
Edit
|
||||||
</li>
|
</.link>
|
||||||
</ul>
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<% end %>
|
||||||
<div class="flex flex-col items-center py-5 text-center">
|
<div class="flex flex-col items-center py-5 text-center">
|
||||||
<.link navigate={~p"/authors/#{@author.id}"}>
|
<.link navigate={~p"/authors/#{@author.id}"}>
|
||||||
<%= if @author.avatar_url != nil do %>
|
<%= if @author.avatar_url != nil do %>
|
||||||
|
|||||||
@@ -2,9 +2,12 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents.AuthorSearch do
|
|||||||
use Phoenix.Component
|
use Phoenix.Component
|
||||||
use DecentralisedBookIndexWeb, :verified_routes
|
use DecentralisedBookIndexWeb, :verified_routes
|
||||||
|
|
||||||
|
alias DecentralisedBookIndex.Accounts.Role
|
||||||
|
|
||||||
attr :search_query, :string, default: ""
|
attr :search_query, :string, default: ""
|
||||||
attr :select_options, :list, required: true
|
attr :select_options, :list, required: true
|
||||||
attr :selected_option, :string, required: true
|
attr :selected_option, :string, required: true
|
||||||
|
attr :current_user, :map, default: nil
|
||||||
|
|
||||||
def author_search(assigns) do
|
def author_search(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
@@ -24,14 +27,16 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents.AuthorSearch do
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col items-stretch justify-end flex-shrink-0 w-full space-y-2 md:w-auto md:flex-row md:space-y-0 md:items-center md:space-x-3">
|
<div class="flex flex-col items-stretch justify-end flex-shrink-0 w-full space-y-2 md:w-auto md:flex-row md:space-y-0 md:items-center md:space-x-3">
|
||||||
<.link patch={~p"/authors/new"}>
|
<%= if @current_user != nil and Role.can_moderate?(@current_user.role) do %>
|
||||||
<button type="button" class="flex items-center justify-center px-4 py-2 text-sm font-medium text-black dark:text-white rounded-lg bg-primary-700 hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 dark:bg-primary-600 dark:hover:bg-primary-700 focus:outline-none dark:focus:ring-primary-800">
|
<.link patch={~p"/authors/new"}>
|
||||||
<svg class="h-3.5 w-3.5 mr-2" fill="currentColor" viewbox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
<button type="button" class="flex items-center justify-center px-4 py-2 text-sm font-medium text-black dark:text-white rounded-lg bg-primary-700 hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 dark:bg-primary-600 dark:hover:bg-primary-700 focus:outline-none dark:focus:ring-primary-800">
|
||||||
<path clip-rule="evenodd" fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" />
|
<svg class="h-3.5 w-3.5 mr-2" fill="currentColor" viewbox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
||||||
</svg>
|
<path clip-rule="evenodd" fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" />
|
||||||
Add author
|
</svg>
|
||||||
</button>
|
Add author
|
||||||
</.link>
|
</button>
|
||||||
|
</.link>
|
||||||
|
<% end %>
|
||||||
<div class="flex items-center w-full space-x-3 md:w-auto">
|
<div class="flex items-center w-full space-x-3 md:w-auto">
|
||||||
<form phx-change="change-sort">
|
<form phx-change="change-sort">
|
||||||
<select name="sort_by" id="countries" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
|
<select name="sort_by" id="countries" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
|
||||||
|
|||||||
@@ -2,35 +2,40 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents.BookCard do
|
|||||||
use Phoenix.Component
|
use Phoenix.Component
|
||||||
use DecentralisedBookIndexWeb, :verified_routes
|
use DecentralisedBookIndexWeb, :verified_routes
|
||||||
|
|
||||||
|
alias DecentralisedBookIndex.Accounts.Role
|
||||||
|
|
||||||
attr(:book, :map, required: true)
|
attr(:book, :map, required: true)
|
||||||
|
attr :current_user, :map, default: nil
|
||||||
|
|
||||||
def book_card(assigns) do
|
def book_card(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<div class="w-full max-w-sm bg-white border border-gray-200 rounded-lg shadow-sm dark:bg-gray-800 dark:border-gray-700 mx-auto my-3">
|
<div class="w-full max-w-sm bg-white border border-gray-200 rounded-lg shadow-sm dark:bg-gray-800 dark:border-gray-700 mx-auto my-3">
|
||||||
<div class="flex justify-end px-4 pt-4">
|
<%= if @current_user != nil and Role.can_moderate?(@current_user.role) do %>
|
||||||
<button id={"dropdownButton#{@book.id}"} data-dropdown-toggle={"dropdown#{@book.id}"} class="inline-block text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:ring-4 focus:outline-none focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-1.5" type="button">
|
<div class="flex justify-end px-4 pt-4">
|
||||||
<span class="sr-only">Open dropdown</span>
|
<button id={"dropdownButton#{@book.id}"} data-dropdown-toggle={"dropdown#{@book.id}"} class="inline-block text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:ring-4 focus:outline-none focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-1.5" type="button">
|
||||||
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 3">
|
<span class="sr-only">Open dropdown</span>
|
||||||
<path d="M2 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm6.041 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM14 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Z"/>
|
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 3">
|
||||||
</svg>
|
<path d="M2 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm6.041 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM14 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Z"/>
|
||||||
</button>
|
</svg>
|
||||||
<!-- Dropdown menu -->
|
</button>
|
||||||
<div id={"dropdown#{@book.id}"} class="z-10 hidden text-base list-none bg-white divide-y divide-gray-100 rounded-lg shadow-sm w-44 dark:bg-gray-700">
|
<!-- Dropdown menu -->
|
||||||
<ul class="py-2" aria-labelledby="dropdownButton">
|
<div id={"dropdown#{@book.id}"} class="z-10 hidden text-base list-none bg-white divide-y divide-gray-100 rounded-lg shadow-sm w-44 dark:bg-gray-700">
|
||||||
<li>
|
<ul class="py-2" aria-labelledby="dropdownButton">
|
||||||
<.link navigate={~p"/books/#{@book.id}/edit"}
|
<li>
|
||||||
class="flex items-center block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white"
|
<.link navigate={~p"/books/#{@book.id}/edit"}
|
||||||
>
|
class="flex items-center block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white"
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-2 -ml-0.5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
>
|
||||||
<path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z"></path>
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-2 -ml-0.5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
||||||
<path fill-rule="evenodd" d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" clip-rule="evenodd"></path>
|
<path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z"></path>
|
||||||
</svg>
|
<path fill-rule="evenodd" d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" clip-rule="evenodd"></path>
|
||||||
Edit
|
</svg>
|
||||||
</.link>
|
Edit
|
||||||
</li>
|
</.link>
|
||||||
</ul>
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<% end %>
|
||||||
<div class="flex flex-col items-center py-5 text-center">
|
<div class="flex flex-col items-center py-5 text-center">
|
||||||
<.link navigate={~p"/books/#{@book.id}"}>
|
<.link navigate={~p"/books/#{@book.id}"}>
|
||||||
<%= if @book.cover_image_url != nil do %>
|
<%= if @book.cover_image_url != nil do %>
|
||||||
|
|||||||
@@ -2,12 +2,16 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents.BookSearch do
|
|||||||
use Phoenix.Component
|
use Phoenix.Component
|
||||||
use DecentralisedBookIndexWeb, :verified_routes
|
use DecentralisedBookIndexWeb, :verified_routes
|
||||||
|
|
||||||
|
alias DecentralisedBookIndex.Accounts.Role
|
||||||
|
|
||||||
attr :search_query, :string, default: ""
|
attr :search_query, :string, default: ""
|
||||||
attr :search_mode, :string, default: "title"
|
attr :search_mode, :string, default: "title"
|
||||||
attr :search_mode_options, :list, required: true
|
attr :search_mode_options, :list, required: true
|
||||||
attr :select_options, :list, required: true
|
attr :select_options, :list, required: true
|
||||||
attr :selected_option, :string, required: true
|
attr :selected_option, :string, required: true
|
||||||
|
|
||||||
|
attr :current_user, :map, default: nil
|
||||||
|
|
||||||
def book_search(assigns) do
|
def book_search(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<div class="relative bg-white shadow-md dark:bg-gray-800 sm:rounded-lg">
|
<div class="relative bg-white shadow-md dark:bg-gray-800 sm:rounded-lg">
|
||||||
@@ -26,14 +30,16 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents.BookSearch do
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col items-stretch justify-end flex-shrink-0 w-full space-y-2 md:w-auto md:flex-row md:space-y-0 md:items-center md:space-x-3">
|
<div class="flex flex-col items-stretch justify-end flex-shrink-0 w-full space-y-2 md:w-auto md:flex-row md:space-y-0 md:items-center md:space-x-3">
|
||||||
<.link patch={~p"/books/new"}>
|
<%= if @current_user != nil and Role.can_moderate?(@current_user.role) do %>
|
||||||
<button type="button" class="flex items-center justify-center px-4 py-2 text-sm font-medium text-black dark:text-white rounded-lg bg-primary-700 hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 dark:bg-primary-600 dark:hover:bg-primary-700 focus:outline-none dark:focus:ring-primary-800">
|
<.link patch={~p"/books/new"}>
|
||||||
<svg class="h-3.5 w-3.5 mr-2" fill="currentColor" viewbox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
<button type="button" class="flex items-center justify-center px-4 py-2 text-sm font-medium text-black dark:text-white rounded-lg bg-primary-700 hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 dark:bg-primary-600 dark:hover:bg-primary-700 focus:outline-none dark:focus:ring-primary-800">
|
||||||
<path clip-rule="evenodd" fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" />
|
<svg class="h-3.5 w-3.5 mr-2" fill="currentColor" viewbox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
||||||
</svg>
|
<path clip-rule="evenodd" fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" />
|
||||||
Add book
|
</svg>
|
||||||
</button>
|
Add book
|
||||||
</.link>
|
</button>
|
||||||
|
</.link>
|
||||||
|
<% end %>
|
||||||
<.dropdown_settings
|
<.dropdown_settings
|
||||||
search_mode={@search_mode}
|
search_mode={@search_mode}
|
||||||
search_mode_options={@search_mode_options}
|
search_mode_options={@search_mode_options}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Index do
|
|||||||
search_query={@search_query}
|
search_query={@search_query}
|
||||||
select_options={@select_options}
|
select_options={@select_options}
|
||||||
selected_option={@sort_by}
|
selected_option={@sort_by}
|
||||||
|
current_user={@current_user}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<.table
|
<.table
|
||||||
@@ -58,7 +59,10 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Index do
|
|||||||
<% else %>
|
<% else %>
|
||||||
<div class="flex flex-wrap flex-[3_1_auto]">
|
<div class="flex flex-wrap flex-[3_1_auto]">
|
||||||
<%= for author <- @page.results do %>
|
<%= for author <- @page.results do %>
|
||||||
<.author_card author={author} />
|
<.author_card
|
||||||
|
author={author}
|
||||||
|
current_user={@current_user}
|
||||||
|
/>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
defmodule DecentralisedBookIndexWeb.AuthorLive.Show do
|
defmodule DecentralisedBookIndexWeb.AuthorLive.Show do
|
||||||
use DecentralisedBookIndexWeb, :live_view
|
use DecentralisedBookIndexWeb, :live_view
|
||||||
|
|
||||||
|
alias DecentralisedBookIndex.Accounts.Role
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
@@ -8,11 +10,13 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Show do
|
|||||||
{@author.name}
|
{@author.name}
|
||||||
|
|
||||||
<:actions>
|
<:actions>
|
||||||
<.link navigate={~p"/authors/#{@author}/edit"}>
|
<%= if @current_user != nil and Role.can_moderate?(@current_user.role) do %>
|
||||||
<.edit_button>
|
<.link navigate={~p"/authors/#{@author}/edit"}>
|
||||||
Edit
|
<.edit_button>
|
||||||
</.edit_button>
|
Edit
|
||||||
</.link>
|
</.edit_button>
|
||||||
|
</.link>
|
||||||
|
<% end %>
|
||||||
</:actions>
|
</:actions>
|
||||||
</.header>
|
</.header>
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ defmodule DecentralisedBookIndexWeb.BookLive.Index do
|
|||||||
search_mode_options={@search_mode_options}
|
search_mode_options={@search_mode_options}
|
||||||
select_options={@select_options}
|
select_options={@select_options}
|
||||||
selected_option={@sort_by}
|
selected_option={@sort_by}
|
||||||
|
current_user={@current_user}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<.table
|
<.table
|
||||||
@@ -68,7 +69,10 @@ defmodule DecentralisedBookIndexWeb.BookLive.Index do
|
|||||||
<% else %>
|
<% else %>
|
||||||
<div class="flex flex-wrap flex-[3_1_auto]">
|
<div class="flex flex-wrap flex-[3_1_auto]">
|
||||||
<%= for book <- @page.results do %>
|
<%= for book <- @page.results do %>
|
||||||
<.book_card book={book} />
|
<.book_card
|
||||||
|
book={book}
|
||||||
|
current_user={@current_user}
|
||||||
|
/>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ defmodule DecentralisedBookIndexWeb.BookLive.Show do
|
|||||||
use DecentralisedBookIndexWeb, :live_view
|
use DecentralisedBookIndexWeb, :live_view
|
||||||
|
|
||||||
alias DecentralisedBookIndex.Metadata
|
alias DecentralisedBookIndex.Metadata
|
||||||
|
alias DecentralisedBookIndex.Accounts.Role
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
@@ -11,11 +12,13 @@ defmodule DecentralisedBookIndexWeb.BookLive.Show do
|
|||||||
<:subtitle>{@authors_string}</:subtitle>
|
<:subtitle>{@authors_string}</:subtitle>
|
||||||
|
|
||||||
<:actions>
|
<:actions>
|
||||||
<.link patch={~p"/books/#{@book}/edit"}>
|
<%= if @current_user != nil and Role.can_moderate?(@current_user.role) do %>
|
||||||
<.edit_button>
|
<.link patch={~p"/books/#{@book}/edit"}>
|
||||||
Edit
|
<.edit_button>
|
||||||
</.edit_button>
|
Edit
|
||||||
</.link>
|
</.edit_button>
|
||||||
|
</.link>
|
||||||
|
<% end %>
|
||||||
</:actions>
|
</:actions>
|
||||||
</.header>
|
</.header>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user