memEx/lib/memex_web/live/note_live/index.html.heex

70 lines
1.9 KiB
Plaintext
Raw Normal View History

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-18 23:45:15 -05:00
<.form
:let={f}
for={:search}
phx-change="search"
phx-submit="search"
phx-debounce="500"
class="self-stretch flex flex-col items-stretch"
>
<%= text_input(f, :search_term, class: "input input-primary") %>
</.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}>
<%= if @current_user do %>
<.link
patch={Routes.note_index_path(@socket, :edit, note)}
data-qa={"note-edit-#{note.id}"}
>
<%= dgettext("actions", "edit") %>
</.link>
<.link
href="#"
phx-click="delete"
phx-value-id={note.id}
data-confirm={dgettext("prompts", "are you sure?")}
data-qa={"delete-note-#{note.id}"}
>
<%= dgettext("actions", "delete") %>
</.link>
<% end %>
</:actions>
</.live_component>
<% end %>
<%= if @current_user do %>
<.link patch={Routes.note_index_path(@socket, :new)} class="self-end btn btn-primary">
<%= dgettext("actions", "new note") %>
</.link>
<% end %>
</div>
2022-07-25 20:08:40 -04:00
<%= if @live_action in [:new, :edit] do %>
<.modal return_to={Routes.note_index_path(@socket, :index)}>
<.live_component
module={MemexWeb.NoteLive.FormComponent}
id={@note.id || :new}
2022-11-17 22:38:52 -05:00
current_user={@current_user}
2022-07-25 20:08:40 -04:00
title={@page_title}
action={@live_action}
note={@note}
return_to={Routes.note_index_path(@socket, :index)}
/>
</.modal>
<% end %>