@@ -6,26 +6,6 @@ module BudgetsHelper
|
||||
csv_params
|
||||
end
|
||||
|
||||
def investment_selected_link(investment)
|
||||
options = investment_selected_link_options(investment)
|
||||
path = toggle_selection_admin_budget_budget_investment_path(@budget,
|
||||
investment, filter: params[:filter], page: params[:page])
|
||||
link_options = {method: :patch, remote: true, class: options[:link_class]}
|
||||
link_to options[:text], path, link_options
|
||||
end
|
||||
|
||||
def investment_selected_link_options(investment)
|
||||
if investment.selected?
|
||||
{link_class: "button small expanded",
|
||||
text: t("admin.budget_investments.index.selected") }
|
||||
elsif investment.feasible? && investment.valuation_finished?
|
||||
{link_class: "button small hollow expanded",
|
||||
text: t("admin.budget_investments.index.select")}
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
def budget_phases_select_options
|
||||
Budget::PHASES.map { |ph| [ t("budgets.phase.#{ph}"), ph ] }
|
||||
end
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<div class='relative'>
|
||||
<%= link_to 'download current selecction',admin_budget_budget_investments_path(csv_params), class: 'advanced-search small' %>
|
||||
<%= link_to t("admin.budget_investments.index.download_current_selection"),
|
||||
admin_budget_budget_investments_path(csv_params),
|
||||
class: 'advanced-search small' %>
|
||||
|
||||
<h3><%= page_entries_info @investments %></h3>
|
||||
</div>
|
||||
|
||||
@@ -27,14 +30,19 @@
|
||||
<strong><%= investment.id %></strong>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to investment.title, admin_budget_budget_investment_path(budget_id: @budget.id, id: investment.id, params: Budget::Investment.filter_params(params)) %>
|
||||
<%= link_to investment.title,
|
||||
admin_budget_budget_investment_path(budget_id: @budget.id,
|
||||
id: investment.id,
|
||||
params: Budget::Investment.filter_params(params)) %>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<%= investment.total_votes %>
|
||||
</td>
|
||||
<td class="small">
|
||||
<% if investment.administrator.present? %>
|
||||
<span title="<%= t('admin.budget_investments.index.assigned_admin') %>"><%= investment.administrator.name %></span>
|
||||
<span title="<%= t('admin.budget_investments.index.assigned_admin') %>">
|
||||
<%= investment.administrator.name %>
|
||||
</span>
|
||||
<% else %>
|
||||
<%= t("admin.budget_investments.index.no_admin_assigned") %>
|
||||
<% end %>
|
||||
@@ -58,7 +66,27 @@
|
||||
<%= investment.valuation_finished? ? t('shared.yes'): t('shared.no') %>
|
||||
</td>
|
||||
<td class="small">
|
||||
<%= investment_selected_link(investment) %>
|
||||
<% if investment.selected? %>
|
||||
<%= link_to_unless investment.budget.finished?,
|
||||
t("admin.budget_investments.index.selected"),
|
||||
toggle_selection_admin_budget_budget_investment_path(@budget,
|
||||
investment,
|
||||
filter: params[:filter],
|
||||
page: params[:page]),
|
||||
method: :patch,
|
||||
remote: true,
|
||||
class: "button small expanded" %>
|
||||
<% elsif investment.feasible? && investment.valuation_finished? %>
|
||||
<%= link_to_unless investment.budget.finished?,
|
||||
t("admin.budget_investments.index.select"),
|
||||
toggle_selection_admin_budget_budget_investment_path(@budget,
|
||||
investment,
|
||||
filter: params[:filter],
|
||||
page: params[:page]),
|
||||
method: :patch,
|
||||
remote: true,
|
||||
class: "button small hollow expanded" %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% if params[:filter] == 'selected' %>
|
||||
<td class="small text-center">
|
||||
|
||||
@@ -138,6 +138,7 @@ en:
|
||||
undecided: "Undecided"
|
||||
selected: "Selected"
|
||||
select: "Select"
|
||||
download_current_selection: "Download current selection"
|
||||
table_id: "ID"
|
||||
table_title: "Title"
|
||||
table_supports: "Supports"
|
||||
|
||||
@@ -139,6 +139,7 @@ es:
|
||||
undecided: "Sin decidir"
|
||||
selected: "Seleccionada"
|
||||
select: "Seleccionar"
|
||||
download_current_selection: "Descargar selección actual"
|
||||
table_id: "ID"
|
||||
table_title: "Título"
|
||||
table_supports: "Apoyos"
|
||||
|
||||
@@ -639,7 +639,10 @@ feature 'Admin budget investments' do
|
||||
admin = create(:administrator, user: create(:user, username: 'Gema'))
|
||||
investment.update(administrator_id: admin.id)
|
||||
|
||||
visit admin_budget_budget_investments_path(@budget, format: :csv)
|
||||
visit admin_budget_budget_investments_path(@budget)
|
||||
within('#filter-subnav') { click_link 'All' }
|
||||
|
||||
click_link "Download current selection"
|
||||
|
||||
header = page.response_headers['Content-Disposition']
|
||||
expect(header).to match(/^attachment/)
|
||||
@@ -666,8 +669,11 @@ feature 'Admin budget investments' do
|
||||
title: 'compatible')
|
||||
investment2 = create(:budget_investment, :finished, budget: @budget,
|
||||
title: 'finished')
|
||||
visit admin_budget_budget_investments_path(@budget, format: :csv,
|
||||
filter: :valuation_finished)
|
||||
|
||||
visit admin_budget_budget_investments_path(@budget)
|
||||
within('#filter-subnav') { click_link 'Valuation finished' }
|
||||
|
||||
click_link "Download current selection"
|
||||
|
||||
header = page.response_headers['Content-Disposition']
|
||||
header.should match(/^attachment/)
|
||||
|
||||
Reference in New Issue
Block a user