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:
@@ -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)) %>
|
||||
|
||||
Reference in New Issue
Block a user