Skip to content

Commit

Permalink
wip display referentiel items from champ data
Browse files Browse the repository at this point in the history
  • Loading branch information
lisa-durand committed Dec 11, 2024
1 parent c4cc64d commit 0841d8b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 14 additions & 0 deletions app/models/champs/drop_down_list_champ.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions app/views/shared/champs/drop_down_list/_show.html.haml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 0841d8b

Please sign in to comment.