fix(filter): filtering types_de_champs by enum should not ilike. nows it search by exact match since enum are normalized so findable with simple where
This commit is contained in:
parent
1339e10280
commit
75063ae31e
2 changed files with 13 additions and 2 deletions
|
@ -33,5 +33,11 @@ module DossierFilteringConcern
|
|||
q = Array.new(values.count, "(#{table_column} ILIKE ?)").join(' OR ')
|
||||
where(q, *(values.map { |value| "%#{value}%" }))
|
||||
}
|
||||
|
||||
scope :filter_enum, lambda { |table, column, values|
|
||||
table_column = ProcedurePresentation.sanitized_column(table, column)
|
||||
q = Array.new(values.count, "(#{table_column} = ?)").join(' OR ')
|
||||
where(q, *(values))
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -220,8 +220,13 @@ class ProcedurePresentation < ApplicationRecord
|
|||
dossiers.where("dossiers.#{column} IN (?)", values)
|
||||
end
|
||||
when TYPE_DE_CHAMP
|
||||
dossiers.with_type_de_champ(column)
|
||||
.filter_ilike(:champs, value_column, values)
|
||||
if dossier_column.type == :enum
|
||||
dossiers.with_type_de_champ(column)
|
||||
.filter_enum(:champs, value_column, values)
|
||||
else
|
||||
dossiers.with_type_de_champ(column)
|
||||
.filter_ilike(:champs, value_column, values)
|
||||
end
|
||||
when 'etablissement'
|
||||
if column == 'entreprise_date_creation'
|
||||
dates = values
|
||||
|
|
Loading…
Reference in a new issue