From ab965ff26d6c2435ab514145d32f21d6ea7d96a6 Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Mon, 16 Dec 2024 17:17:44 +0100 Subject: [PATCH] wip tableau instructeur --- app/models/champs/drop_down_list_champ.rb | 5 +++-- .../drop_down_list_type_de_champ.rb | 18 ++++++++++++++++++ .../types_de_champ/type_de_champ_base.rb | 2 +- .../instructeurs/procedures/show.html.haml | 3 ++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/models/champs/drop_down_list_champ.rb b/app/models/champs/drop_down_list_champ.rb index b7db545d48d..a7dff3abd63 100644 --- a/app/models/champs/drop_down_list_champ.rb +++ b/app/models/champs/drop_down_list_champ.rb @@ -48,7 +48,8 @@ def value=(value) def set_referentiel_from(value) referentiel_item = ReferentielItem.find(value) - { option: referentiel_item.option, data: referentiel_item.data } + # { option: referentiel_item.option, data: referentiel_item.data } + referentiel_item end def value_other=(value) @@ -76,7 +77,7 @@ def referentiel_item_data end def referentiel_item_option_value - referentiel_item_option.values.first + referentiel_item_option&.values&.first end private 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..8c5a0ea6691 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,22 @@ # frozen_string_literal: true class TypesDeChamp::DropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBase + + def columns(procedure:, displayable: true, prefix: nil) + if referentiel? + [ + Columns::JSONPathColumn.new( + procedure_id: procedure.id, + stable_id:, + tdc_type: type_champ, + label: "#{libelle_with_prefix(prefix)} – Référentiel", + type: :text, + jsonpath: '$.referentiel', + displayable: + ) + ] + else + super + end + end end 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 504cd63d925..4132e30fa7e 100644 --- a/app/models/types_de_champ/type_de_champ_base.rb +++ b/app/models/types_de_champ/type_de_champ_base.rb @@ -3,7 +3,7 @@ class TypesDeChamp::TypeDeChampBase include ActiveModel::Validations - delegate :description, :libelle, :mandatory, :mandatory?, :stable_id, :fillable?, :public?, :type_champ, :options_for_select, :drop_down_options, :referentiel_drop_down_options, :drop_down_other?, to: :@type_de_champ + delegate :description, :libelle, :mandatory, :mandatory?, :stable_id, :fillable?, :public?, :type_champ, :options_for_select, :drop_down_options, :referentiel_drop_down_options, :drop_down_other?, :referentiel?, to: :@type_de_champ FILL_DURATION_SHORT = 10.seconds FILL_DURATION_MEDIUM = 1.minute diff --git a/app/views/instructeurs/procedures/show.html.haml b/app/views/instructeurs/procedures/show.html.haml index 003f8a3cbe0..b1839022de6 100644 --- a/app/views/instructeurs/procedures/show.html.haml +++ b/app/views/instructeurs/procedures/show.html.haml @@ -147,7 +147,8 @@ = "- #{t("views.instructeurs.dossiers.deleted_reason.#{dossier.hidden_by_reason}")}" - else %a{ href: path } - = column.is_a?(Hash) ? tags_label(column[:value]) : column + -# = column.is_a?(Hash) ? tags_label(column[:value]) : column + = column = "- #{t("views.instructeurs.dossiers.deleted_reason.#{dossier.hidden_by_reason}")}" if dossier.hidden_by_user_at.present? %td