Skip to content

Commit

Permalink
Added votes to Legislation Proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaCheca committed Oct 25, 2017
1 parent b5f2f9a commit 276baed
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 25 deletions.
2 changes: 1 addition & 1 deletion app/controllers/legislation/proposals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def index_customization
end

def vote
@proposal.register_vote(current_user, 'yes')
@proposal.register_vote(current_user, params[:value])
set_legislation_proposal_votes(@proposal)
end

Expand Down
68 changes: 44 additions & 24 deletions app/views/legislation/proposals/_votes.html.erb
Original file line number Diff line number Diff line change
@@ -1,40 +1,60 @@
<div class="supports text-center">
<span class="total-supports">
<%= t("proposals.proposal.supports", count: proposal.total_votes) %>&nbsp;
</span>

<div class="in-favor">
<% if voted_for?(@legislation_proposal_votes, proposal) %>
<div class="supported callout success">
<%= t("proposals.proposal.already_supported") %>
<% voted_classes = css_classes_for_vote(@legislation_proposal_votes, proposal) %>
<div class="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 class="percentage"><%= votes_percentage('likes', proposal) %></span>
<% end %>
<% else %>
<div class="like">
<span class="icon-like">
<span class="show-for-sr"><%= t('votes.agree') %></span>
</span>
<span class="percentage"><%= votes_percentage('likes', proposal) %></span>
</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 %>
</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="button button-support small expanded">
<%= t("proposals.proposal.support") %>
<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? %>
<div class="participation-not-allowed" style='display:none' aria-hidden="false">
<p>
<%= t("votes.organizations") %>
</p>
</div>
<% elsif user_signed_in? && !proposal.votable_by?(current_user) %>
<div tabindex="0">
<div class="participation-not-allowed" style='display:none' aria-hidden="false">
<p>
<%= t("votes.verified_only",
verify_account: link_to(t("votes.verify_account"), verification_path )).html_safe %>
</p>
</div>
<% elsif user_signed_in? && !proposal.votable_by?(current_user)%>
<div class="participation-not-allowed" style='display:none' aria-hidden="false">
<p>
<%= t("votes.anonymous",
verify_account: link_to(t("votes.verify_account"), verification_path )).html_safe %>
</p>
</div>
<% elsif !user_signed_in? %>
<div tabindex="0">
Expand Down

0 comments on commit 276baed

Please sign in to comment.