From aec136ed98f1b50c95b4061c42a7557fe4113f98 Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Tue, 17 Dec 2024 19:26:30 +0100 Subject: [PATCH] feat(export): can export dossier with referentiel values --- .../drop_down_list_type_de_champ.rb | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) 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..17ebfbbc214 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.present? + 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