aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorXinhui2017-07-03 17:15:49 +0200
committerXinhui2017-07-03 17:15:49 +0200
commit433c498ac44aac684f0165265e3da437cafa3243 (patch)
tree725c097f40a6948e10671068369c8fb852c50e98 /app
parentadc8e323d6f76baf50d649b47bf83f08468681c0 (diff)
downloadchouette-core-433c498ac44aac684f0165265e3da437cafa3243.tar.bz2
Workbench#show filtering restore q_for_result
Diffstat (limited to 'app')
-rw-r--r--app/controllers/workbenches_controller.rb29
-rw-r--r--app/views/workbenches/_filters.html.slim2
2 files changed, 16 insertions, 15 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
diff --git a/app/views/workbenches/_filters.html.slim b/app/views/workbenches/_filters.html.slim
index 4eaf910c0..d7ac79577 100644
--- a/app/views/workbenches/_filters.html.slim
+++ b/app/views/workbenches/_filters.html.slim
@@ -1,4 +1,4 @@
-= search_form_for @q, url: workbench_path(@workbench.id), builder: SimpleForm::FormBuilder, class: 'form form-filter' do |f|
+= search_form_for @q_for_form, url: workbench_path(@workbench.id), builder: SimpleForm::FormBuilder, class: 'form form-filter' do |f|
.ffg-row
.input-group.search_bar
= f.search_field :name_cont, class: 'form-control', placeholder: 'Indiquez un nom de référentiel...'