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)
|
!types_without_label.include?(champ.type_champ)
|
||||||
end
|
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)
|
def geo_data(champ)
|
||||||
# rubocop:disable Rails/OutputSafety
|
# rubocop:disable Rails/OutputSafety
|
||||||
raw(champ.to_render_data.to_json)
|
raw(champ.to_render_data.to_json)
|
||||||
|
|
|
@ -80,6 +80,10 @@ class Champ < ApplicationRecord
|
||||||
type_de_champ.to_typed_id
|
type_de_champ.to_typed_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def html_label?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def needs_dossier_id?
|
def needs_dossier_id?
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
class Champs::CiviliteChamp < Champ
|
class Champs::CiviliteChamp < Champ
|
||||||
|
def html_label?
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,6 +13,10 @@ class Champs::DatetimeChamp < Champ
|
||||||
value.present? ? I18n.l(Time.zone.parse(value)) : ""
|
value.present? ? I18n.l(Time.zone.parse(value)) : ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def html_label?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def format_before_save
|
def format_before_save
|
||||||
|
|
|
@ -51,4 +51,8 @@ class Champs::PieceJustificativeChamp < Champ
|
||||||
piece_justificative_file.service_url
|
piece_justificative_file.service_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def html_label?
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
= # we do this trick because some html elements should use 'label' and some should be plain paragraphs
|
= # we do this trick because some html elements should use 'label' and some should be plain paragraphs
|
||||||
- if has_html_label?(champ)
|
- if champ.html_label?
|
||||||
%h4.form-label
|
= form.label champ.main_value_name do
|
||||||
= render partial: 'shared/dossiers/editable_champs/champ_label_content', locals: { champ: champ, seen_at: seen_at }
|
= render partial: 'shared/dossiers/editable_champs/champ_label_content', locals: { champ: champ, seen_at: seen_at }
|
||||||
- else
|
- 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 }
|
= render partial: 'shared/dossiers/editable_champs/champ_label_content', locals: { champ: champ, seen_at: seen_at }
|
||||||
|
|
||||||
- if champ.description.present?
|
- if champ.description.present?
|
||||||
|
|
Loading…
Reference in a new issue