mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 22:27:59 +01:00
comment destroying (css wip)
This commit is contained in:
parent
3fe828ae9a
commit
5101bd31f2
9 changed files with 60 additions and 8 deletions
|
@ -30,6 +30,8 @@ $vote_up_color: #67af2b !default;
|
||||||
$vote_down_color: #cf0001 !default;
|
$vote_down_color: #cf0001 !default;
|
||||||
$hide_color: #cf0001 !default;
|
$hide_color: #cf0001 !default;
|
||||||
|
|
||||||
|
$destroyed_comment_color: #f3baba !default;
|
||||||
|
|
||||||
$assistant_color: #eeceed !default;
|
$assistant_color: #eeceed !default;
|
||||||
|
|
||||||
$tag_normal_color: #6f8f0e !default;
|
$tag_normal_color: #6f8f0e !default;
|
||||||
|
|
|
@ -17,6 +17,8 @@ $success_light_color: #144714 !default;
|
||||||
$danger_light_color: #66211f !default;
|
$danger_light_color: #66211f !default;
|
||||||
$warning_light_color: #7d4825 !default;
|
$warning_light_color: #7d4825 !default;
|
||||||
|
|
||||||
|
$destroyed_comment_color: #382c2f !default;
|
||||||
|
|
||||||
$meta_color: #191f2a !default;
|
$meta_color: #191f2a !default;
|
||||||
|
|
||||||
$header_color: #284371 !default;
|
$header_color: #284371 !default;
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
color: $vote_down_color;
|
color: $vote_down_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.comment--destroyed {
|
||||||
|
background-color: $destroyed_comment_color;
|
||||||
|
}
|
||||||
|
|
||||||
.comment_under_review {
|
.comment_under_review {
|
||||||
color: blue;
|
color: blue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,6 +146,12 @@ defmodule Philomena.Comments do
|
||||||
|> Repo.update()
|
|> Repo.update()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy_comment(%Comment{} = comment) do
|
||||||
|
comment
|
||||||
|
|> Comment.destroy_changeset()
|
||||||
|
|> Repo.update()
|
||||||
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Returns an `%Ecto.Changeset{}` for tracking comment changes.
|
Returns an `%Ecto.Changeset{}` for tracking comment changes.
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,12 @@ defmodule Philomena.Comments.Comment do
|
||||||
|> put_change(:deletion_reason, "")
|
|> put_change(:deletion_reason, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy_changeset(comment) do
|
||||||
|
change(comment)
|
||||||
|
|> put_change(:destroyed_content, true)
|
||||||
|
|> put_change(:body, "")
|
||||||
|
end
|
||||||
|
|
||||||
defp put_name_at_post_time(changeset, nil), do: changeset
|
defp put_name_at_post_time(changeset, nil), do: changeset
|
||||||
defp put_name_at_post_time(changeset, user), do: change(changeset, name_at_post_time: user.name)
|
defp put_name_at_post_time(changeset, user), do: change(changeset, name_at_post_time: user.name)
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,5 +8,19 @@ defmodule PhilomenaWeb.Image.Comment.DeleteController do
|
||||||
plug :load_and_authorize_resource, model: Comment, id_name: "comment_id", persisted: true
|
plug :load_and_authorize_resource, model: Comment, id_name: "comment_id", persisted: true
|
||||||
|
|
||||||
def delete(conn, _params) do
|
def delete(conn, _params) do
|
||||||
|
comment = conn.assigns.comment
|
||||||
|
|
||||||
|
case Comments.destroy_comment(comment) do
|
||||||
|
{:ok, comment} ->
|
||||||
|
Comments.reindex_comment(comment)
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> put_flash(:info, "Comment successfully destroyed!")
|
||||||
|
|> redirect(to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}")
|
||||||
|
{:error, _changeset} ->
|
||||||
|
conn
|
||||||
|
|> put_flash(:error, "Unable to destroy comment!")
|
||||||
|
|> redirect(to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
article.block.communication id="comment_#{@comment.id}"
|
article.block.communication id="comment_#{@comment.id}"
|
||||||
.block__content.flex.flex--no-wrap
|
.block__content.flex.flex--no-wrap class=comment_body_class(@comment)
|
||||||
.flex__fixed.spacing-right
|
.flex__fixed.spacing-right
|
||||||
= render PhilomenaWeb.UserAttributionView, "_anon_user_avatar.html", object: @comment, conn: @conn
|
= render PhilomenaWeb.UserAttributionView, "_anon_user_avatar.html", object: @comment, conn: @conn
|
||||||
.flex__grow.communication__body
|
.flex__grow.communication__body
|
||||||
|
@ -16,8 +16,13 @@ article.block.communication id="comment_#{@comment.id}"
|
||||||
= @comment.deleted_by.name
|
= @comment.deleted_by.name
|
||||||
| )
|
| )
|
||||||
= if can?(@conn, :delete, @comment) do
|
= if can?(@conn, :delete, @comment) do
|
||||||
br
|
= if @comment.destroyed_content do
|
||||||
==<> @body
|
br
|
||||||
|
strong.comment_deleted>
|
||||||
|
| This comment's contents have been destroyed.
|
||||||
|
- else
|
||||||
|
br
|
||||||
|
==<> @body
|
||||||
- else
|
- else
|
||||||
==<> @body
|
==<> @body
|
||||||
.block__content.communication__options
|
.block__content.communication__options
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
article.block.communication id="comment_#{@comment.id}"
|
article.block.communication id="comment_#{@comment.id}"
|
||||||
.block__content.flex.flex--no-wrap
|
.block__content.flex.flex--no-wrap class=comment_body_class(@comment)
|
||||||
.flex__fixed.spacing-right
|
.flex__fixed.spacing-right
|
||||||
.post-image-container
|
.post-image-container
|
||||||
= render PhilomenaWeb.ImageView, "_image_container.html", image: @comment.image, size: :thumb_tiny, conn: @conn
|
= render PhilomenaWeb.ImageView, "_image_container.html", image: @comment.image, size: :thumb_tiny, conn: @conn
|
||||||
|
@ -14,10 +14,20 @@ article.block.communication id="comment_#{@comment.id}"
|
||||||
= if @comment.hidden_from_users do
|
= if @comment.hidden_from_users do
|
||||||
strong.comment_deleted
|
strong.comment_deleted
|
||||||
' Deletion reason:
|
' Deletion reason:
|
||||||
=> @comment.deletion_reason
|
=<> @comment.deletion_reason
|
||||||
- else
|
= if can?(@conn, :delete, @comment) do
|
||||||
==<> @body
|
| (
|
||||||
|
= @comment.deleted_by.name
|
||||||
|
| )
|
||||||
|
= if can?(@conn, :delete, @comment) do
|
||||||
|
= if @comment.destroyed_content do
|
||||||
|
br
|
||||||
|
strong.comment_deleted>
|
||||||
|
| This comment's contents have been destroyed.
|
||||||
|
- else
|
||||||
|
br
|
||||||
|
==<> @body
|
||||||
|
|
||||||
.block__content.communication__options
|
.block__content.communication__options
|
||||||
.flex.flex--wrap.flex--spaced-out
|
.flex.flex--wrap.flex--spaced-out
|
||||||
= render PhilomenaWeb.CommentView, "_comment_options.html", comment: @comment, conn: @conn
|
= render PhilomenaWeb.CommentView, "_comment_options.html", comment: @comment, conn: @conn
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
defmodule PhilomenaWeb.CommentView do
|
defmodule PhilomenaWeb.CommentView do
|
||||||
use PhilomenaWeb, :view
|
use PhilomenaWeb, :view
|
||||||
|
|
||||||
|
defp comment_body_class(%{destroyed_content: true}), do: "comment--destroyed"
|
||||||
|
defp comment_body_class(_comment), do: nil
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue