LinkedDropDownColumn is also a ChampColumn by the way

This commit is contained in:
simon lehericey 2024-10-31 18:34:30 +01:00
parent 9d6304e7d4
commit de8cad888e
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
2 changed files with 21 additions and 10 deletions

View file

@ -1,9 +1,15 @@
# frozen_string_literal: true
class Columns::LinkedDropDownColumn < Column
def column
return super if default_column?
"#{@column}->#{value_column}" # override column otherwise json path facets will have same id as other
class Columns::LinkedDropDownColumn < Columns::ChampColumn
def initialize(procedure_id:, label:, stable_id:, value_column:, displayable:, type: :text)
super(
procedure_id:,
label:,
stable_id:,
displayable:,
type:,
value_column:
)
end
def filtered_ids(dossiers, values)
@ -14,6 +20,14 @@ class Columns::LinkedDropDownColumn < Column
private
def column_id
if value_column == :value
"type_de_champ/#{stable_id}"
else
"type_de_champ/#{stable_id}->#{path}"
end
end
def typed_value(champ)
return nil if default_column?

View file

@ -75,17 +75,15 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
[
Columns::LinkedDropDownColumn.new(
procedure_id:,
table: Column::TYPE_DE_CHAMP_TABLE,
column: stable_id.to_s,
label: libelle_with_prefix(prefix),
stable_id: stable_id,
type: :text,
value_column: :value,
displayable:
),
Columns::LinkedDropDownColumn.new(
procedure_id:,
table: Column::TYPE_DE_CHAMP_TABLE,
column: stable_id.to_s,
stable_id:,
label: "#{libelle_with_prefix(prefix)} (Primaire)",
type: :enum,
value_column: :primary,
@ -93,8 +91,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
),
Columns::LinkedDropDownColumn.new(
procedure_id:,
table: Column::TYPE_DE_CHAMP_TABLE,
column: stable_id.to_s,
stable_id:,
label: "#{libelle_with_prefix(prefix)} (Secondaire)",
type: :enum,
value_column: :secondary,