comments: let mods click score to see votes.
This commit is contained in:
@@ -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" %>
|
||||
|
||||
11
app/views/comment_votes/_search.html.erb
Normal file
11
app/views/comment_votes/_search.html.erb
Normal 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 %>
|
||||
24
app/views/comment_votes/index.html+compact.erb
Normal file
24
app/views/comment_votes/index.html+compact.erb
Normal 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>
|
||||
@@ -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| %>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user