Change 'Calculate Winners button' to budget_investments index.

Move the button so that it appears in the Winners tab of the
budget_investments index.

When the budget is in "Balloting projects", "Reviewing Ballots"
or "Finished budget" phases, the button will appear as a button
(clickable). If there are no winners calculated yet, the text
will be "Calculate winner investments"; if there are, the text
will be "Recalculate winner investments".

If the budget is in another phase, the button will be
disabled and a message will appear: 'The budget has to stay on
phase "Balloting projects", "Reviewing Ballots" or
"Finished budget" in order to calculate winners projects'
This commit is contained in:
iagirre
2018-01-23 13:51:41 +01:00
parent 06772a7b87
commit 2821985552
5 changed files with 34 additions and 3 deletions

View File

@@ -9,7 +9,23 @@
<%= link_to t("admin.budget_investments.index.download_current_selection"),
admin_budget_budget_investments_path(csv_params),
class: "float-right small" %>
class: "float-right small clear" %>
<% if params[:filter] == 'winners' %>
<% if display_calculate_winners_button?(@budget) %>
<%= link_to calculate_winner_button_text(@budget),
calculate_winners_admin_budget_path(@budget),
method: :put,
class: "button hollow float-right clear" %>
<% else %>
<span class="button hollow disabled float-right clear">
<%= t("admin.budgets.winners.calculate")%>
</span>
<div class="callout warning clear">
<%= t("admin.budget_investments.index.cannot_calculate_winners") %>
</div>
<% end %>
<% end %>
<% if @investments.any? %>
<h3 class="inline-block"><%= page_entries_info @investments %></h3><br>
@@ -134,7 +150,7 @@
<%= paginate @investments %>
<% else %>
<div class="callout primary">
<div class="callout primary clear">
<%= t("admin.budget_investments.index.no_budget_investments") %>
</div>
<% end %>