phoenixRealWorld/lib/phoenixRealWorld_web/live/article_live/index.html.heex
ReyoKatsu 03e1691fea
fin
2025-04-24 03:07:36 +09:00

62 lines
1.6 KiB
Text

<.header>
Listing Articles
<:actions :if={@current_user}>
<.link patch={~p"/articles/new"}>
<.button>New Article</.button>
</.link>
</:actions>
</.header>
<%!-- 追加 --%>
<div class="flex gap-2">
Search by tag:
<.link
:for={%{tag: tag} <- @tags}
href={~p"/articles?tag=#{tag}"}
class="underline"
>
<%= tag %>
</.link>
<.link href={~p"/articles"} class="text-yellow-700">Reset</.link>
</div>
<.table
id="articles"
rows={@streams.articles}
row_click={fn {_id, article} -> JS.navigate(~p"/articles/#{article}") end}
>
<:col :let={{_id, article}} label="Title">{article.title}</:col>
<:col :let={{_id, article}} label="Body">{article.body}</:col>
<%!-- ↓追加 --%>
<:col :let={{_id, article}} label="tags">
<PhoenixRealWorldWeb.ArticleComponents.tags article={article} />
</:col>
<:action :let={{_id, article}}>
<div class="sr-only">
<.link navigate={~p"/articles/#{article}"}>Show</.link>
</div>
<%!-- <.link patch={~p"/articles/#{article}/edit"}>Edit</.link> --%>
</:action>
<%!-- <:action :let={{id, article}}>
<.link
phx-click={JS.push("delete", value: %{id: article.id}) |> hide("##{id}")}
data-confirm="Are you sure?"
>
Delete
</.link>
</:action> --%>
</.table>
<.modal :if={@live_action in [:new, :edit]} id="article-modal" show on_cancel={JS.patch(~p"/articles")}>
<.live_component
module={PhoenixRealWorldWeb.ArticleLive.FormComponent}
id={@article.id || :new}
title={@page_title}
action={@live_action}
article={@article}
current_user={@current_user}
patch={~p"/articles"}
/>
</.modal>