Standalone "admin" page for each comment (#19644)
* Created separate comments page * Optimised code for single comment and multiple comments * Indifual comments poage added * Minor header change * Created show method * Applied review changes * Removed like button from admin comments page
This commit is contained in:
parent
1a92880cc8
commit
bc2d7702ee
7 changed files with 52 additions and 52 deletions
|
|
@ -19,6 +19,10 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@comment = Comment.includes(:user, :commentable).find(params[:id])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def authorize_admin
|
||||
|
|
|
|||
38
app/views/admin/comments/_comment.html.erb
Normal file
38
app/views/admin/comments/_comment.html.erb
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<div>
|
||||
<article class="crayons-card p-4 pt-3 pb-2 flex flex-col gap-3">
|
||||
<% if comment.commentable %>
|
||||
<header class="flex justify-between gap-4 items-center border-b-1 border-base-10 border-solid border-0 pb-3 -mx-2 px-2">
|
||||
<div class="flex gap-2 items-center">
|
||||
<% if comment.user %>
|
||||
<a href="<%= comment.user.path %>" target="_blank" rel="noopener" class="shrink-0 c-link">
|
||||
<img width="32" height="32" class="radius-full block" src="<%= comment.user.profile_image_url_for(length: 64) %>" alt="<%= comment.user.username %> profile" loading="lazy" />
|
||||
</a>
|
||||
<% end %>
|
||||
<p>
|
||||
<a href="<%= comment.user.path %>" target="_blank" rel="noopener" class="c-link c-link--branded fw-bold"><%= comment.user.username %></a>
|
||||
on:
|
||||
<a href="<%= comment.commentable.path %>" class="c-link c-link--branded"><%= comment.commentable.title %></a>
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
<% end %>
|
||||
<div class="text-styles text-styles--tertiary">
|
||||
<%= sanitize comment.processed_html,
|
||||
tags: %w[strong em p h1 h2 h3 h4 h5 h6 i u b code pre br ul ol li small sup img a span hr blockquote],
|
||||
attributes: %w[href strong em ref rel src title alt class] %>
|
||||
</div>
|
||||
<footer class="fs-s flex gap-4 border-t-1 border-base-10 border-solid border-0 pt-2 -mx-2 pl-2 justify-between items-center">
|
||||
<span>❤️ <%= pluralize(comment.public_reactions_count, "like") %></span>
|
||||
<div class="ml-auto">
|
||||
<a class="c-link c-link--block" href="<%= comment.path %>" target="_blank" rel="noopener">
|
||||
<%= t("views.moderations.comments.view_comment") %>
|
||||
</a>
|
||||
</div>
|
||||
<% if !defined?(is_individual_comment) || !is_individual_comment %>
|
||||
<a href="/admin/content_manager/comments/<%= comment.id %>" class="c-link c-link--block">
|
||||
<%= t("views.moderations.comments.view_details") %>
|
||||
</a>
|
||||
<% end %>
|
||||
</footer>
|
||||
</article>
|
||||
</div>
|
||||
|
|
@ -1,58 +1,8 @@
|
|||
<h1 class="crayons-title">Comments</h1>
|
||||
|
||||
<%= paginate @comments %>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<% @comments.each do |comment| %>
|
||||
<article class="crayons-card p-4 pt-3 pb-2 flex flex-col gap-3">
|
||||
<% if comment.commentable %>
|
||||
<header class="flex justify-between gap-4 items-center border-b-1 border-base-10 border-solid border-0 pb-3 -mx-2 px-2">
|
||||
<div class="flex gap-2 items-center">
|
||||
<% if comment.user %>
|
||||
<a href="<%= comment.user.path %>" target="_blank" rel="noopener" class="shrink-0 c-link">
|
||||
<img width="32" height="32" class="radius-full block" src="<%= comment.user.profile_image_url_for(length: 64) %>" alt="<%= comment.user.username %> profile" loading="lazy" />
|
||||
</a>
|
||||
<% end %>
|
||||
<p>
|
||||
<a href="<%= comment.user.path %>" target="_blank" rel="noopener" class="c-link c-link--branded fw-bold"><%= comment.user.username %></a>
|
||||
on:
|
||||
<a href="<%= comment.commentable.path %>" class="c-link c-link--branded"><%= comment.commentable.title %></a>
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
<% end %>
|
||||
<div class="text-styles text-styles--tertiary">
|
||||
<%= sanitize comment.processed_html,
|
||||
tags: %w[strong em p h1 h2 h3 h4 h5 h6 i u b code pre br ul ol li small sup img a span hr blockquote],
|
||||
attributes: %w[href strong em ref rel src title alt class] %>
|
||||
</div>
|
||||
<footer class="fs-s flex gap-4 border-t-1 border-base-10 border-solid border-0 pt-2 -mx-2 pl-2 justify-between items-center">
|
||||
<span>❤️ <%= pluralize(comment.public_reactions_count, "like") %></span>
|
||||
<% if comment.reactions.where(user_id: current_user.id).empty? %>
|
||||
<%= form_tag(reactions_path, remote: true) do %>
|
||||
<%= hidden_field_tag(:reactable_type, "Comment") %>
|
||||
<%= hidden_field_tag(:reactable_id, comment.id) %>
|
||||
<button class="c-btn c-btn--icon-left">
|
||||
<%= crayons_icon_tag(:heart, class: "c-btn__icon", width: 18, height: 18) %>
|
||||
Like
|
||||
</button>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="ml-auto">
|
||||
<a class="c-link c-link--block" href="<%= comment.path %>" target="_blank" rel="noopener">View</a>
|
||||
</div>
|
||||
</footer>
|
||||
</article>
|
||||
<% end %>
|
||||
<%= render partial: "comment", collection: @comments, locals: { is_individual_comment: false } %>
|
||||
</div>
|
||||
|
||||
<%= paginate @comments %>
|
||||
|
||||
<script>
|
||||
window.addEventListener('load', function() {
|
||||
document.querySelector("form").addEventListener("submit", function(e) {
|
||||
this.classList.toggle("hidden");
|
||||
this.classList.toggle("inline");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
2
app/views/admin/comments/show.html.erb
Normal file
2
app/views/admin/comments/show.html.erb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<h1 class="crayons-title">Comment</h1>
|
||||
<%= render partial: "comment", locals: { comment: @comment, is_individual_comment: true } %>
|
||||
|
|
@ -162,6 +162,9 @@ en:
|
|||
terms_and_conditions: Terms & Conditions
|
||||
trusted: Trusted User Guide
|
||||
author: Author
|
||||
comments:
|
||||
view_comment: View Comment
|
||||
view_details: View Details
|
||||
date: Date
|
||||
notice:
|
||||
subtitle: '%{community} Mods'
|
||||
|
|
|
|||
|
|
@ -161,6 +161,9 @@ fr:
|
|||
terms_and_conditions: Conditions générales d'utilisation
|
||||
trusted: Guide de l'utilisateur de confiance
|
||||
author: Auteur
|
||||
comments:
|
||||
view_comment: Voir le commentaire
|
||||
view_details: Voir les détails
|
||||
date: Date
|
||||
notice:
|
||||
subtitle: '%{community} Mods'
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ namespace :admin do
|
|||
resources :badge_achievements, only: %i[index destroy]
|
||||
get "/badge_achievements/award_badges", to: "badge_achievements#award"
|
||||
post "/badge_achievements/award_badges", to: "badge_achievements#award_badges"
|
||||
resources :comments, only: [:index]
|
||||
resources :comments, only: %i[index show]
|
||||
resources :organizations, only: %i[index show] do
|
||||
member do
|
||||
patch "update_org_credits"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue