diff --git a/app/models/champs/drop_down_list_champ.rb b/app/models/champs/drop_down_list_champ.rb index 647b5ba6054..cd82c045fb7 100644 --- a/app/models/champs/drop_down_list_champ.rb +++ b/app/models/champs/drop_down_list_champ.rb @@ -66,6 +66,20 @@ def in?(options) options.include?(value) end + def referentiel_item_option + return nil if self.data.nil? + self.data.fetch("option") + end + + def referentiel_item_data + return nil if self.data.nil? + self.data.fetch("data") + end + + def referentiel_item_option_value + referentiel_item_option.values.first + end + private def value_is_in_options diff --git a/app/views/shared/champs/drop_down_list/_show.html.haml b/app/views/shared/champs/drop_down_list/_show.html.haml index c04a052c6dc..a9f71829781 100644 --- a/app/views/shared/champs/drop_down_list/_show.html.haml +++ b/app/views/shared/champs/drop_down_list/_show.html.haml @@ -1,16 +1,14 @@ -- referentiel_item = champ.referentiel_item - -- if champ.referentiel? && referentiel_item&.option.present? +- if champ.referentiel? && champ.referentiel_item_option.present? - if current_user.instructeur? && !current_user.owns_or_invite?(champ.dossier) .fr-background-alt--grey.fr-p-3v - - referentiel_item.option.merge(referentiel_item.data).each do |key, value| + - champ.referentiel_item_option.merge(champ.referentiel_item_data).each do |key, value| - if key.present? = render Dossiers::RowShowComponent.new(label: key) do |c| - c.with_value do %p= value - else - %p= referentiel_item.option[referentiel_item.option.keys.first] + %p= champ.referentiel_item_option_value - elsif champ.used_by_routing_rules? && champ.dossier.forced_groupe_instructeur %p