From e28da733d7a1bc34acd7b461e6ffc4a155f14079 Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 18 Nov 2021 01:59:47 -0600 Subject: [PATCH] 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. --- .../post_votes_component.html.erb | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/components/post_votes_component/post_votes_component.html.erb b/app/components/post_votes_component/post_votes_component.html.erb index 5934c1a42..65dfdd071 100644 --- a/app/components/post_votes_component/post_votes_component.html.erb +++ b/app/components/post_votes_component/post_votes_component.html.erb @@ -1,21 +1,21 @@ - <% if can_vote? %> - <% if upvoted? %> - <%= 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 %> - <% else %> - <%= 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 %> + <% if current_user.is_anonymous? %> + <%= link_to upvote_icon, login_path(url: request.fullpath), class: "post-upvote-link inactive-link" %> + <% elsif upvoted? %> + <%= 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 %> + <% else %> + <%= 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 %> <%= link_to post.score, post_votes_path(search: { post_id: post.id }, variant: :compact) %> - <% if can_vote? %> - <% if downvoted? %> - <%= 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 %> - <% else %> - <%= 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 %> + <% if current_user.is_anonymous? %> + <%= link_to downvote_icon, login_path(url: request.fullpath), class: "post-downvote-link inactive-link" %> + <% elsif downvoted? %> + <%= 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 %> + <% else %> + <%= 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 %>