homeman-elixir/lib/homeman_web/live/todo_live/index.html.heex

44 lines
1.2 KiB
Plaintext
Raw Normal View History

2024-01-21 23:48:10 -06:00
<.header>
Listing Todos
<:actions>
<.link patch={~p"/todos/new"}>
<.button>New Todo</.button>
</.link>
</:actions>
</.header>
<.table
id="todos"
rows={@streams.todos}
row_click={fn {_id, todo} -> JS.navigate(~p"/todos/#{todo}") end}
>
<:col :let={{_id, todo}} label="Description"><%= todo.description %></:col>
<:col :let={{_id, todo}} label="Emoji"><%= todo.emoji %></:col>
<:col :let={{_id, todo}} label="Completed at"><%= todo.completed_at %></:col>
<:action :let={{_id, todo}}>
<div class="sr-only">
<.link navigate={~p"/todos/#{todo}"}>Show</.link>
</div>
<.link patch={~p"/todos/#{todo}/edit"}>Edit</.link>
</:action>
<:action :let={{id, todo}}>
<.link
phx-click={JS.push("delete", value: %{id: todo.id}) |> hide("##{id}")}
data-confirm="Are you sure?"
>
Delete
</.link>
</:action>
</.table>
<.modal :if={@live_action in [:new, :edit]} id="todo-modal" show on_cancel={JS.patch(~p"/todos")}>
<.live_component
module={HomemanWeb.TodoLive.FormComponent}
id={@todo.id || :new}
title={@page_title}
action={@live_action}
todo={@todo}
patch={~p"/todos"}
/>
</.modal>