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({
|
$(document).on({
|
||||||
"mouseenter focus": function() {
|
"mouseenter focus": function() {
|
||||||
$("div.participation-not-allowed", this).show();
|
$("div.participation-not-allowed", this).show();
|
||||||
$("div.participation-allowed", this).hide();
|
|
||||||
},
|
},
|
||||||
mouseleave: function() {
|
mouseleave: function() {
|
||||||
$("div.participation-not-allowed", this).hide();
|
$("div.participation-not-allowed", this).hide();
|
||||||
$("div.participation-allowed", this).show();
|
|
||||||
}
|
}
|
||||||
}, votes);
|
}, votes);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<div class="votes">
|
<div class="votes">
|
||||||
<% if current_user %>
|
|
||||||
<%= t("comments.comment.votes", count: comment.total_votes) %>
|
<%= t("comments.comment.votes", count: comment.total_votes) %>
|
||||||
|
|
|
|
||||||
|
|
||||||
@@ -34,44 +33,8 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<%= comment.total_dislikes %>
|
<%= comment.total_dislikes %>
|
||||||
</span>
|
</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="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>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
<% unless current_user %>
|
||||||
<div tabindex="0">
|
<div tabindex="0">
|
||||||
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
||||||
<%= sanitize(t("votes.comment_unauthenticated", signin: link_to_signin, signup: link_to_signup)) %>
|
<%= sanitize(t("votes.comment_unauthenticated", signin: link_to_signin, signup: link_to_signup)) %>
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ module Votes
|
|||||||
within(".participation-not-allowed") do
|
within(".participation-not-allowed") do
|
||||||
expect(page).to have_content "You must sign in or sign up to vote"
|
expect(page).to have_content "You must sign in or sign up to vote"
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(page).not_to have_selector(".participation-allowed")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def expect_message_to_many_anonymous_votes
|
def expect_message_to_many_anonymous_votes
|
||||||
|
|||||||
Reference in New Issue
Block a user