memEx/lib/memex_web/live/note_live/show.html.heex
2023-02-04 13:02:09 -05:00

57 lines
1.5 KiB
Plaintext

<div class="mx-auto flex flex-col justify-center items-stretch space-y-4 max-w-3xl">
<h1 class="text-xl">
<%= @note.slug %>
</h1>
<div class="flex flex-wrap space-x-1">
<.link
:for={tag <- @note.tags}
navigate={Routes.note_index_path(Endpoint, :search, tag)}
class="link"
>
<%= tag %>
</.link>
</div>
<.note_content note={@note} />
<p class="self-end">
<%= gettext("Visibility: %{visibility}", visibility: @note.visibility) %>
</p>
<div class="self-end flex space-x-4">
<.link class="btn btn-primary" navigate={Routes.note_index_path(@socket, :index)}>
<%= dgettext("actions", "back") %>
</.link>
<.link
:if={is_owner?(@note, @current_user)}
class="btn btn-primary"
patch={Routes.note_show_path(@socket, :edit, @note.slug)}
>
<%= dgettext("actions", "edit") %>
</.link>
<button
:if={is_owner_or_admin?(@note, @current_user)}
type="button"
class="btn btn-primary"
phx-click="delete"
data-confirm={dgettext("prompts", "are you sure?")}
data-qa={"delete-note-#{@note.id}"}
>
<%= dgettext("actions", "delete") %>
</button>
</div>
</div>
<.modal :if={@live_action == :edit} return_to={Routes.note_show_path(@socket, :show, @note.slug)}>
<.live_component
module={MemexWeb.NoteLive.FormComponent}
id={@note.id}
current_user={@current_user}
title={@page_title}
action={@live_action}
note={@note}
return_to={Routes.note_show_path(@socket, :show, @note.slug)}
/>
</.modal>