From 58158938cb24cf1f327fc1d800a2d0195b59e57e Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Wed, 13 Feb 2019 17:50:33 +0100 Subject: [PATCH] [#3477] Extract helper --- .../new_gestionnaire/procedures_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index 8e15b44d2..708dd6f6d 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -112,7 +112,7 @@ module NewGestionnaire procedure_presentation.update(displayed_fields: fields) current_sort = procedure_presentation.sort - if !values.include?("#{current_sort['table']}/#{current_sort['column']}") + if !values.include?(field_id(current_sort)) procedure_presentation.update(sort: Procedure.default_sort) end @@ -194,6 +194,10 @@ module NewGestionnaire private + def field_id(field) + "#{field['table']}/#{field['column']}" + end + def statut @statut ||= (params[:statut].presence || 'a-suivre') end @@ -228,9 +232,7 @@ module NewGestionnaire end def displayed_fields_values - procedure_presentation.displayed_fields.map do |field| - "#{field['table']}/#{field['column']}" - end + procedure_presentation.displayed_fields.map { |field| field_id(field) } end def current_filters