From 3278b35729fce2db42c12922cad6f8c6a74890c5 Mon Sep 17 00:00:00 2001 From: behraaang Date: Sat, 10 Nov 2018 23:08:11 +0330 Subject: [PATCH 1/5] partial added, render an investment --- .gitignore | 1 + .../budget_investments/_investments.html.erb | 82 +------------------ .../_select_investment.html.erb | 81 ++++++++++++++++++ .../toggle_selection.js.erb | 2 +- 4 files changed, 84 insertions(+), 82 deletions(-) create mode 100644 app/views/admin/budget_investments/_select_investment.html.erb diff --git a/.gitignore b/.gitignore index 0413aaa36..c7ecd304f 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ public/sitemap.xml public/system/ /public/ckeditor_assets/ +.idea/ diff --git a/app/views/admin/budget_investments/_investments.html.erb b/app/views/admin/budget_investments/_investments.html.erb index a3a512366..81b46f9d3 100644 --- a/app/views/admin/budget_investments/_investments.html.erb +++ b/app/views/admin/budget_investments/_investments.html.erb @@ -57,87 +57,7 @@ <% @investments.each do |investment| %> - - <%= investment.id %> - - - <%= link_to investment.title, - admin_budget_budget_investment_path(budget_id: @budget.id, - id: investment.id, - params: Budget::Investment.filter_params(params)), - target: "_blank" %> - - - <%= investment.total_votes %> - - - <% if investment.administrator.present? %> - "> - <%= investment.administrator.name %> - - <% else %> - <%= t("admin.budget_investments.index.no_admin_assigned") %> - <% end %> - - - <% no_valuation_groups = t("admin.budget_investments.index.no_valuation_groups") %> - <%= investment.assigned_valuation_groups || no_valuation_groups %> -
- <% no_valuators_assigned = t("admin.budget_investments.index.no_valuators_assigned") %> - <%= investment.assigned_valuators || no_valuators_assigned %> - - - <%= investment.heading.name %> - - - <%= t("admin.budget_investments.index.feasibility.#{investment.feasibility}", - price: investment.formatted_price) %> - - - <%= investment.valuation_finished? ? t("shared.yes"): t("shared.no") %> - - - <%= form_for [:admin, investment.budget, investment], remote: true do |f| %> - <%= f.check_box :visible_to_valuators, - label: false, - class: "js-submit-on-change", - id: "budget_investment_visible_to_valuators" %> - <% end %> - - - <% 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], - sort_by: params[:sort_by], - min_total_supports: params[:min_total_supports], - advanced_filters: params[:advanced_filters], - 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], - sort_by: params[:sort_by], - min_total_supports: params[:min_total_supports], - advanced_filters: params[:advanced_filters], - page: params[:page]), - method: :patch, - remote: true, - class: "button small hollow expanded" %> - <% end %> - - <% if params[:filter] == "selected" %> - - <%= investment.incompatible? ? t("shared.yes"): t("shared.no") %> - - <% end %> + <%= render '/admin/budget_investments/select_investment', investment: investment %> <% end %> diff --git a/app/views/admin/budget_investments/_select_investment.html.erb b/app/views/admin/budget_investments/_select_investment.html.erb new file mode 100644 index 000000000..12bb5c5c8 --- /dev/null +++ b/app/views/admin/budget_investments/_select_investment.html.erb @@ -0,0 +1,81 @@ + + <%= investment.id %> + + + <%= link_to investment.title, + admin_budget_budget_investment_path(budget_id: @budget.id, + id: investment.id, + params: Budget::Investment.filter_params(params)), + target: "_blank" %> + + + <%= investment.total_votes %> + + + <% if investment.administrator.present? %> + "> + <%= investment.administrator.name %> + + <% else %> + <%= t("admin.budget_investments.index.no_admin_assigned") %> + <% end %> + + + <% no_valuation_groups = t("admin.budget_investments.index.no_valuation_groups") %> + <%= investment.assigned_valuation_groups || no_valuation_groups %> +
+ <% no_valuators_assigned = t("admin.budget_investments.index.no_valuators_assigned") %> + <%= investment.assigned_valuators || no_valuators_assigned %> + + + <%= investment.heading.name %> + + + <%= t("admin.budget_investments.index.feasibility.#{investment.feasibility}", + price: investment.formatted_price) %> + + + <%= investment.valuation_finished? ? t("shared.yes"): t("shared.no") %> + + + <%= form_for [:admin, investment.budget, investment], remote: true do |f| %> + <%= f.check_box :visible_to_valuators, + label: false, + class: "js-submit-on-change", + id: "budget_investment_visible_to_valuators" %> + <% end %> + + + <% 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], + sort_by: params[:sort_by], + min_total_supports: params[:min_total_supports], + advanced_filters: params[:advanced_filters], + 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], + sort_by: params[:sort_by], + min_total_supports: params[:min_total_supports], + advanced_filters: params[:advanced_filters], + page: params[:page]), + method: :patch, + remote: true, + class: "button small hollow expanded" %> + <% end %> + +<% if params[:filter] == "selected" %> + + <%= investment.incompatible? ? t("shared.yes"): t("shared.no") %> + +<% end %> diff --git a/app/views/admin/budget_investments/toggle_selection.js.erb b/app/views/admin/budget_investments/toggle_selection.js.erb index dc3a8d67a..3074847d6 100644 --- a/app/views/admin/budget_investments/toggle_selection.js.erb +++ b/app/views/admin/budget_investments/toggle_selection.js.erb @@ -1 +1 @@ -$("#investments").html('<%= j render("admin/budget_investments/investments") %>'); +$("#<%= dom_id(@investment) %>").html('<%= j render("select_investment", investment: @investment) %>'); From c7e94bb779a69a47a8e576e353d6da9b2b65d140 Mon Sep 17 00:00:00 2001 From: Behrang Mirzamani Date: Thu, 15 Nov 2018 22:51:58 +0330 Subject: [PATCH 2/5] Delete .gitignore --- .gitignore | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index c7ecd304f..000000000 --- a/.gitignore +++ /dev/null @@ -1,37 +0,0 @@ -# See https://help.github.com/articles/ignoring-files for more about ignoring files. -# -# If you find yourself ignoring temporary files generated by your text editor -# or operating system, you probably want to add a global ignore instead: -# git config --global core.excludesfile '~/.gitignore_global' - -# Ignore bundler config. -/.bundle - -# Ignore the default SQLite database. -/db/*.sqlite3 -/db/*.sqlite3-journal - -# Ignore all logfiles and tempfiles. -/log/* -!/log/.keep -/tmp - -/spec/examples.txt -/config/database.yml -/config/secrets.yml -/config/deploy-secrets.yml -/config/maintenance.yml - -/coverage - -/config/beta-testers.txt -.byebug_history - -# Mac finder artifacts -.DS_Store -.ruby-gemset - -public/sitemap.xml -public/system/ -/public/ckeditor_assets/ -.idea/ From 7a9888a793c5fae073cc0205825cdf6ab5f172df Mon Sep 17 00:00:00 2001 From: behraaang Date: Thu, 15 Nov 2018 23:30:08 +0330 Subject: [PATCH 3/5] Fix failed spec, add pagination spec for unselecting an investemnt --- spec/features/admin/budget_investments_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index 77c5480c4..9713959a1 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -1079,6 +1079,7 @@ feature 'Admin budget investments' do click_link('Selected') end + click_button('Filter') expect(page).not_to have_content(selected_bi.title) expect(page).to have_content('There is 1 investment') @@ -1089,6 +1090,20 @@ feature 'Admin budget investments' do expect(page).not_to have_link('Selected') end end + + scenario "Pagination after unselecting an investment", :js do + budget_investments = create_list(:budget_investment, 30, budget: budget) + + visit admin_budget_budget_investments_path(budget) + + within("#budget_investment_#{selected_bi.id}") do + click_link('Selected') + end + + click_link('Next') + + expect(page).to have_link('Previous') + end end context "Mark as visible to valuators" do From aecfc319cbad20e57151ee820687f0de8d82f07c Mon Sep 17 00:00:00 2001 From: behraaang Date: Thu, 15 Nov 2018 23:39:42 +0330 Subject: [PATCH 4/5] gitignore deleted mistakenly --- .gitignore | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..865001781 --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/* +!/log/.keep +/tmp + +/spec/examples.txt +/config/database.yml +/config/secrets.yml +/config/deploy-secrets.yml +/config/maintenance.yml + +/coverage + +/config/beta-testers.txt +.byebug_history + +# Mac finder artifacts +.DS_Store +.ruby-gemset + +public/sitemap.xml +public/system/ +/public/ckeditor_assets/ + From 88f01fb99905a1da78c645fdd323536c863119e4 Mon Sep 17 00:00:00 2001 From: behraaang Date: Fri, 16 Nov 2018 01:12:14 +0330 Subject: [PATCH 5/5] fix spec --- spec/features/admin/budget_investments_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index 9713959a1..384e2e54f 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -1092,7 +1092,7 @@ feature 'Admin budget investments' do end scenario "Pagination after unselecting an investment", :js do - budget_investments = create_list(:budget_investment, 30, budget: budget) + create_list(:budget_investment, 30, budget: budget) visit admin_budget_budget_investments_path(budget)