can add investments to ballot

This commit is contained in:
rgarcia
2016-09-05 19:29:53 +02:00
parent 53d53ea9fb
commit 9839d7afd0
22 changed files with 881 additions and 17 deletions

View File

@@ -1,10 +1,10 @@
<li id="<%= dom_id(investment) %>_sidebar">
<%= investment.title %>
<span><%= format_price(investment.price) %></span>
<span><%= format_price(@budget, investment.price) %></span>
<% if @budget.balloting? %>
<%= link_to ballot_line_path(id: investment.id,
investments_ids: investment_ids),
<%= link_to budget_ballot_line_url(id: investment.id,
investments_ids: investment_ids),
title: t('budgets.ballots.show.remove'),
class: "remove-investment-project",
method: :delete,

View File

@@ -0,0 +1,28 @@
<span class="total-amount">
<%= format_price(@budget, @budget.heading_price(@heading)) %>
</span>
<div class="progress" role="progressbar" tabindex="0"
aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
<div class="progress-meter"
style="width:
<%= progress_bar_width(@budget.heading_price(@heading),
@ballot.amount_spent(@heading.id)) %>">
</div>
</div>
<div class="progress spent-amount-progress" role="progressbar" tabindex="0"
aria-valuenow="20" aria-valuemin="0" aria-valuetext="25 percent" aria-valuemax="100">
<span class="progress-meter spent-amount-meter"
style="width:
<%= progress_bar_width(@budget.heading_price(@heading),
@ballot.amount_spent(@heading.id)) %>">
<p id="amount-spent" class="progress-meter-text spent-amount-text">
<%= format_price(@budget, @ballot.amount_spent(@heading.id)) %>
<span id="amount-available" class="amount-available">
<%= t("spending_proposals.index.available") %>
<span><%= format_price(@budget, @ballot.amount_available(@heading)) %></span>
</span>
</p>
</span>
</div>

View File

@@ -4,12 +4,12 @@
</span>
<p class="investment-project-amount">
<%= format_price(investment.price) %>
<%= format_price(@budget, investment.price) %>
</p>
<% if @budget.balloting? %>
<%= link_to t('budgets.ballots.show.remove'),
ballot_line_path(id: investment.id,
budget_ballot_line_path(id: investment.id,
investments_ids: investment_ids),
class: "delete small expanded",
method: :delete,

View File

@@ -0,0 +1,5 @@
<% if @spending_proposals.present? %>
<% @spending_proposals.each do |spending_proposal| %>
$("#<%= dom_id(spending_proposal) %>_ballot").html('<%= j render("spending_proposals/ballot", spending_proposal: spending_proposal) %>');
<% end %>
<% end %>

View File

@@ -0,0 +1,5 @@
$("#progress_bar").html('<%= j render("budgets/ballot/progress_bar", ballot: @ballot) %>');
$("#sidebar").html('<%= j render("budgets/investments/sidebar") %>');
$("#<%= dom_id(@investment) %>_ballot").html('<%= j render("budgets/investments/ballot", investment: @investment) %>');
<%= render 'refresh_ballots' %>

View File

@@ -0,0 +1,6 @@
$("#progress_bar").html('<%= j render("spending_proposals/progress_bar", ballot: @ballot) %>');
$("#sidebar").html('<%= j render("spending_proposals/sidebar") %>');
$("#ballot").html('<%= j render("ballots/ballot") %>')
$("#<%= dom_id(@spending_proposal) %>_ballot").html('<%= j render("spending_proposals/ballot", spending_proposal: @spending_proposal) %>');
<%= render 'refresh_ballots' %>

View File

@@ -0,0 +1,2 @@
$("#<%= dom_id(@spending_proposal) %>_ballot").html('<%= j render("spending_proposals/ballot", spending_proposal: @spending_proposal) %>');
$(".no-supports-allowed").show();

View File

@@ -1,9 +1,13 @@
<% reason = investment.reason_for_not_being_ballotable_by(current_user, @ballot) %>
<div class="supports ballot">
<% if @ballot.has_investment?(investment) %>
<%= render 'budgets/ballots/remove', investment: investment %>
<%= render 'budgets/ballot/remove',
investment: investment,
investment_ids: @investments %>
<% else %>
<%= render 'budgets/ballots/add', investment: investment %>
<%= render 'budgets/ballot/add',
investment: investment,
investment_ids: @investments %>
<% end %>
<% if reason.present? && !@ballot.has_investment?(investment) %>
@@ -14,7 +18,7 @@
verify_account: link_to(t("votes.verify_account"), verification_path),
signin: link_to(t("votes.signin"), new_user_session_path),
signup: link_to(t("votes.signup"), new_user_registration_path),
my_heading: link_to(@ballot.heading.try(:name), budget_investments_path(budget_id: @budget.id, heading_id: @ballot.heading_id))
my_heading: link_to(@ballot.try(:heading).try(:name), budget_investments_path(budget_id: @budget.id, heading_id: @ballot.try(:heading_id)))
).html_safe %>
</p>
</div>

View File

@@ -10,7 +10,9 @@
<% end %>
<% if can? :show, @ballot %>
<%= link_to t("budget.investments.header.check_ballot"), budget_ballot_path(@budget, @ballot), class: "button float-right" %>
<%= link_to t("budget.investments.header.check_ballot"),
budget_ballot_path(@budget, @ballot),
class: "button float-right" %>
<% end %>
</div>
</div>
@@ -21,7 +23,8 @@
<h1 class="inline-block"><%= @filter_geozone_name %></h1>
<div id="check-ballot" style="display: none;">
<% if can? :show, @ballot %>
<%= link_to t("budget.investments.header.check_ballot"), ballot_path %>
<%= link_to t("budget.investments.header.check_ballot"),
budget_ballot_path(@budget) %>
<% end %>
</div>
<% if @heading.present? && @ballot.heading.present? && @ballot.heading != @heading %>

View File

@@ -53,7 +53,7 @@
vote_url: vote_budget_investment_path(@budget, investment, value: 'yes') } %>
</div>
<% elsif feature?("investment_features.phase3") %>
<% elsif @budget.balloting? %>
<div id="<%= dom_id(investment) %>_ballot"
class="small-12 medium-3 column text-center">
<%= render 'ballot', investment: investment %>

View File

@@ -13,7 +13,7 @@
<em>
<%= t("budget.investments.index.sidebar.voted_html",
count: @ballot.investments.by_heading(@heading.id).count,
amount_spent: format_price(@ballot.amount_spent(@heading))) %>
amount_spent: format_price(@budget, @ballot.amount_spent(@heading))) %>
</em>
</p>
<% else %>
@@ -22,7 +22,9 @@
<ul class="ballot-list">
<% @ballot.investments.by_heading(@heading).each do |investment| %>
<%= render 'ballots/investment_for_sidebar', investment: investment %>
<%= render 'budgets/ballot/investment_for_sidebar',
investment: investment,
investment_ids: @investments %>
<% end %>
</ul>