replaced helper has_html_label? with inheritance

This commit is contained in:
clemkeirua 2020-03-23 16:50:59 +01:00 committed by GitHub Action
parent 2ecb9cd5a2
commit 6d02e6e9e8
6 changed files with 18 additions and 9 deletions

View file

@ -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)

View file

@ -80,6 +80,10 @@ class Champ < ApplicationRecord
type_de_champ.to_typed_id
end
def html_label?
true
end
private
def needs_dossier_id?

View file

@ -1,2 +1,5 @@
class Champs::CiviliteChamp < Champ
def html_label?
false
end
end

View file

@ -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

View file

@ -51,4 +51,8 @@ class Champs::PieceJustificativeChamp < Champ
piece_justificative_file.service_url
end
end
def html_label?
false
end
end

View file

@ -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?