zoeys.computer/lib/zoeyscomputer_web/live/gist_live/index.html.heex

45 lines
1.1 KiB
Text
Raw Normal View History

2024-10-26 15:01:33 -04:00
<.header>
Listing Gists
<:actions>
<.link patch={~p"/gists/new"}>
<.button>New Gist</.button>
</.link>
</:actions>
</.header>
<.table
id="gists"
rows={@streams.gists}
row_click={fn {_id, gist} -> JS.navigate(~p"/gists/#{gist}") end}
>
2024-10-26 21:41:22 -04:00
<:col :let={{_id, gist}} label="Code">
<p class="truncate max-w-72"><%= gist.title || gist.code %></p>
</:col>
2024-10-26 15:01:33 -04:00
<:col :let={{_id, gist}} label="Lang"><%= gist.lang %></:col>
<:action :let={{_id, gist}}>
<div class="sr-only">
<.link navigate={~p"/gists/#{gist}"}>Show</.link>
</div>
<.link patch={~p"/gists/#{gist}/edit"}>Edit</.link>
</:action>
<:action :let={{id, gist}}>
<.link
phx-click={JS.push("delete", value: %{id: gist.id}) |> hide("##{id}")}
data-confirm="Are you sure?"
>
Delete
</.link>
</:action>
</.table>
<.modal :if={@live_action in [:new, :edit]} id="gist-modal" show on_cancel={JS.patch(~p"/gists")}>
<.live_component
module={ZoeyscomputerWeb.GistLive.FormComponent}
id={@gist.id || :new}
title={@page_title}
action={@live_action}
gist={@gist}
patch={~p"/gists"}
/>
</.modal>