move add_filter
This commit is contained in:
parent
e3ee756da4
commit
4241ea05f3
2 changed files with 4 additions and 7 deletions
|
@ -150,9 +150,7 @@ module Instructeurs
|
|||
end
|
||||
|
||||
def add_filter
|
||||
if params[:value].present?
|
||||
procedure_presentation.add_filter(statut, params[:field], params[:value])
|
||||
end
|
||||
|
||||
redirect_back(fallback_location: instructeur_procedure_url(procedure))
|
||||
end
|
||||
|
|
|
@ -197,16 +197,15 @@ class ProcedurePresentation < ApplicationRecord
|
|||
|
||||
def add_filter(statut, field, value)
|
||||
if value.present?
|
||||
updated_filters = self.filters
|
||||
table, column = field.split('/')
|
||||
label = find_field(table, column)['label']
|
||||
|
||||
case table
|
||||
when 'type_de_champ', 'type_de_champ_private'
|
||||
type_de_champ = TypeDeChamp.find_by(id: column)
|
||||
value = type_de_champ.dynamic_type.human_to_filter(value)
|
||||
value = find_type_de_champ(column).dynamic_type.human_to_filter(value)
|
||||
end
|
||||
|
||||
updated_filters = filters.dup
|
||||
updated_filters[statut] << {
|
||||
'label' => label,
|
||||
'table' => table,
|
||||
|
@ -214,7 +213,7 @@ class ProcedurePresentation < ApplicationRecord
|
|||
'value' => value
|
||||
}
|
||||
|
||||
update(filters: updated_filters)
|
||||
update!(filters: updated_filters)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue