2022-11-17 22:38:52 -05:00
|
|
|
<div class="mx-auto flex flex-col justify-center items-start space-y-4 max-w-3xl">
|
|
|
|
<h1 class="text-xl">
|
|
|
|
<%= gettext("notes") %>
|
|
|
|
</h1>
|
|
|
|
|
2022-11-19 00:21:14 -05:00
|
|
|
<.form
|
|
|
|
:let={f}
|
2023-03-16 19:49:19 -04:00
|
|
|
for={%{}}
|
|
|
|
as={:search}
|
2022-11-19 00:21:14 -05:00
|
|
|
phx-change="search"
|
|
|
|
phx-submit="search"
|
|
|
|
class="self-stretch flex flex-col items-stretch"
|
|
|
|
>
|
2022-11-24 12:43:34 -05:00
|
|
|
<%= text_input(f, :search_term,
|
|
|
|
class: "input input-primary",
|
|
|
|
value: @search,
|
2023-03-19 15:28:53 -04:00
|
|
|
role: "search",
|
2022-11-24 12:43:34 -05:00
|
|
|
phx_debounce: 300,
|
|
|
|
placeholder: gettext("search")
|
|
|
|
) %>
|
2022-11-19 00:21:14 -05:00
|
|
|
</.form>
|
|
|
|
|
2022-11-17 22:38:52 -05:00
|
|
|
<%= if @notes |> Enum.empty?() do %>
|
|
|
|
<h1 class="self-center text-primary-500">
|
|
|
|
<%= gettext("no notes found") %>
|
|
|
|
</h1>
|
|
|
|
<% else %>
|
|
|
|
<.live_component
|
|
|
|
module={MemexWeb.Components.NotesTableComponent}
|
|
|
|
id="notes-index-table"
|
|
|
|
current_user={@current_user}
|
|
|
|
notes={@notes}
|
|
|
|
>
|
|
|
|
<:actions :let={note}>
|
2023-02-04 11:29:06 -05:00
|
|
|
<.link
|
2023-03-18 23:09:36 -04:00
|
|
|
:if={Notes.is_owner?(note, @current_user)}
|
2023-02-04 11:29:06 -05:00
|
|
|
patch={Routes.note_index_path(@socket, :edit, note.slug)}
|
2023-03-18 00:26:32 -04:00
|
|
|
aria-label={dgettext("actions", "edit %{note_slug}", note_slug: note.slug)}
|
2023-02-04 11:29:06 -05:00
|
|
|
>
|
|
|
|
<%= dgettext("actions", "edit") %>
|
|
|
|
</.link>
|
|
|
|
<.link
|
2023-03-18 23:09:36 -04:00
|
|
|
:if={Notes.is_owner_or_admin?(note, @current_user)}
|
2023-02-04 11:29:06 -05:00
|
|
|
href="#"
|
|
|
|
phx-click="delete"
|
|
|
|
phx-value-id={note.id}
|
|
|
|
data-confirm={dgettext("prompts", "are you sure?")}
|
2023-03-18 00:26:32 -04:00
|
|
|
aria-label={dgettext("actions", "delete %{note_slug}", note_slug: note.slug)}
|
2023-02-04 11:29:06 -05:00
|
|
|
>
|
|
|
|
<%= dgettext("actions", "delete") %>
|
|
|
|
</.link>
|
2022-11-17 22:38:52 -05:00
|
|
|
</:actions>
|
|
|
|
</.live_component>
|
|
|
|
<% end %>
|
|
|
|
|
2023-02-04 11:29:06 -05:00
|
|
|
<.link
|
|
|
|
:if={@current_user}
|
|
|
|
patch={Routes.note_index_path(@socket, :new)}
|
|
|
|
class="self-end btn btn-primary"
|
|
|
|
>
|
|
|
|
<%= dgettext("actions", "new note") %>
|
|
|
|
</.link>
|
2022-11-17 22:38:52 -05:00
|
|
|
</div>
|
2022-07-25 20:08:40 -04:00
|
|
|
|
2023-02-04 11:29:06 -05:00
|
|
|
<.modal :if={@live_action in [:new, :edit]} return_to={Routes.note_index_path(@socket, :index)}>
|
|
|
|
<.live_component
|
|
|
|
module={MemexWeb.NoteLive.FormComponent}
|
|
|
|
id={@note.id || :new}
|
|
|
|
current_user={@current_user}
|
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
|
|
|
note={@note}
|
|
|
|
return_to={Routes.note_index_path(@socket, :index)}
|
|
|
|
/>
|
|
|
|
</.modal>
|