diff --git a/app/helpers/champ_helper.rb b/app/helpers/champ_helper.rb index 67c50e4c9..a31ca1b58 100644 --- a/app/helpers/champ_helper.rb +++ b/app/helpers/champ_helper.rb @@ -4,12 +4,6 @@ module ChampHelper !types_without_label.include?(champ.type_champ) end - def has_html_label?(champ) - types_with_no_html_label = [TypeDeChamp.type_champs.fetch(:civilite), TypeDeChamp.type_champs.fetch(:yes_no), TypeDeChamp.type_champs.fetch(:datetime), TypeDeChamp.type_champs.fetch(:piece_justificative) - ] - types_with_no_html_label.include?(champ.type_champ) - end - def geo_data(champ) # rubocop:disable Rails/OutputSafety raw(champ.to_render_data.to_json) diff --git a/app/models/champ.rb b/app/models/champ.rb index 69c6303e3..35936912b 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -80,6 +80,10 @@ class Champ < ApplicationRecord type_de_champ.to_typed_id end + def html_label? + true + end + private def needs_dossier_id? diff --git a/app/models/champs/civilite_champ.rb b/app/models/champs/civilite_champ.rb index 9404e46a1..600a2c032 100644 --- a/app/models/champs/civilite_champ.rb +++ b/app/models/champs/civilite_champ.rb @@ -1,2 +1,5 @@ class Champs::CiviliteChamp < Champ + def html_label? + false + end end diff --git a/app/models/champs/datetime_champ.rb b/app/models/champs/datetime_champ.rb index 84008894b..7f09acee1 100644 --- a/app/models/champs/datetime_champ.rb +++ b/app/models/champs/datetime_champ.rb @@ -13,6 +13,10 @@ class Champs::DatetimeChamp < Champ value.present? ? I18n.l(Time.zone.parse(value)) : "" end + def html_label? + false + end + private def format_before_save diff --git a/app/models/champs/piece_justificative_champ.rb b/app/models/champs/piece_justificative_champ.rb index 35403deb6..431a86e94 100644 --- a/app/models/champs/piece_justificative_champ.rb +++ b/app/models/champs/piece_justificative_champ.rb @@ -51,4 +51,8 @@ class Champs::PieceJustificativeChamp < Champ piece_justificative_file.service_url end end + + def html_label? + false + end end diff --git a/app/views/shared/dossiers/editable_champs/_champ_label.html.haml b/app/views/shared/dossiers/editable_champs/_champ_label.html.haml index 838746400..737846f64 100644 --- a/app/views/shared/dossiers/editable_champs/_champ_label.html.haml +++ b/app/views/shared/dossiers/editable_champs/_champ_label.html.haml @@ -1,9 +1,9 @@ = # we do this trick because some html elements should use 'label' and some should be plain paragraphs -- if has_html_label?(champ) - %h4.form-label +- if champ.html_label? + = form.label champ.main_value_name do = render partial: 'shared/dossiers/editable_champs/champ_label_content', locals: { champ: champ, seen_at: seen_at } - else - = form.label champ.main_value_name do + %h4.form-label = render partial: 'shared/dossiers/editable_champs/champ_label_content', locals: { champ: champ, seen_at: seen_at } - if champ.description.present?