post/comment/forum votes: add vote counts to profile pages.
* Add post/comment/forum vote counts to user profiles. * Show uploaders on post votes index and allow searching by uploader. * Show forum posters on forum votes index and allow searching by poster. * Add unvote link to forum votes index. * Only show unvote links to current user.
This commit is contained in:
@@ -44,7 +44,9 @@
|
||||
<div><%= time_ago_in_words_tagged(vote.created_at) %></div>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to "unvote", comment_comment_votes_path(vote.comment), remote: true, method: :delete %>
|
||||
<% if vote.user == CurrentUser.user %>
|
||||
<%= link_to "unvote", comment_comment_votes_path(vote.comment), remote: true, method: :delete %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<div id="c-forum-post-votes">
|
||||
<div id="a-index">
|
||||
<%= search_form_for(forum_post_votes_path) do |f| %>
|
||||
<%= f.input :creator_name, label: "User", input_html: { value: params[:search][:creator_name], data: { autocomplete: "user" } } %>
|
||||
<%= f.input :creator_name, label: "Voter", input_html: { value: params[:search][:creator_name], data: { autocomplete: "user" } } %>
|
||||
<%= f.simple_fields_for :forum_post do |fa| %>
|
||||
<%= fa.input :creator_name, label: "Forum Poster", input_html: { value: params.dig(:search, :forum_post, :creator_name), data: { autocomplete: "user" } } %>
|
||||
<% end %>
|
||||
<%= f.input :forum_post_id, label: "Forum Post", input_html: { value: params[:search][:forum_post_id] } %>
|
||||
<%= f.input :score, label: "Type", collection: [["Up", "1"], ["Meh", "0"], ["Down", "-1"]], include_blank: true, selected: params[:search][:score] %>
|
||||
<%= f.input :score, label: "Score", collection: [["+1", "1"], ["0", "0"], ["-1", "-1"]], include_blank: true, selected: params[:search][:score] %>
|
||||
<%= f.submit "Search" %>
|
||||
<% end %>
|
||||
|
||||
@@ -12,8 +15,10 @@
|
||||
<tr>
|
||||
<th>Forum Post</th>
|
||||
<th>Forum Topic</th>
|
||||
<th>Type</th>
|
||||
<th>Created</th>
|
||||
<th>Score</th>
|
||||
<th>Forum Poster</th>
|
||||
<th>Voter</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -27,12 +32,22 @@
|
||||
<%= link_to forum_post_vote.forum_post.topic.title, forum_post_vote.forum_post.topic %>
|
||||
</td>
|
||||
<td>
|
||||
<%= forum_post_vote.vote_type %>
|
||||
<%= link_to sprintf("%+d", forum_post_vote.score), forum_post_votes_path(search: { score: forum_post_vote.score }) %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to_user forum_post_vote.forum_post.creator %>
|
||||
<%= link_to "»", forum_post_votes_path(search: { forum_post: { creator_name: forum_post_vote.forum_post.creator.name }}) %>
|
||||
<div><%= time_ago_in_words_tagged(forum_post_vote.forum_post.created_at) %></div>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to_user forum_post_vote.creator %>
|
||||
<%= link_to "»", forum_post_votes_path(search: { creator_name: forum_post_vote.creator.name }) %>
|
||||
<p><%= time_ago_in_words_tagged(forum_post_vote.updated_at) %></p>
|
||||
<div><%= time_ago_in_words_tagged(forum_post_vote.created_at) %></div>
|
||||
</td>
|
||||
<td>
|
||||
<% if forum_post_vote.creator == CurrentUser.user %>
|
||||
<%= link_to "unvote", forum_post_vote_path(forum_post_vote, format: "js"), remote: true, method: :delete %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div id="c-post-votes">
|
||||
<div id="a-index">
|
||||
<%= search_form_for(post_votes_path) do |f| %>
|
||||
<%= f.input :user_name, label: "User", input_html: { value: params[:search][:user_name], "data-autocomplete": "user" } %>
|
||||
<%= f.input :user_name, label: "Voter", input_html: { value: params[:search][:user_name], "data-autocomplete": "user" } %>
|
||||
<%= f.input :post_id, label: "Post", input_html: { value: params[:search][:post_id] } %>
|
||||
<%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match], "data-autocomplete": "tag-query" } %>
|
||||
<%= f.input :score, collection: [["+3", "3"], ["+1", "1"], ["-1", "-1"], ["-3", "-3"]], include_blank: true, selected: params[:search][:score] %>
|
||||
@@ -14,7 +14,8 @@
|
||||
<th>Post</th>
|
||||
<th>Tags</th>
|
||||
<th>Score</th>
|
||||
<th>Created</th>
|
||||
<th>Uploader</th>
|
||||
<th>Voter</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -28,13 +29,20 @@
|
||||
<%= TagSetPresenter.new(vote.post.tag_array).inline_tag_list_html %>
|
||||
</td>
|
||||
<td><%= link_to sprintf("%+d", vote.score), post_votes_path(search: { score: vote.score }) %></td>
|
||||
<td>
|
||||
<%= link_to_user vote.post.uploader %>
|
||||
<%= link_to "»", post_votes_path(search: { post_tags_match: "user:#{vote.post.uploader.name}" }) %>
|
||||
<div><%= time_ago_in_words_tagged(vote.post.created_at) %></div>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to_user vote.user %>
|
||||
<%= link_to "»", post_votes_path(search: { user_name: vote.user.name }) %>
|
||||
<div><%= time_ago_in_words_tagged(vote.created_at) %></div>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to "undo", post_post_votes_path(vote.post), remote: true, method: :delete %>
|
||||
<% if vote.user == CurrentUser.user %>
|
||||
<%= link_to "unvote", post_post_votes_path(vote.post), remote: true, method: :delete %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -87,9 +87,11 @@
|
||||
|
||||
<% if CurrentUser.user == user || CurrentUser.user.is_admin? %>
|
||||
<tr>
|
||||
<th>Post Votes</th>
|
||||
<th>Votes</th>
|
||||
<td>
|
||||
<%= link_to user.post_votes.count, post_votes_path(search: { user_name: user.name }) %>
|
||||
<%= link_to user.post_votes.count, post_votes_path(search: { user_name: user.name }) %> posts,
|
||||
<%= link_to user.comment_votes.count, comment_votes_path(search: { user_name: user.name }) %> comments,
|
||||
<%= link_to user.forum_post_votes.count, forum_post_votes_path(search: { creator_name: user.name }) %> forum posts
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user