From 1b1fdd896eb2d550464cea51c50a8e82e4bc47cd Mon Sep 17 00:00:00 2001 From: Xinhui Date: Thu, 23 Mar 2017 12:30:16 +0100 Subject: Workbench#show remove current_organisation filter Refs #2918 --- app/controllers/workbenches_controller.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'app/controllers/workbenches_controller.rb') diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index 7f108b266..58fd507d4 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -7,9 +7,7 @@ class WorkbenchesController < BreadcrumbController def show scope = params[:q] ? resource.all_referentials : resource.referentials.ready scope = ransack_associated_lines(scope) - @q = ransack_periode(scope).ransack(params[:q]) - @q.organisation_name_eq_any ||= current_organisation.name unless params[:q] @wbench_refs = sort_result(@q.result).paginate(page: params[:page], per_page: 30) show! do build_breadcrumb :show -- cgit v1.2.3 From b29d19d3f5254c30a8660e9e8fbb93db3cb1d2cd Mon Sep 17 00:00:00 2001 From: Xinhui Date: Wed, 29 Mar 2017 16:05:38 +0200 Subject: Fix workbench filter form validity_period keep value after submit Refs #2994 --- app/controllers/workbenches_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/controllers/workbenches_controller.rb') diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index 58fd507d4..ecf70805d 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -66,7 +66,9 @@ class WorkbenchesController < BreadcrumbController if begin_range > end_range flash.now[:error] = t('referentials.errors.validity_period') else - scope = scope.in_periode(begin_range..end_range) + scope = scope.in_periode(begin_range..end_range) + @begin_range = begin_range + @end_range = end_range end scope end -- cgit v1.2.3 From e6083aa8e7a0d37c4100caec37fa65ae3232c4c1 Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Thu, 30 Mar 2017 17:14:07 +0200 Subject: Manage both archived_at_not_null and archived_at_null in WorkbenchesController#show (without ransack help). Refs #3013 --- app/controllers/workbenches_controller.rb | 41 ++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'app/controllers/workbenches_controller.rb') diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index ecf70805d..1424fe03c 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -5,10 +5,17 @@ class WorkbenchesController < BreadcrumbController respond_to :html, only: [:show] def show - scope = params[:q] ? resource.all_referentials : resource.referentials.ready + scope = resource.all_referentials scope = ransack_associated_lines(scope) - @q = ransack_periode(scope).ransack(params[:q]) - @wbench_refs = sort_result(@q.result).paginate(page: params[:page], per_page: 30) + scope = ransack_periode(scope) + scope = ransack_status(scope) + + # Ignore archived_at_not_null/archived_at_null managed by ransack_status scope + q_for_result = + scope.ransack(params[:q].merge(archived_at_not_null: nil, archived_at_null: nil)) + @wbench_refs = sort_result(q_for_result.result).paginate(page: params[:page], per_page: 30) + + @q = scope.ransack(params[:q]) show! do build_breadcrumb :show end @@ -42,6 +49,8 @@ class WorkbenchesController < BreadcrumbController def query_params if params[:q].present? params[:q].delete_if { |query, value| value.blank? } + else + params[:q] = { "archived_at_not_null"=>"1", "archived_at_null"=>"1" } end end @@ -72,4 +81,30 @@ class WorkbenchesController < BreadcrumbController end scope end + + # Fake (again) ransack filter + def ransack_status scope + return scope unless params[:q] + + archived_at_not_null = params[:q]['archived_at_not_null'] == '1' + archived_at_null = params[:q]['archived_at_null'] == '1' + + if !archived_at_not_null and !archived_at_null + return scope.none + end + + if archived_at_not_null and archived_at_null + return scope + end + + if archived_at_null + return scope.where(archived_at: nil) + end + + if archived_at_not_null + return scope.where("archived_at is not null") + end + + scope + end end -- cgit v1.2.3