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:
evazion
2019-10-28 14:34:56 -05:00
parent d3165f78aa
commit fd4a9d4d30
7 changed files with 48 additions and 14 deletions

View File

@@ -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 %>