votes: show vote buttons to logged-out users.

Show upvote and downvote buttons to logged-out users. Clicking them
sends you to the login page.
This commit is contained in:
evazion
2021-11-18 01:59:47 -06:00
parent bd8672681f
commit e28da733d7

View File

@@ -1,21 +1,21 @@
<span class="post-votes" data-id="<%= post.id %>"> <span class="post-votes" data-id="<%= post.id %>">
<% if can_vote? %> <% if current_user.is_anonymous? %>
<% if upvoted? %> <%= link_to upvote_icon, login_path(url: request.fullpath), class: "post-upvote-link inactive-link" %>
<%= link_to upvote_icon, post_post_votes_path(post_id: post.id), class: "post-upvote-link post-unvote-link active-link", method: :delete, remote: true %> <% elsif upvoted? %>
<% else %> <%= link_to upvote_icon, post_post_votes_path(post_id: post.id), class: "post-upvote-link post-unvote-link active-link", method: :delete, remote: true %>
<%= link_to upvote_icon, post_post_votes_path(post_id: post.id, score: 1), class: "post-upvote-link inactive-link", method: :post, remote: true %> <% else %>
<% end %> <%= link_to upvote_icon, post_post_votes_path(post_id: post.id, score: 1), class: "post-upvote-link inactive-link", method: :post, remote: true %>
<% end %> <% end %>
<span class="post-score"> <span class="post-score">
<%= link_to post.score, post_votes_path(search: { post_id: post.id }, variant: :compact) %> <%= link_to post.score, post_votes_path(search: { post_id: post.id }, variant: :compact) %>
</span> </span>
<% if can_vote? %> <% if current_user.is_anonymous? %>
<% if downvoted? %> <%= link_to downvote_icon, login_path(url: request.fullpath), class: "post-downvote-link inactive-link" %>
<%= link_to downvote_icon, post_post_votes_path(post_id: post.id), class: "post-downvote-link post-unvote-link active-link", method: :delete, remote: true %> <% elsif downvoted? %>
<% else %> <%= link_to downvote_icon, post_post_votes_path(post_id: post.id), class: "post-downvote-link post-unvote-link active-link", method: :delete, remote: true %>
<%= link_to downvote_icon, post_post_votes_path(post_id: post.id, score: -1), class: "post-downvote-link inactive-link", method: :post, remote: true %> <% else %>
<% end %> <%= link_to downvote_icon, post_post_votes_path(post_id: post.id, score: -1), class: "post-downvote-link inactive-link", method: :post, remote: true %>
<% end %> <% end %>
</span> </span>