Added votes to Legislation Proposals
This commit is contained in:
@@ -42,7 +42,7 @@ class Legislation::ProposalsController < Legislation::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def vote
|
def vote
|
||||||
@proposal.register_vote(current_user, 'yes')
|
@proposal.register_vote(current_user, params[:value])
|
||||||
set_legislation_proposal_votes(@proposal)
|
set_legislation_proposal_votes(@proposal)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +1,61 @@
|
|||||||
<div class="supports text-center">
|
<% voted_classes = css_classes_for_vote(@legislation_proposal_votes, proposal) %>
|
||||||
<span class="total-supports">
|
<div class="votes">
|
||||||
<%= t("proposals.proposal.supports", count: proposal.total_votes) %>
|
<div class="in-favor inline-block">
|
||||||
|
<% if user_signed_in? %>
|
||||||
|
<%= link_to vote_legislation_process_proposal_path(process_id: proposal.process, id: proposal, value: 'yes'),
|
||||||
|
class: "like #{voted_classes[:in_favor]}", title: t('votes.agree'), method: "post", remote: true do %>
|
||||||
|
<span class="icon-like">
|
||||||
|
<span class="show-for-sr"><%= t('votes.agree') %></span>
|
||||||
</span>
|
</span>
|
||||||
|
<span class="percentage"><%= votes_percentage('likes', proposal) %></span>
|
||||||
<div class="in-favor">
|
|
||||||
<% if voted_for?(@legislation_proposal_votes, proposal) %>
|
|
||||||
<div class="supported callout success">
|
|
||||||
<%= t("proposals.proposal.already_supported") %>
|
|
||||||
</div>
|
|
||||||
<% elsif user_signed_in? && proposal.votable_by?(current_user) %>
|
|
||||||
<%= link_to vote_url,
|
|
||||||
class: "button button-support small expanded",
|
|
||||||
title: t('proposals.proposal.support_title'), method: "post", remote: true do %>
|
|
||||||
<%= t("proposals.proposal.support") %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="button button-support small expanded">
|
<div class="like">
|
||||||
<%= t("proposals.proposal.support") %>
|
<span class="icon-like">
|
||||||
|
<span class="show-for-sr"><%= t('votes.agree') %></span>
|
||||||
|
</span>
|
||||||
|
<span class="percentage"><%= votes_percentage('likes', proposal) %></span>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<span class="divider"></span>
|
||||||
|
|
||||||
|
<div class="against inline-block">
|
||||||
|
<% if user_signed_in? %>
|
||||||
|
<%= link_to vote_legislation_process_proposal_path(process_id: proposal.process, id: proposal, value: 'no'), class: "unlike #{voted_classes[:against]}", title: t('votes.disagree'), method: "post", remote: true do %>
|
||||||
|
<span class="icon-unlike">
|
||||||
|
<span class="show-for-sr"><%= t('votes.disagree') %></span>
|
||||||
|
</span>
|
||||||
|
<span class="percentage"><%= votes_percentage('dislikes', proposal) %></span>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<div class="unlike">
|
||||||
|
<span class="icon-unlike">
|
||||||
|
<span class="show-for-sr"><%= t('votes.disagree') %></span>
|
||||||
|
</span>
|
||||||
|
<span class="percentage"><%= votes_percentage('dislikes', proposal) %></span>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span class="total-votes">
|
||||||
|
<%= t("proposals.proposal.votes", count: proposal.total_votes) %>
|
||||||
|
</span>
|
||||||
|
|
||||||
<% if user_signed_in? && current_user.organization? %>
|
<% if user_signed_in? && current_user.organization? %>
|
||||||
<div class="participation-not-allowed" style='display:none' aria-hidden="false">
|
<div class="participation-not-allowed" style='display:none' aria-hidden="false">
|
||||||
<p>
|
<p>
|
||||||
<%= t("votes.organizations") %>
|
<%= t("votes.organizations") %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<% elsif user_signed_in? && !proposal.votable_by?(current_user) %>
|
<% elsif user_signed_in? && !proposal.votable_by?(current_user)%>
|
||||||
<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">
|
||||||
<p>
|
<p>
|
||||||
<%= t("votes.verified_only",
|
<%= t("votes.anonymous",
|
||||||
verify_account: link_to(t("votes.verify_account"), verification_path )).html_safe %>
|
verify_account: link_to(t("votes.verify_account"), verification_path )).html_safe %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<% elsif !user_signed_in? %>
|
<% elsif !user_signed_in? %>
|
||||||
<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">
|
||||||
|
|||||||
Reference in New Issue
Block a user