diff --git a/lib/chiya_web/components/public_components.ex b/lib/chiya_web/components/public_components.ex index 9099ff4..df22bfa 100644 --- a/lib/chiya_web/components/public_components.ex +++ b/lib/chiya_web/components/public_components.ex @@ -164,6 +164,64 @@ defmodule ChiyaWeb.PublicComponents do end end + def comment_form(assigns) do + ~H""" + <.simple_form + :let={f} + for={@changeset} + action={~p"/note/#{assigns.note.slug}/comment"} + class="bg-theme-background -m-3" + > + <.error :if={@changeset.action}> + Oops, something went wrong! Please check the errors below. + + <.input + field={f[:author_name]} + type="text" + placeholder="Name" + class="bg-theme-background dark:bg-theme-background border-theme-base/20 dark:border-theme-base/20 text-theme-base dark:text-theme-base placeholder-theme-base/40 dark:placeholder-theme-base/60 dark:focus:border-theme-base/60 dark:focus:border-theme-base/60" + /> + <.input + field={f[:content]} + type="textarea" + placeholder="Content" + rows="3" + class="bg-theme-background dark:bg-theme-background border-theme-base/20 dark:border-theme-base/20 text-theme-base dark:text-theme-base placeholder-theme-base/60 dark:placeholder-theme-base/60 focus:border-theme-base/60 dark:focus:border-theme-base/60" + /> + <.input field={f[:note_id]} type="hidden" /> + <:actions> + <.button>Submit Comment + + + """ + end + + def comment_list(assigns) do + ~H""" + <%= if not Enum.empty?(assigns.note.comments) do %> + <.line /> + +

<%= Enum.count(assigns.note.comments) %> Comments

+ + + <% else %> + <.line /> + +

No comments yet.

+ <% end %> + """ + end + defp gallery_name(note), do: "gallery-#{note.id}" defp main_image(note), diff --git a/lib/chiya_web/controllers/comment_html/index.html.heex b/lib/chiya_web/controllers/comment_html/index.html.heex index f791e13..ea801ad 100644 --- a/lib/chiya_web/controllers/comment_html/index.html.heex +++ b/lib/chiya_web/controllers/comment_html/index.html.heex @@ -12,14 +12,14 @@ <.link navigate={~p"/admin/comments/#{comment}"}>Show - <:action :let={comment}> - <.link href={~p"/admin/comments/#{comment}"} method="delete" data-confirm="Are you sure?"> + <:action :let={_comment}> + <.link href="#" method="delete" data-confirm="Are you sure?"> Delete - <:action :let={comment}> + <:action :let={_comment}>
- <.link navigate={~p"/admin/comments/#{comment}/approve"}>Approve + <.link href="#">Approve
diff --git a/lib/chiya_web/controllers/comment_html/show.html.heex b/lib/chiya_web/controllers/comment_html/show.html.heex index 962d56e..ce158e1 100644 --- a/lib/chiya_web/controllers/comment_html/show.html.heex +++ b/lib/chiya_web/controllers/comment_html/show.html.heex @@ -2,7 +2,7 @@ Comment <%= @comment.id %> <:subtitle>This is a comment record from your database. <:actions> - <.link href={~p"/admin/notes/#{@comment}/approve"}> + <.link href="#"> <.button>Approve note @@ -15,7 +15,7 @@ <:item title="Approved at"><%= @comment.approved_at %> <:item title="Kind"><%= @comment.kind %> <:item title="Note"> - <%= @comment.note.name %> + <%= @comment.note.name %> diff --git a/lib/chiya_web/controllers/page_html/note.html.heex b/lib/chiya_web/controllers/page_html/note.html.heex index 473742d..37c09f4 100644 --- a/lib/chiya_web/controllers/page_html/note.html.heex +++ b/lib/chiya_web/controllers/page_html/note.html.heex @@ -56,58 +56,4 @@ <% end %> - -
- <%= if not Enum.empty?(@note.comments) do %> - <.line /> - -

<%= Enum.count(@note.comments) %> Comments

- - - <% else %> - <.line /> - -

No comments yet.

- <% end %> - - <.line /> - - <.simple_form - :let={f} - for={@changeset} - action={~p"/note/#{@note.slug}/comment"} - class="bg-theme-background -m-3" - > - <.error :if={@changeset.action}> - Oops, something went wrong! Please check the errors below. - - <.input - field={f[:author_name]} - type="text" - placeholder="Name" - class="bg-theme-background dark:bg-theme-background border-theme-base/20 dark:border-theme-base/20 text-theme-base dark:text-theme-base placeholder-theme-base/40 dark:placeholder-theme-base/60 dark:focus:border-theme-base/60 dark:focus:border-theme-base/60" - /> - <.input - field={f[:content]} - type="textarea" - placeholder="Content" - rows="3" - class="bg-theme-background dark:bg-theme-background border-theme-base/20 dark:border-theme-base/20 text-theme-base dark:text-theme-base placeholder-theme-base/60 dark:placeholder-theme-base/60 focus:border-theme-base/60 dark:focus:border-theme-base/60" - /> - <.input field={f[:note_id]} type="hidden" /> - <:actions> - <.button>Submit Comment - - -
diff --git a/lib/chiya_web/router.ex b/lib/chiya_web/router.ex index 5ba03f9..e0fde0e 100644 --- a/lib/chiya_web/router.ex +++ b/lib/chiya_web/router.ex @@ -138,6 +138,8 @@ defmodule ChiyaWeb.Router do get "/about", PageController, :about - post "/note/:slug/comment", CommentController, :create + # TODO: Comments are disabled for now + # and need a better submit/approve flow + # post "/note/:slug/comment", CommentController, :create end end