Skip to content

Commit

Permalink
feat(export): can export dossier with referentiel values
Browse files Browse the repository at this point in the history
  • Loading branch information
E-L-T committed Dec 20, 2024
1 parent 69f6043 commit aec136e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app/models/types_de_champ/drop_down_list_type_de_champ.rb
Original file line number Diff line number Diff line change
@@ -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|
Expand All @@ -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

0 comments on commit aec136e

Please sign in to comment.