removes investments from sidebar
This commit is contained in:
55
app/views/budgets/ballot/_ballot.html.erb
Normal file
55
app/views/budgets/ballot/_ballot.html.erb
Normal file
@@ -0,0 +1,55 @@
|
||||
<div class="row ballot">
|
||||
|
||||
<%= render 'shared/back_link' %>
|
||||
|
||||
<h1 class="text-center"><%= t("budgets.ballots.show.title") %></h1>
|
||||
|
||||
<div class="small-12 medium-8 column small-centered text-center">
|
||||
<h2>
|
||||
<%= t("budgets.ballots.show.voted_html",
|
||||
count: @ballot.investments.count) %>
|
||||
</h2>
|
||||
<p>
|
||||
<small>
|
||||
<%= t("budgets.ballots.show.voted_info_html") %>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<div class="margin-top">
|
||||
<% @ballot.groups.each do |group| %>
|
||||
<div id="<%= dom_id(group) %>"
|
||||
class="small-12 medium-6 column">
|
||||
<h3 class="subtitle">
|
||||
<%= group.name %> - <%= group.headings.first.name %>
|
||||
</h3>
|
||||
<% if @ballot.has_lines_in_group?(group) %>
|
||||
<h4 class="amount-spent text-right">
|
||||
<%= t("budgets.ballots.show.amount_spent") %>
|
||||
<span>
|
||||
<%= format_price(@budget, @ballot.amount_spent(@ballot.heading_for_group(group).id)) %>
|
||||
</span>
|
||||
</h4>
|
||||
<% else %>
|
||||
<p>
|
||||
<%= t("budgets.ballots.show.zero") %><br>
|
||||
<%= link_to t("budgets.ballots.show.heading_link"),
|
||||
budget_investments_path(budget, heading_id: heading.id),
|
||||
data: { no_turbolink: true } %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<ul class="ballot-list">
|
||||
<%= render partial: 'budgets/ballot/investment',
|
||||
collection: @ballot.investments.by_group(group.id) %>
|
||||
</ul>
|
||||
|
||||
<h4>
|
||||
<%= t("budgets.ballots.show.remaining",
|
||||
amount_city: format_price(@budget, @ballot.amount_available(@ballot.heading_for_group(group)))).html_safe %>
|
||||
</h4>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -3,12 +3,12 @@
|
||||
<span><%= format_price(@budget, investment.price) %></span>
|
||||
|
||||
<% if @budget.balloting? %>
|
||||
<%# link_to budget_ballot_line_path(budget, id: investment.id),
|
||||
<%= link_to budget_ballot_line_path(@budget, id: investment.id),
|
||||
title: t('budgets.ballots.show.remove'),
|
||||
class: "remove-investment-project",
|
||||
method: :delete,
|
||||
remote: true do %>
|
||||
<span class="icon-x"></span>
|
||||
<%# end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
$("#progress_bar").html('<%= j render("budgets/ballot/progress_bar", ballot: @ballot) %>');
|
||||
$("#sidebar").html('<%= j render("spending_proposals/sidebar") %>');
|
||||
// $("#ballot").html('<%# j render("ballots/ballot") %>')
|
||||
$("#sidebar").html('<%= j render("budgets/investments/sidebar") %>');
|
||||
$("#ballot").html('<%= j render("budgets/ballot/ballot") %>')
|
||||
$("#<%= dom_id(@investment) %>_ballot").html('<%= j render("budgets/investments/ballot", investment: @investment) %>');
|
||||
|
||||
<%= render 'refresh_ballots' %>
|
||||
|
||||
@@ -1,57 +1,3 @@
|
||||
<div id="ballot">
|
||||
<div class="row ballot">
|
||||
|
||||
<%= render 'shared/back_link' %>
|
||||
|
||||
<h1 class="text-center"><%= t("budgets.ballots.show.title") %></h1>
|
||||
|
||||
<div class="small-12 medium-8 column small-centered text-center">
|
||||
<h2>
|
||||
<%= t("budgets.ballots.show.voted_html",
|
||||
count: @ballot.investments.count) %>
|
||||
</h2>
|
||||
<p>
|
||||
<small>
|
||||
<%= t("budgets.ballots.show.voted_info_html") %>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<div class="margin-top">
|
||||
<% @ballot.groups.each do |group| %>
|
||||
<div id="<%= dom_id(group) %>"
|
||||
class="small-12 medium-6 column">
|
||||
<h3 class="subtitle">
|
||||
<%= group.name %> - <%= group.headings.first.name %>
|
||||
</h3>
|
||||
<% if @ballot.has_lines_in_group?(group) %>
|
||||
<h4 class="amount-spent text-right">
|
||||
<%= t("budgets.ballots.show.amount_spent") %>
|
||||
<span>
|
||||
<%= format_price(@budget, @ballot.amount_spent(@ballot.heading_for_group(group).id)) %>
|
||||
</span>
|
||||
</h4>
|
||||
<% else %>
|
||||
<p>
|
||||
<%= t("budgets.ballots.show.zero") %><br>
|
||||
<%= link_to t("budgets.ballots.show.heading_link"),
|
||||
budget_investments_path(budget, heading_id: heading.id),
|
||||
data: { no_turbolink: true } %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<ul class="ballot-list">
|
||||
<%= render partial: 'budgets/ballot/investment',
|
||||
collection: @ballot.investments.by_group(group.id) %>
|
||||
</ul>
|
||||
|
||||
<h4>
|
||||
<%= t("budgets.ballots.show.remaining",
|
||||
amount_city: format_price(@budget, @ballot.amount_available(@ballot.heading_for_group(group)))).html_safe %>
|
||||
</h4>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<%= render "budgets/ballot/ballot" %>
|
||||
</div>
|
||||
|
||||
@@ -363,93 +363,56 @@ feature 'Ballots' do
|
||||
|
||||
scenario 'Removing spending proposals from ballot', :js do
|
||||
user = create(:user, :level_two)
|
||||
ballot = create(:ballot, user: user)
|
||||
sp = create(:spending_proposal, :feasible, :finished, price: 10)
|
||||
ballot.spending_proposals = [sp]
|
||||
ballot = create(:budget_ballot, user: user, budget: budget)
|
||||
investment = create(:budget_investment, :feasible, :finished, price: 10, heading: heading, group: group)
|
||||
create(:budget_ballot_line, ballot: ballot, investment: investment, heading: heading, group: group)
|
||||
|
||||
login_as(user)
|
||||
visit ballot_path
|
||||
visit budget_ballot_path(budget)
|
||||
|
||||
expect(page).to have_content("You voted one proposal")
|
||||
expect(page).to have_content("You have voted one proposal")
|
||||
|
||||
within("#spending_proposal_#{sp.id}") do
|
||||
within("#budget_investment_#{investment.id}") do
|
||||
find(".remove-investment-project").trigger('click')
|
||||
end
|
||||
|
||||
expect(current_path).to eq(ballot_path)
|
||||
expect(page).to have_content("You voted 0 proposals")
|
||||
expect(current_path).to eq(budget_ballot_path(budget))
|
||||
expect(page).to have_content("You have voted 0 proposals")
|
||||
end
|
||||
|
||||
scenario 'Removing spending proposals from ballot (sidebar)', :js do
|
||||
scenario 'Removing spending proposals from ballot (sidebar)', :js, :focus do
|
||||
user = create(:user, :level_two)
|
||||
sp1 = create(:spending_proposal, :feasible, :finished, price: 10000)
|
||||
sp2 = create(:spending_proposal, :feasible, :finished, price: 20000)
|
||||
investment1 = create(:budget_investment, :feasible, :finished, price: 10000, heading: heading)
|
||||
investment2 = create(:budget_investment, :feasible, :finished, price: 20000, heading: heading)
|
||||
|
||||
ballot = create(:ballot, user: user, spending_proposals: [sp1, sp2])
|
||||
ballot = create(:budget_ballot, budget: budget, user: user, investments: [investment1, investment2])
|
||||
|
||||
login_as(user)
|
||||
visit spending_proposals_path(geozone: 'all')
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
expect(page).to have_css("#amount-spent", text: "€30,000")
|
||||
expect(page).to have_css("#amount-available", text: "€23,970,000")
|
||||
expect(page).to have_css("#amount-available", text: "€970,000")
|
||||
|
||||
within("#sidebar") do
|
||||
expect(page).to have_content sp1.title
|
||||
expect(page).to have_content investment1.title
|
||||
expect(page).to have_content "€10,000"
|
||||
|
||||
expect(page).to have_content sp2.title
|
||||
expect(page).to have_content investment2.title
|
||||
expect(page).to have_content "€20,000"
|
||||
end
|
||||
|
||||
within("#sidebar #spending_proposal_#{sp1.id}_sidebar") do
|
||||
within("#sidebar #budget_investment_#{investment1.id}_sidebar") do
|
||||
find(".remove-investment-project").trigger('click')
|
||||
end
|
||||
|
||||
expect(page).to have_css("#amount-spent", text: "€20,000")
|
||||
expect(page).to have_css("#amount-available", text: "€23,980,000")
|
||||
expect(page).to have_css("#amount-available", text: "€980,000")
|
||||
|
||||
within("#sidebar") do
|
||||
expect(page).to_not have_content sp1.title
|
||||
expect(page).to_not have_content investment1.title
|
||||
expect(page).to_not have_content "€10,000"
|
||||
|
||||
expect(page).to have_content sp2.title
|
||||
expect(page).to have_content "€20,000"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Removing spending proposals from ballot (sidebar)', :js do
|
||||
user = create(:user, :level_two)
|
||||
sp1 = create(:spending_proposal, :feasible, :finished, price: 10000)
|
||||
sp2 = create(:spending_proposal, :feasible, :finished, price: 20000)
|
||||
|
||||
ballot = create(:ballot, user: user, spending_proposals: [sp1, sp2])
|
||||
|
||||
login_as(user)
|
||||
visit spending_proposals_path(geozone: 'all')
|
||||
|
||||
expect(page).to have_css("#amount-spent", text: "€30,000")
|
||||
expect(page).to have_css("#amount-available", text: "€23,970,000")
|
||||
|
||||
within("#sidebar") do
|
||||
expect(page).to have_content sp1.title
|
||||
expect(page).to have_content "€10,000"
|
||||
|
||||
expect(page).to have_content sp2.title
|
||||
expect(page).to have_content "€20,000"
|
||||
end
|
||||
|
||||
within("#sidebar #spending_proposal_#{sp1.id}_sidebar") do
|
||||
find(".remove-investment-project").trigger('click')
|
||||
end
|
||||
|
||||
expect(page).to have_css("#amount-spent", text: "€20,000")
|
||||
expect(page).to have_css("#amount-available", text: "€23,980,000")
|
||||
|
||||
within("#sidebar") do
|
||||
expect(page).to_not have_content sp1.title
|
||||
expect(page).to_not have_content "€10,000"
|
||||
|
||||
expect(page).to have_content sp2.title
|
||||
expect(page).to have_content investment2.title
|
||||
expect(page).to have_content "€20,000"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user