you know what ? value_column is a column
This commit is contained in:
parent
8599dd829a
commit
aa8ce15c2a
2 changed files with 8 additions and 8 deletions
|
@ -6,11 +6,12 @@ class Columns::ChampColumn < Column
|
||||||
def initialize(procedure_id:, label:, stable_id:, tdc_type:, displayable: true, filterable: true, type: :text, options_for_select: [])
|
def initialize(procedure_id:, label:, stable_id:, tdc_type:, displayable: true, filterable: true, type: :text, options_for_select: [])
|
||||||
@stable_id = stable_id
|
@stable_id = stable_id
|
||||||
@tdc_type = tdc_type
|
@tdc_type = tdc_type
|
||||||
|
column = tdc_type.in?(['departements', 'regions']) ? :external_id : :value
|
||||||
|
|
||||||
super(
|
super(
|
||||||
procedure_id:,
|
procedure_id:,
|
||||||
table: 'type_de_champ',
|
table: 'type_de_champ',
|
||||||
column: stable_id.to_s,
|
column:,
|
||||||
label:,
|
label:,
|
||||||
type:,
|
type:,
|
||||||
displayable:,
|
displayable:,
|
||||||
|
@ -33,13 +34,13 @@ class Columns::ChampColumn < Column
|
||||||
def filtered_ids(dossiers, search_terms)
|
def filtered_ids(dossiers, search_terms)
|
||||||
if type == :enum
|
if type == :enum
|
||||||
dossiers.with_type_de_champ(stable_id)
|
dossiers.with_type_de_champ(stable_id)
|
||||||
.filter_enum(:champs, value_column, search_terms).ids
|
.filter_enum(:champs, column, search_terms).ids
|
||||||
elsif type == :enums
|
elsif type == :enums
|
||||||
dossiers.with_type_de_champ(stable_id)
|
dossiers.with_type_de_champ(stable_id)
|
||||||
.filter_array_enum(:champs, value_column, search_terms).ids
|
.filter_array_enum(:champs, column, search_terms).ids
|
||||||
else
|
else
|
||||||
dossiers.with_type_de_champ(stable_id)
|
dossiers.with_type_de_champ(stable_id)
|
||||||
.filter_ilike(:champs, value_column, search_terms).ids
|
.filter_ilike(:champs, column, search_terms).ids
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,9 +48,7 @@ class Columns::ChampColumn < Column
|
||||||
|
|
||||||
def column_id = "type_de_champ/#{stable_id}"
|
def column_id = "type_de_champ/#{stable_id}"
|
||||||
|
|
||||||
def value_column = @tdc_type.in?(['departements', 'regions']) ? :external_id : :value
|
def string_value(champ) = champ.public_send(column)
|
||||||
|
|
||||||
def string_value(champ) = champ.public_send(value_column)
|
|
||||||
|
|
||||||
def typed_value(champ)
|
def typed_value(champ)
|
||||||
value = string_value(champ)
|
value = string_value(champ)
|
||||||
|
|
|
@ -32,8 +32,9 @@ class DossierFilterService
|
||||||
dossiers_id_with_notification
|
dossiers_id_with_notification
|
||||||
end
|
end
|
||||||
when TYPE_DE_CHAMP
|
when TYPE_DE_CHAMP
|
||||||
|
stable_id = sorted_column.column.stable_id
|
||||||
ids = dossiers
|
ids = dossiers
|
||||||
.with_type_de_champ(column)
|
.with_type_de_champ(stable_id)
|
||||||
.order("champs.value #{order}")
|
.order("champs.value #{order}")
|
||||||
.pluck(:id)
|
.pluck(:id)
|
||||||
if ids.size != count
|
if ids.size != count
|
||||||
|
|
Loading…
Reference in a new issue