memEx/lib/memex_web/live/note_live/index.html.heex
2022-11-03 18:23:17 -04:00

55 lines
1.4 KiB
Plaintext

<h1>Listing Notes</h1>
<%= 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}
title={@page_title}
action={@live_action}
note={@note}
return_to={Routes.note_index_path(@socket, :index)}
/>
</.modal>
<% end %>
<table>
<thead>
<tr>
<th>Title</th>
<th>Content</th>
<th>Tag</th>
<th>Visibility</th>
<th></th>
</tr>
</thead>
<tbody id="notes">
<%= for note <- @notes do %>
<tr id={"note-#{note.id}"}>
<td><%= note.title %></td>
<td><%= note.content %></td>
<td><%= note.tag %></td>
<td><%= note.visibility %></td>
<td>
<span>
<%= live_redirect("Show", to: Routes.note_show_path(@socket, :show, note)) %>
</span>
<span><%= live_patch("Edit", to: Routes.note_index_path(@socket, :edit, note)) %></span>
<span>
<%= link("Delete",
to: "#",
phx_click: "delete",
phx_value_id: note.id,
data: [confirm: "Are you sure?"]
) %>
</span>
</td>
</tr>
<% end %>
</tbody>
</table>
<span><%= live_patch("New Note", to: Routes.note_index_path(@socket, :new)) %></span>