Remove duplication in comments votes component
We're also simplifying the code a bit by removing the `participation-allowed` HTML class, which wasn't used in any other votes component.
This commit is contained in:
@@ -5,11 +5,9 @@
|
||||
$(document).on({
|
||||
"mouseenter focus": function() {
|
||||
$("div.participation-not-allowed", this).show();
|
||||
$("div.participation-allowed", this).hide();
|
||||
},
|
||||
mouseleave: function() {
|
||||
$("div.participation-not-allowed", this).hide();
|
||||
$("div.participation-allowed", this).show();
|
||||
}
|
||||
}, votes);
|
||||
},
|
||||
|
||||
@@ -1,77 +1,40 @@
|
||||
<div class="votes">
|
||||
<% if current_user %>
|
||||
<%= t("comments.comment.votes", count: comment.total_votes) %>
|
||||
|
|
||||
<%= t("comments.comment.votes", count: comment.total_votes) %>
|
||||
|
|
||||
|
||||
<span class="in_favor">
|
||||
<% if can?(:vote, comment) %>
|
||||
<%= link_to vote_comment_path(comment, value: "yes"),
|
||||
method: "post", remote: true, title: t("votes.agree") do %>
|
||||
<span class="icon-like">
|
||||
<span class="show-for-sr"><%= t("votes.agree") %></span>
|
||||
</span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span class="icon-like">
|
||||
<span class="show-for-sr"><%= t("votes.agree") %></span>
|
||||
</span>
|
||||
<% end %>
|
||||
<%= comment.total_likes %>
|
||||
</span>
|
||||
|
||||
<span class="against">
|
||||
<% if can?(:vote, comment) %>
|
||||
<%= link_to vote_comment_path(comment, value: "no"),
|
||||
method: "post", remote: true, title: t("votes.disagree") do %>
|
||||
<span class="icon-unlike">
|
||||
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
||||
</span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span class="icon-unlike">
|
||||
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
||||
</span>
|
||||
<% end %>
|
||||
<%= comment.total_dislikes %>
|
||||
</span>
|
||||
<% else %>
|
||||
<div class="participation-allowed">
|
||||
<%= t("comments.comment.votes", count: comment.total_votes) %>
|
||||
|
|
||||
|
||||
<span class="in_favor">
|
||||
<% if can?(:vote, comment) %>
|
||||
<%= link_to vote_comment_path(comment, value: "yes"),
|
||||
method: "post", remote: true, title: t("votes.agree") do %>
|
||||
<span class="icon-like">
|
||||
<span class="show-for-sr"><%= t("votes.agree") %></span>
|
||||
</span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span class="in_favor">
|
||||
<% if can?(:vote, comment) %>
|
||||
<%= link_to vote_comment_path(comment, value: "yes"),
|
||||
method: "post", remote: true, title: t("votes.agree") do %>
|
||||
<span class="icon-like">
|
||||
<span class="show-for-sr"><%= t("votes.agree") %></span>
|
||||
</span>
|
||||
<% end %>
|
||||
<%= comment.total_likes %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span class="icon-like">
|
||||
<span class="show-for-sr"><%= t("votes.agree") %></span>
|
||||
</span>
|
||||
<% end %>
|
||||
<%= comment.total_likes %>
|
||||
</span>
|
||||
|
||||
<span class="against">
|
||||
<% if can?(:vote, comment) %>
|
||||
<%= link_to vote_comment_path(comment, value: "no"),
|
||||
method: "post", remote: true, title: t("votes.disagree") do %>
|
||||
<span class="icon-unlike">
|
||||
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
||||
</span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span class="against">
|
||||
<% if can?(:vote, comment) %>
|
||||
<%= link_to vote_comment_path(comment, value: "no"),
|
||||
method: "post", remote: true, title: t("votes.disagree") do %>
|
||||
<span class="icon-unlike">
|
||||
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
||||
</span>
|
||||
<% end %>
|
||||
<%= comment.total_dislikes %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span class="icon-unlike">
|
||||
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= comment.total_dislikes %>
|
||||
</span>
|
||||
|
||||
<% unless current_user %>
|
||||
<div tabindex="0">
|
||||
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
||||
<%= sanitize(t("votes.comment_unauthenticated", signin: link_to_signin, signup: link_to_signup)) %>
|
||||
|
||||
@@ -8,8 +8,6 @@ module Votes
|
||||
within(".participation-not-allowed") do
|
||||
expect(page).to have_content "You must sign in or sign up to vote"
|
||||
end
|
||||
|
||||
expect(page).not_to have_selector(".participation-allowed")
|
||||
end
|
||||
|
||||
def expect_message_to_many_anonymous_votes
|
||||
|
||||
Reference in New Issue
Block a user