48 lines
1.6 KiB
Text
48 lines
1.6 KiB
Text
<.header>
|
|
<:subtitle>This is a article record from your database.</:subtitle>
|
|
<!--変更 ログインしているかどうか&ログインユーザーと記事の作者が同じかどうか-->
|
|
<:actions :if={@current_user && @current_user.id == @article.author_id}>
|
|
<.link patch={~p"/articles/#{@article}/edit"} phx-click={JS.push_focus()}>
|
|
<button>Edit article</button>
|
|
</.link>
|
|
<.link phx-click={JS.push("delete")} data-confirm="Are you sure?">
|
|
<button>Delete article</button>
|
|
</.link>
|
|
</:actions>
|
|
</.header>
|
|
|
|
<.list>
|
|
<:item title="Title">{@article.title}</:item>
|
|
<:item title="Body">{@article.body}</:item>
|
|
<:item title="Comments">
|
|
<.table id="comments" rows={@article.comments}>
|
|
<:col :let={comment} label="Author"><%= comment.author.email %></:col>
|
|
<:col :let={comment} label="Body"><%= comment.body %></:col>
|
|
</.table>
|
|
<.simple_form
|
|
:if={@current_user}
|
|
for={@comment_form}
|
|
id="comment-form"
|
|
phx-change="validate_comment"
|
|
phx-submit="post_comment"
|
|
>
|
|
<.input field={@comment_form[:body]} type="textarea" />
|
|
<:actions>
|
|
<.button phx-disable_with="Posting...">Post comment</.button>
|
|
</:actions>
|
|
</.simple_form>
|
|
</:item>
|
|
</.list>
|
|
|
|
<.back navigate={~p"/articles"}>Back to articles</.back>
|
|
|
|
<.modal :if={@live_action == :edit} id="article-modal" show on_cancel={JS.patch(~p"/articles/#{@article}")}>
|
|
<.live_component
|
|
module={PhoenixRealWorldWeb.ArticleLive.FormComponent}
|
|
id={@article.id}
|
|
title={@page_title}
|
|
action={@live_action}
|
|
article={@article}
|
|
patch={~p"/articles/#{@article}"}
|
|
/>
|
|
</.modal>
|