posts: make post votes work the same way as comment votes.

Change post votes to work the same way as comment votes:

* Make the upvote arrow blue if you've upvoted the post, or grey if you
  haven't. Likewise for the downvote arrow.
* Make it so you can click the upvote or downvote arrows to undo the vote.
* Don't show any notices when you vote on a post.

Also fix it so that votes work the same way on the posts page, the
comments page, and in the modqueue. Before it wasn't possible to undo
votes on the comments page or in the modqueue.
This commit is contained in:
evazion
2021-01-28 17:34:42 -06:00
parent 0a8fe506b4
commit ffdd5e6128
13 changed files with 135 additions and 42 deletions

View File

@@ -28,12 +28,7 @@
<span class="info">
<strong>Score</strong>
<span>
<span id="score-for-post-<%= post.id %>"><%= post.score %></span>
<% if policy(PostVote).create? %>
(vote <%= link_to upvote_icon, post_post_votes_path(score: "up", post_id: post.id), remote: true, method: :post %>/<%= link_to downvote_icon, post_post_votes_path(score: "down", post_id: post.id), remote: true, method: :post %>)
<% end %>
</span>
<%= render_post_votes post, current_user: CurrentUser.user %>
</span>
</div>