aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/workbenches_controller.rb
diff options
context:
space:
mode:
authorXinhui2017-07-03 17:15:49 +0200
committerXinhui2017-07-03 17:15:49 +0200
commit433c498ac44aac684f0165265e3da437cafa3243 (patch)
tree725c097f40a6948e10671068369c8fb852c50e98 /app/controllers/workbenches_controller.rb
parentadc8e323d6f76baf50d649b47bf83f08468681c0 (diff)
downloadchouette-core-433c498ac44aac684f0165265e3da437cafa3243.tar.bz2
Workbench#show filtering restore q_for_result
Diffstat (limited to 'app/controllers/workbenches_controller.rb')
-rw-r--r--app/controllers/workbenches_controller.rb29
1 files changed, 15 insertions, 14 deletions
diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb
index a53e21269..30b98eec0 100644
--- a/app/controllers/workbenches_controller.rb
+++ b/app/controllers/workbenches_controller.rb
@@ -10,20 +10,10 @@ class WorkbenchesController < BreadcrumbController
scope = ransack_periode(scope)
scope = ransack_status(scope)
- # Ignore archived_at_not_null/archived_at_null managed by ransack_status scope
- # We clone params[:q] so we can delete fake ransack filter arguments before calling search method,
- # which will allow us to preserve params[:q] for sorting
- ransack_params = params[:q].clone
- ransack_params.delete('associated_lines_id_eq')
- ransack_params.delete('archived_at_not_null')
- ransack_params.delete('archived_at_null')
-
- @q = scope.ransack(ransack_params)
- @wbench_refs = sort_result(@q.result).paginate(page: params[:page], per_page: 30)
- @wbench_refs = ModelDecorator.decorate(
- @wbench_refs,
- with: ReferentialDecorator
- )
+ @q_for_form = scope.ransack(params[:q])
+ @q_for_result = scope.ransack(ransack_params)
+ @wbench_refs = sort_result(@q_for_result.result).paginate(page: params[:page], per_page: 30)
+ @wbench_refs = ModelDecorator.decorate(@wbench_refs, with: ReferentialDecorator)
show! do
build_breadcrumb :show
@@ -101,4 +91,15 @@ class WorkbenchesController < BreadcrumbController
scope = scope.where("archived_at is not null") if archived
scope
end
+
+ # Ignore archived_at_not_null/archived_at_null managed by ransack_status scope
+ # We clone params[:q] so we can delete fake ransack filter arguments before calling search method,
+ # which will allow us to preserve params[:q] for sorting
+ def ransack_params
+ copy_params = params[:q].clone
+ copy_params.delete('associated_lines_id_eq')
+ copy_params.delete('archived_at_not_null')
+ copy_params.delete('archived_at_null')
+ copy_params
+ end
end