From eda673a85d115c6834cbd475987aa33039af0529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Wed, 10 Jan 2018 11:57:13 +0100 Subject: [PATCH 1/5] Restored missing code --- .../budget_investments/_investments.html.erb | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/views/admin/budget_investments/_investments.html.erb b/app/views/admin/budget_investments/_investments.html.erb index 75bde7002..594ef5cf0 100644 --- a/app/views/admin/budget_investments/_investments.html.erb +++ b/app/views/admin/budget_investments/_investments.html.erb @@ -58,7 +58,25 @@ <%= investment.valuation_finished? ? t('shared.yes'): t('shared.no') %> - <%= 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 %> <% if params[:filter] == 'selected' %> From a06abf7650e88be59c2df0203fdd312555b10230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Wed, 10 Jan 2018 11:57:23 +0100 Subject: [PATCH 2/5] Removed unnecessary code --- app/helpers/budgets_helper.rb | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index a14b86538..d2d6e1f5d 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -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 From bc363289ad84736f01bd4b48b10845cd6b87865c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Wed, 10 Jan 2018 12:19:48 +0100 Subject: [PATCH 3/5] Added translations to link text --- app/views/admin/budget_investments/_investments.html.erb | 5 ++++- config/locales/en/admin.yml | 1 + config/locales/es/admin.yml | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/views/admin/budget_investments/_investments.html.erb b/app/views/admin/budget_investments/_investments.html.erb index 594ef5cf0..c23f8a45c 100644 --- a/app/views/admin/budget_investments/_investments.html.erb +++ b/app/views/admin/budget_investments/_investments.html.erb @@ -1,5 +1,8 @@
- <%= 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' %> +

<%= page_entries_info @investments %>

diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 0d83e824b..0045f0991 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -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" diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 456b78ab3..ff886a02d 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -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" From 02f7e423fea3198f3f0bad7b95ea0622599f7720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Wed, 10 Jan 2018 13:03:52 +0100 Subject: [PATCH 4/5] Improved tests --- spec/features/admin/budget_investments_spec.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index c3fc69473..aab577f4a 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -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/) From 760b7ca4c85cb3ff0c2df9ff8d65440fd482a7f7 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 10 Jan 2018 13:37:03 +0100 Subject: [PATCH 5/5] Fix indentations and lines lenght --- .../budget_investments/_investments.html.erb | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/app/views/admin/budget_investments/_investments.html.erb b/app/views/admin/budget_investments/_investments.html.erb index c23f8a45c..0299b6149 100644 --- a/app/views/admin/budget_investments/_investments.html.erb +++ b/app/views/admin/budget_investments/_investments.html.erb @@ -30,14 +30,19 @@ <%= investment.id %> - <%= 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)) %> <%= investment.total_votes %> <% if investment.administrator.present? %> - <%= investment.administrator.name %> + + <%= investment.administrator.name %> + <% else %> <%= t("admin.budget_investments.index.no_admin_assigned") %> <% end %> @@ -62,23 +67,25 @@ <% 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" %> + <%= 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" %> + <%= 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 %> <% if params[:filter] == 'selected' %>