diff --git a/app/models/columns/champ_column.rb b/app/models/columns/champ_column.rb index e60472284..2d6ee6c4a 100644 --- a/app/models/columns/champ_column.rb +++ b/app/models/columns/champ_column.rb @@ -3,8 +3,9 @@ class Columns::ChampColumn < Column attr_reader :stable_id - def initialize(procedure_id:, label:, stable_id:, displayable: true, filterable: true, type: :text, value_column: :value) + def initialize(procedure_id:, label:, stable_id:, tdc_type:, displayable: true, filterable: true, type: :text, value_column: :value) @stable_id = stable_id + @tdc_type = tdc_type super( procedure_id:, diff --git a/app/models/columns/json_path_column.rb b/app/models/columns/json_path_column.rb index 523b065ff..89e4e15f3 100644 --- a/app/models/columns/json_path_column.rb +++ b/app/models/columns/json_path_column.rb @@ -3,13 +3,14 @@ class Columns::JSONPathColumn < Columns::ChampColumn attr_reader :jsonpath - def initialize(procedure_id:, label:, stable_id:, jsonpath:, displayable:, type: :text) + def initialize(procedure_id:, label:, stable_id:, tdc_type:, jsonpath:, displayable:, type: :text) @jsonpath = quote_string(jsonpath) super( procedure_id:, label:, stable_id:, + tdc_type:, displayable:, type: ) diff --git a/app/models/columns/linked_drop_down_column.rb b/app/models/columns/linked_drop_down_column.rb index 2be2724d3..4530bf97f 100644 --- a/app/models/columns/linked_drop_down_column.rb +++ b/app/models/columns/linked_drop_down_column.rb @@ -3,13 +3,14 @@ class Columns::LinkedDropDownColumn < Columns::ChampColumn attr_reader :path - def initialize(procedure_id:, label:, stable_id:, path:, displayable:, type: :text) + def initialize(procedure_id:, label:, stable_id:, tdc_type:, path:, displayable:, type: :text) @path = path super( procedure_id:, label:, stable_id:, + tdc_type:, displayable:, type: ) diff --git a/app/models/concerns/addressable_column_concern.rb b/app/models/concerns/addressable_column_concern.rb index 23c80acb7..4f10b62b5 100644 --- a/app/models/concerns/addressable_column_concern.rb +++ b/app/models/concerns/addressable_column_concern.rb @@ -14,6 +14,7 @@ module AddressableColumnConcern Columns::JSONPathColumn.new( procedure_id:, stable_id:, + tdc_type: type_champ, label: "#{libelle_with_prefix(prefix)} – #{label}", jsonpath:, displayable:, diff --git a/app/models/types_de_champ/linked_drop_down_list_type_de_champ.rb b/app/models/types_de_champ/linked_drop_down_list_type_de_champ.rb index d50fa4121..cee354c02 100644 --- a/app/models/types_de_champ/linked_drop_down_list_type_de_champ.rb +++ b/app/models/types_de_champ/linked_drop_down_list_type_de_champ.rb @@ -76,7 +76,8 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas Columns::LinkedDropDownColumn.new( procedure_id:, label: libelle_with_prefix(prefix), - stable_id: stable_id, + stable_id:, + tdc_type: type_champ, type: :text, path: :value, displayable: @@ -84,6 +85,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas Columns::LinkedDropDownColumn.new( procedure_id:, stable_id:, + tdc_type: type_champ, label: "#{libelle_with_prefix(prefix)} (Primaire)", type: :enum, path: :primary, @@ -92,6 +94,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas Columns::LinkedDropDownColumn.new( procedure_id:, stable_id:, + tdc_type: type_champ, label: "#{libelle_with_prefix(prefix)} (Secondaire)", type: :enum, path: :secondary, diff --git a/app/models/types_de_champ/titre_identite_type_de_champ.rb b/app/models/types_de_champ/titre_identite_type_de_champ.rb index bb8e31785..02cd74fb6 100644 --- a/app/models/types_de_champ/titre_identite_type_de_champ.rb +++ b/app/models/types_de_champ/titre_identite_type_de_champ.rb @@ -29,6 +29,7 @@ class TypesDeChamp::TitreIdentiteTypeDeChamp < TypesDeChamp::TypeDeChampBase Columns::TitreIdentiteColumn.new( procedure_id:, stable_id:, + tdc_type: type_champ, label: libelle_with_prefix(prefix), type: TypeDeChamp.column_type(type_champ), value_column: TypeDeChamp.value_column(type_champ), diff --git a/app/models/types_de_champ/type_de_champ_base.rb b/app/models/types_de_champ/type_de_champ_base.rb index ec5940e2a..2c81fc430 100644 --- a/app/models/types_de_champ/type_de_champ_base.rb +++ b/app/models/types_de_champ/type_de_champ_base.rb @@ -100,7 +100,8 @@ class TypesDeChamp::TypeDeChampBase [ Columns::ChampColumn.new( procedure_id:, - stable_id: stable_id, + stable_id:, + tdc_type: type_champ, label: libelle_with_prefix(prefix), type: TypeDeChamp.column_type(type_champ), value_column: TypeDeChamp.value_column(type_champ), diff --git a/spec/models/columns/json_path_column_spec.rb b/spec/models/columns/json_path_column_spec.rb index 0da283764..062da2e57 100644 --- a/spec/models/columns/json_path_column_spec.rb +++ b/spec/models/columns/json_path_column_spec.rb @@ -5,7 +5,8 @@ describe Columns::JSONPathColumn do let(:dossier) { create(:dossier, procedure:) } let(:champ) { dossier.champs.first } let(:stable_id) { champ.stable_id } - let(:column) { described_class.new(procedure_id: procedure.id, label: 'label', stable_id:, jsonpath:, displayable: true) } + let(:tdc_type) { champ.type_champ } + let(:column) { described_class.new(procedure_id: procedure.id, label: 'label', stable_id:, tdc_type:, jsonpath:, displayable: true) } describe '#value' do let(:jsonpath) { '$.city_name' }