From 69f60432f24641aa0eed565c176fb09888a3a250 Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Wed, 18 Dec 2024 10:26:41 +0100 Subject: [PATCH] feat(referentiel): display referentiel columns --- .../drop_down_list_type_de_champ.rb | 17 +++++++++++++++++ 1 file changed, 17 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 4b905839739..6f3fe7640f7 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,4 +1,21 @@ # frozen_string_literal: true class TypesDeChamp::DropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBase + def columns(procedure:, displayable: true, prefix: nil) + if referentiel? + referentiel.headers.map do |header| + Columns::JSONPathColumn.new( + procedure_id: procedure.id, + stable_id:, + tdc_type: type_champ, + label: "#{libelle_with_prefix(prefix)} – Référentiel #{header}", + type: :text, + jsonpath: "$.referentiel.data.#{header.parameterize.underscore}", + displayable: + ) + end + else + super + end + end end