Added highlighting and notices for moderators

- Posts and topics have an added moderation_reports function
-- This is so all moderation reports can be loaded in a single query
- Those moderation reports are passed into the render functions separately
-- This is so the individual comments/posts don't have to be queried
This commit is contained in:
BrokenEagle
2020-01-18 21:10:50 +00:00
parent 4cef0e45c2
commit a3e889bdf5
13 changed files with 76 additions and 7 deletions

View File

@@ -8,7 +8,7 @@
<%= link_to(image_tag(comment.post.preview_file_url), post_path(comment.post)) %>
<% end %>
</div>
<%= render partial: "comments/partials/show/comment", collection: [comment], locals: { context: :index_by_comment, dtext_data: DText.preprocess(@comments.map(&:body)) } %>
<%= render partial: "comments/partials/show/comment", collection: [comment], locals: { context: :index_by_comment, dtext_data: DText.preprocess(@comments.map(&:body)), moderation_reports: [] } %>
<% end %>
<% end %>
<% end %>

View File

@@ -1,5 +1,5 @@
$("#threshold-comments-notice-for-<%= @post.id %>").hide();
var current_comment_section = $("div.comments-for-post[data-post-id=<%= @post.id %>] div.list-of-comments");
current_comment_section.html("<%= j(render(partial: 'comments/partials/show/comment', collection: @comments, locals: { context: :index_for_post, dtext_data: DText.preprocess(@comments.map(&:body)) })) %>");
current_comment_section.html("<%= j(render(partial: 'comments/partials/show/comment', collection: @comments, locals: { context: :index_for_post, dtext_data: DText.preprocess(@comments.map(&:body)), moderation_reports: (CurrentUser.is_moderator? ? @post.moderation_reports : []) })) %>");
$(window).trigger("danbooru:index_for_post", [<%= @post.id %>]);

View File

@@ -3,6 +3,13 @@
<%= render "comments/partials/index/header", :post => post %>
<% end %>
<% if CurrentUser.is_moderator? && post.moderation_reports.any? %>
<div class="row moderation-comments-notice">
<span class="info" id="moderation-comments-notice-for-<%= post.id %>">
This post has comments reported for moderation! (<%= post.moderation_reports.count %> <%= (post.moderation_reports.count == 1 ? "report" : "reports") %>)
</span>
</div>
<% end %>
<% if post.comments.hidden(CurrentUser.user).any? || (page == :comments && post.comments.size > 6) %>
<div class="row hidden-comments-notice">
<span class="info" id="threshold-comments-notice-for-<%= post.id %>">
@@ -13,7 +20,7 @@
<div class="list-of-comments list-of-messages">
<% if comments.present? %>
<%= render partial: "comments/partials/show/comment", collection: comments, locals: { context: :index_by_post, dtext_data: DText.preprocess(comments.map(&:body)) } %>
<%= render partial: "comments/partials/show/comment", collection: comments, locals: { context: :index_by_post, dtext_data: DText.preprocess(comments.map(&:body)), moderation_reports: (CurrentUser.is_moderator? ? post.moderation_reports : []) } %>
<% elsif post.last_commented_at.present? %>
<p>There are no visible comments.</p>
<% else %>

View File

@@ -1,4 +1,4 @@
<%# locals: comment, context, dtext_data %>
<%# locals: comment, context, dtext_data, moderation_reports %>
<% if CurrentUser.is_moderator? || (params[:search] && params[:search][:is_deleted] =~ /t/) || !comment.is_deleted? %>
<a name="comment-<%= comment.id %>"></a>
@@ -12,6 +12,9 @@
data-is-deleted="<%= comment.is_deleted? %>"
data-is-sticky="<%= comment.is_sticky? %>"
data-below-threshold="<%= comment.score < CurrentUser.user.comment_threshold %>"
<% if CurrentUser.is_moderator? %>
data-is-reported="<%= moderation_reports.pluck(:model_id).include?(comment.id) %>"
<% end %>
data-is-voted="<%= comment.voted_by?(CurrentUser.user) %>">
<div class="author">
<h4>