comments: let mods click score to see votes.

This commit is contained in:
evazion
2021-01-22 04:26:55 -06:00
parent bed5fdafb8
commit 2eecf4d695
5 changed files with 50 additions and 10 deletions

View File

@@ -53,7 +53,13 @@
<%= link_to upvote_icon, comment_comment_votes_path(comment_id: comment.id, score: "1"), class: "comment-upvote-link inactive-link", method: :post, remote: true %>
<% end %>
<span class="comment-score"><%= comment.score %></span>
<% if policy(CommentVote).can_see_votes? %>
<%= link_to comment_votes_path(search: { comment_id: comment.id }, variant: "compact"), class: "inactive-link" do %>
<span class="comment-score"><%= comment.score %></span>
<% end %>
<% else %>
<span class="comment-score"><%= comment.score %></span>
<% end %>
<% if current_user.is_anonymous? %>
<%= link_to downvote_icon, login_path(url: request.fullpath), class: "comment-downvote-link inactive-link" %>

View File

@@ -0,0 +1,11 @@
<%= search_form_for(comment_votes_path) do |f| %>
<%= f.input :user_name, label: "Voter", input_html: { value: params[:search][:user_name], "data-autocomplete": "user" } %>
<%= f.simple_fields_for :comment do |fc| %>
<%= fc.input :creator_name, label: "Commenter", input_html: { value: params.dig(:search, :comment, :creator_name), "data-autocomplete": "user" } %>
<%= fc.input :post_tags_match, label: "Tags", input_html: { value: params.dig(:search, :comment, :post_tags_match), "data-autocomplete": "tag-query" } %>
<%= fc.input :post_id, label: "Post", input_html: { value: params.dig(:search, :comment, :post_id) } %>
<% end %>
<%= f.input :comment_id, label: "Comment", input_html: { value: params[:search][:comment_id] } %>
<%= f.input :score, collection: [["+1", "1"], ["-1", "-1"]], include_blank: true, selected: params[:search][:score] %>
<%= f.submit "Search" %>
<% end %>

View File

@@ -0,0 +1,24 @@
<%= render "comments/secondary_links" %>
<div id="c-comment-votes">
<div id="a-index">
<%= render "search" %>
<%= table_for @comment_votes, class: "striped autofit" do |t| %>
<% t.column "Score" do |vote| %>
<%= link_to sprintf("%+d", vote.score), comment_votes_path(search: { score: vote.score }) %>
<% end %>
<% t.column "Voter" do |vote| %>
<%= link_to_user vote.user %>
<%= link_to "»", comment_votes_path(search: { user_name: vote.user.name }) %>
<% end %>
<% t.column "Created" do |vote| %>
<%= time_ago_in_words_tagged(vote.created_at) %>
<% end %>
<% end %>
<%= numbered_paginator(@comment_votes) %>
</div>
</div>

View File

@@ -2,15 +2,7 @@
<div id="c-comment-votes">
<div id="a-index">
<%= search_form_for(comment_votes_path) do |f| %>
<%= f.input :user_name, label: "Voter", input_html: { value: params[:search][:user_name], "data-autocomplete": "user" } %>
<%= f.simple_fields_for :comment do |fc| %>
<%= fc.input :creator_name, label: "Commenter", input_html: { value: params.dig(:search, :comment, :creator_name), "data-autocomplete": "user" } %>
<%= fc.input :post_tags_match, label: "Tags", input_html: { value: params.dig(:search, :comment, :post_tags_match), "data-autocomplete": "tag-query" } %>
<% end %>
<%= f.input :score, collection: [["+1", "1"], ["-1", "-1"]], include_blank: true, selected: params[:search][:score] %>
<%= f.submit "Search" %>
<% end %>
<%= render "search" %>
<%= table_for @comment_votes, class: "striped autofit" do |t| %>
<% t.column "Post" do |vote| %>

View File

@@ -44,6 +44,13 @@ class CommentVotesControllerTest < ActionDispatch::IntegrationTest
should respond_to_search(user: {level: User::Levels::GOLD}).with { @vote }
end
end
context "compact variant" do
should "render" do
get_auth comment_votes_path(variant: "compact"), create(:moderator_user)
assert_response :success
end
end
end
context "create action" do