replaced helper has_html_label? with inheritance
This commit is contained in:
parent
2ecb9cd5a2
commit
6d02e6e9e8
6 changed files with 18 additions and 9 deletions
|
@ -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)
|
||||
|
|
|
@ -80,6 +80,10 @@ class Champ < ApplicationRecord
|
|||
type_de_champ.to_typed_id
|
||||
end
|
||||
|
||||
def html_label?
|
||||
true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def needs_dossier_id?
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
class Champs::CiviliteChamp < Champ
|
||||
def html_label?
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -51,4 +51,8 @@ class Champs::PieceJustificativeChamp < Champ
|
|||
piece_justificative_file.service_url
|
||||
end
|
||||
end
|
||||
|
||||
def html_label?
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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?
|
||||
|
|
Loading…
Reference in a new issue