Merge pull request #3268 from consul/budget-polish
[Backport] Budgets UI minor fixes
This commit is contained in:
@@ -1253,16 +1253,12 @@
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-bottom: $line-height / 2;
|
margin-bottom: $line-height / 2;
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: $highlight;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
a {
|
||||||
display: block;
|
display: block;
|
||||||
padding: $line-height / 2;
|
padding: $line-height / 2;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
background: $highlight;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ module BudgetsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def css_for_ballot_heading(heading)
|
def css_for_ballot_heading(heading)
|
||||||
return '' if current_ballot.blank?
|
return "" if current_ballot.blank? || @current_filter == "unfeasible"
|
||||||
current_ballot.has_lines_in_heading?(heading) ? 'is-active' : ''
|
current_ballot.has_lines_in_heading?(heading) ? "is-active" : ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_ballot
|
def current_ballot
|
||||||
|
|||||||
@@ -62,8 +62,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
<% if @budget.balloting_process? %>
|
<% if display_calculate_winners_button?(@budget) %>
|
||||||
<%= link_to t("admin.budgets.winners.calculate"),
|
<%= link_to calculate_winner_button_text(@budget),
|
||||||
calculate_winners_admin_budget_path(@budget),
|
calculate_winners_admin_budget_path(@budget),
|
||||||
method: :put,
|
method: :put,
|
||||||
class: "button hollow" %>
|
class: "button hollow" %>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="row margin">
|
<div class="row margin">
|
||||||
<div id="select-district" class="small-12 medium-7 column select-district">
|
<div id="headings" class="small-12 medium-7 column select-district">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<% @group.headings.order_by_group_name.each_slice(7) do |slice| %>
|
<% @group.headings.order_by_group_name.each_slice(7) do |slice| %>
|
||||||
<div class="small-6 medium-4 column end">
|
<div class="small-6 medium-4 column end">
|
||||||
|
|||||||
@@ -94,22 +94,28 @@
|
|||||||
<%= render_map(nil, "budgets", false, nil, @budgets_coordinates) %>
|
<%= render_map(nil, "budgets", false, nil, @budgets_coordinates) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<ul class="no-bullet margin-top">
|
||||||
<% show_links = show_links_to_budget_investments(current_budget) %>
|
<% show_links = show_links_to_budget_investments(current_budget) %>
|
||||||
<% if show_links %>
|
<% if show_links %>
|
||||||
<%= link_to budget_url(current_budget) do %>
|
<li>
|
||||||
<small><%= t("budgets.index.investment_proyects") %></small>
|
<%= link_to budget_url(current_budget) do %>
|
||||||
<% end %><br>
|
<small><%= t("budgets.index.investment_proyects") %></small>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to budget_url(current_budget, filter: 'unfeasible') do %>
|
<li>
|
||||||
<small><%= t("budgets.index.unfeasible_investment_proyects") %></small>
|
<%= link_to budget_url(current_budget, filter: "unfeasible") do %>
|
||||||
<% end %><br>
|
<small><%= t("budgets.index.unfeasible_investment_proyects") %></small>
|
||||||
<% if show_links %>
|
|
||||||
<%= link_to budget_url(current_budget, filter: 'unselected') do %>
|
|
||||||
<small><%= t("budgets.index.not_selected_investment_proyects") %></small>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</li>
|
||||||
|
<% if show_links %>
|
||||||
|
<li>
|
||||||
|
<%= link_to budget_url(current_budget, filter: "unselected") do %>
|
||||||
|
<small><%= t("budgets.index.not_selected_investment_proyects") %></small>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</ul>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div id="all_phases">
|
<div id="all_phases">
|
||||||
|
|||||||
@@ -150,7 +150,7 @@
|
|||||||
<div class="callout warning">
|
<div class="callout warning">
|
||||||
<%= t("budgets.investments.show.project_unfeasible_html") %>
|
<%= t("budgets.investments.show.project_unfeasible_html") %>
|
||||||
</div>
|
</div>
|
||||||
<% elsif investment.winner? %>
|
<% elsif investment.winner? && @budget.finished? %>
|
||||||
<div class="callout success">
|
<div class="callout success">
|
||||||
<strong><%= t("budgets.investments.show.project_winner") %></strong>
|
<strong><%= t("budgets.investments.show.project_winner") %></strong>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -359,20 +359,30 @@ feature 'Admin budget investments' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Disable 'Calculate winner' button if incorrect phase" do
|
scenario "Disable 'Calculate winner' button if incorrect phase" do
|
||||||
budget.update(phase: 'reviewing_ballots')
|
budget.update(phase: "reviewing_ballots")
|
||||||
|
|
||||||
visit admin_budget_budget_investments_path(budget)
|
visit admin_budget_budget_investments_path(budget)
|
||||||
click_link 'Winners'
|
click_link "Winners"
|
||||||
|
|
||||||
expect(page).to have_link "Calculate Winner Investments"
|
expect(page).to have_link "Calculate Winner Investments"
|
||||||
|
|
||||||
budget.update(phase: 'accepting')
|
visit edit_admin_budget_path(budget)
|
||||||
|
|
||||||
|
expect(page).to have_link "Calculate Winner Investments"
|
||||||
|
|
||||||
|
budget.update(phase: "accepting")
|
||||||
|
|
||||||
visit admin_budget_budget_investments_path(budget)
|
visit admin_budget_budget_investments_path(budget)
|
||||||
click_link 'Winners'
|
click_link "Winners"
|
||||||
|
|
||||||
|
expect(page).not_to have_link "Calculate Winner Investments"
|
||||||
|
expect(page).to have_content 'The budget has to stay on phase "Balloting projects", '\
|
||||||
|
'"Reviewing Ballots" or "Finished budget" in order '\
|
||||||
|
"to calculate winners projects"
|
||||||
|
|
||||||
|
visit edit_admin_budget_path(budget)
|
||||||
|
|
||||||
expect(page).not_to have_link "Calculate Winner Investments"
|
expect(page).not_to have_link "Calculate Winner Investments"
|
||||||
expect(page).to have_content 'The budget has to stay on phase "Balloting projects", "Reviewing Ballots" or "Finished budget" in order to calculate winners projects'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Filtering by minimum number of votes", :js do
|
scenario "Filtering by minimum number of votes", :js do
|
||||||
|
|||||||
@@ -220,14 +220,33 @@ feature 'Admin budgets' do
|
|||||||
expect(page).to have_content 'See results'
|
expect(page).to have_content 'See results'
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'For a finished Budget' do
|
scenario "For a finished Budget" do
|
||||||
budget = create(:budget, phase: 'finished')
|
budget = create(:budget, phase: "finished")
|
||||||
allow_any_instance_of(Budget).to receive(:has_winning_investments?).and_return true
|
allow_any_instance_of(Budget).to receive(:has_winning_investments?).and_return(true)
|
||||||
|
|
||||||
visit edit_admin_budget_path(budget)
|
visit edit_admin_budget_path(budget)
|
||||||
|
|
||||||
expect(page).not_to have_content 'Calculate Winner Investments'
|
expect(page).to have_content "Calculate Winner Investments"
|
||||||
expect(page).to have_content 'See results'
|
expect(page).to have_content "See results"
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Recalculate for a finished Budget" do
|
||||||
|
budget = create(:budget, phase: "finished")
|
||||||
|
group = create(:budget_group, budget: budget)
|
||||||
|
heading = create(:budget_heading, group: group)
|
||||||
|
create(:budget_investment, :winner, heading: heading)
|
||||||
|
|
||||||
|
visit edit_admin_budget_path(budget)
|
||||||
|
|
||||||
|
expect(page).to have_content "Recalculate Winner Investments"
|
||||||
|
expect(page).to have_content "See results"
|
||||||
|
expect(page).not_to have_content "Calculate Winner Investments"
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget)
|
||||||
|
click_link "Winners"
|
||||||
|
|
||||||
|
expect(page).to have_content "Recalculate Winner Investments"
|
||||||
|
expect(page).not_to have_content "Calculate Winner Investments"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1073,7 +1073,8 @@ feature 'Budget Investments' do
|
|||||||
expect(page).to have_content("This investment project has been selected for balloting phase")
|
expect(page).to have_content("This investment project has been selected for balloting phase")
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Show (winner budget investment)" do
|
scenario "Show (winner budget investment) only if budget is finished" do
|
||||||
|
budget.update(phase: "balloting")
|
||||||
user = create(:user)
|
user = create(:user)
|
||||||
login_as(user)
|
login_as(user)
|
||||||
|
|
||||||
@@ -1088,6 +1089,12 @@ feature 'Budget Investments' do
|
|||||||
|
|
||||||
visit budget_investment_path(budget_id: budget.id, id: investment.id)
|
visit budget_investment_path(budget_id: budget.id, id: investment.id)
|
||||||
|
|
||||||
|
expect(page).not_to have_content("Winning investment project")
|
||||||
|
|
||||||
|
budget.update(phase: "finished")
|
||||||
|
|
||||||
|
visit budget_investment_path(budget_id: budget.id, id: investment.id)
|
||||||
|
|
||||||
expect(page).to have_content("Winning investment project")
|
expect(page).to have_content("Winning investment project")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1506,6 +1513,39 @@ feature 'Budget Investments' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Highlight voted heading except with unfeasible filter", :js do
|
||||||
|
budget.update(phase: "balloting")
|
||||||
|
user = create(:user, :level_two)
|
||||||
|
|
||||||
|
heading_1 = create(:budget_heading, group: group, name: "Heading 1")
|
||||||
|
heading_2 = create(:budget_heading, group: group, name: "Heading 2")
|
||||||
|
investment = create(:budget_investment, :selected, heading: heading_1)
|
||||||
|
|
||||||
|
login_as(user)
|
||||||
|
visit budget_path(budget)
|
||||||
|
|
||||||
|
click_link "Health"
|
||||||
|
click_link "Heading 1"
|
||||||
|
|
||||||
|
add_to_ballot(investment)
|
||||||
|
|
||||||
|
visit budget_group_path(budget, group)
|
||||||
|
|
||||||
|
expect(page).to have_css("#budget_heading_#{heading_1.id}.is-active")
|
||||||
|
expect(page).to have_css("#budget_heading_#{heading_2.id}")
|
||||||
|
|
||||||
|
visit budget_group_path(budget, group)
|
||||||
|
|
||||||
|
click_link "See unfeasible investments"
|
||||||
|
click_link "Health"
|
||||||
|
|
||||||
|
within("#headings") do
|
||||||
|
expect(page).to have_css("#budget_heading_#{heading_1.id}")
|
||||||
|
expect(page).to have_css("#budget_heading_#{heading_2.id}")
|
||||||
|
expect(page).not_to have_css(".is-active")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario 'Ballot is visible' do
|
scenario 'Ballot is visible' do
|
||||||
login_as(author)
|
login_as(author)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user