diff --git a/app/models/types_de_champ/drop_down_list_type_de_champ.rb b/app/models/types_de_champ/drop_down_list_type_de_champ.rb index 6f3fe7640f7..584a2d930da 100644 --- a/app/models/types_de_champ/drop_down_list_type_de_champ.rb +++ b/app/models/types_de_champ/drop_down_list_type_de_champ.rb @@ -1,6 +1,14 @@ # frozen_string_literal: true class TypesDeChamp::DropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBase + def champ_value_for_export(champ, path = :value) + if referentiel? && path != :value + champ.referentiel_item_data&.dig(path) + else + champ.value + end + end + def columns(procedure:, displayable: true, prefix: nil) if referentiel? referentiel.headers.map do |header| @@ -18,4 +26,21 @@ def columns(procedure:, displayable: true, prefix: nil) super end end + + def paths + paths = [] + if referentiel? + referentiel.headers.each do |header| + paths.push({ + libelle: "#{libelle} (#{header})", + description: "#{description} (#{header})", + path: header.parameterize.underscore, + maybe_null: public? && !mandatory? + }) + end + paths + else + super + end + end end