homeman-elixir/lib/homeman_web/live/task_live/index.html.heex
2024-01-21 23:48:10 -06:00

45 lines
1.2 KiB
Plaintext

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