diff options
| author | Xinhui | 2017-07-03 17:15:49 +0200 |
|---|---|---|
| committer | Xinhui | 2017-07-03 17:15:49 +0200 |
| commit | 433c498ac44aac684f0165265e3da437cafa3243 (patch) | |
| tree | 725c097f40a6948e10671068369c8fb852c50e98 /app/controllers/workbenches_controller.rb | |
| parent | adc8e323d6f76baf50d649b47bf83f08468681c0 (diff) | |
| download | chouette-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.rb | 29 |
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 |
