move filtering logic inside champ_column
This commit is contained in:
parent
055069755a
commit
9d976b8d95
2 changed files with 13 additions and 12 deletions
|
@ -31,6 +31,19 @@ class Columns::ChampColumn < Column
|
|||
end
|
||||
end
|
||||
|
||||
def filtered_ids(dossiers, search_terms)
|
||||
if type == :enum
|
||||
dossiers.with_type_de_champ(stable_id)
|
||||
.filter_enum(:champs, value_column, search_terms).ids
|
||||
elsif type == :enums
|
||||
dossiers.with_type_de_champ(stable_id)
|
||||
.filter_array_enum(:champs, value_column, search_terms).ids
|
||||
else
|
||||
dossiers.with_type_de_champ(stable_id)
|
||||
.filter_ilike(:champs, value_column, search_terms).ids
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def column_id = "type_de_champ/#{stable_id}"
|
||||
|
|
|
@ -74,7 +74,6 @@ class DossierFilterService
|
|||
.map do |(table, column), filters_for_column|
|
||||
values = filters_for_column.map(&:filter)
|
||||
filtered_column = filters_for_column.first.column
|
||||
value_column = filtered_column.value_column
|
||||
|
||||
if filtered_column.respond_to?(:filtered_ids)
|
||||
filtered_column.filtered_ids(dossiers, values)
|
||||
|
@ -93,17 +92,6 @@ class DossierFilterService
|
|||
else
|
||||
dossiers.where("dossiers.#{column} IN (?)", values)
|
||||
end
|
||||
when TYPE_DE_CHAMP
|
||||
if filtered_column.type == :enum
|
||||
dossiers.with_type_de_champ(column)
|
||||
.filter_enum(:champs, value_column, values)
|
||||
elsif filtered_column.type == :enums
|
||||
dossiers.with_type_de_champ(column)
|
||||
.filter_array_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