2017-12-14 16:23:15 +01:00
|
|
|
module ChampHelper
|
2018-06-18 11:30:26 +02:00
|
|
|
def has_label?(champ)
|
2018-08-28 16:22:34 +02:00
|
|
|
types_without_label = [TypeDeChamp.type_champs.fetch(:header_section), TypeDeChamp.type_champs.fetch(:explication)]
|
2018-06-18 11:30:26 +02:00
|
|
|
!types_without_label.include?(champ.type_champ)
|
2017-12-14 16:23:15 +01:00
|
|
|
end
|
2018-10-17 12:07:25 +02:00
|
|
|
|
|
|
|
def geo_data(champ)
|
|
|
|
# rubocop:disable Rails/OutputSafety
|
2018-11-30 13:19:19 +01:00
|
|
|
raw(champ.to_render_data.to_json)
|
2018-10-17 12:07:25 +02:00
|
|
|
# rubocop:enable Rails/OutputSafety
|
|
|
|
end
|
2018-12-27 11:41:16 +01:00
|
|
|
|
|
|
|
def formatted_value(champ)
|
|
|
|
value = champ.value
|
|
|
|
type = champ.type_champ
|
|
|
|
|
|
|
|
if type == TypeDeChamp.type_champs.fetch(:date) && value.present?
|
|
|
|
Date.parse(value).strftime("%d/%m/%Y")
|
|
|
|
elsif type.in? [TypeDeChamp.type_champs.fetch(:checkbox), TypeDeChamp.type_champs.fetch(:engagement)]
|
|
|
|
value == 'on' ? 'Oui' : 'Non'
|
|
|
|
elsif type == TypeDeChamp.type_champs.fetch(:yes_no)
|
|
|
|
if value == 'true'
|
|
|
|
'Oui'
|
|
|
|
elsif value == 'false'
|
|
|
|
'Non'
|
|
|
|
end
|
|
|
|
elsif type == TypeDeChamp.type_champs.fetch(:multiple_drop_down_list) && value.present?
|
|
|
|
JSON.parse(value).join(', ')
|
|
|
|
else
|
|
|
|
value
|
|
|
|
end
|
|
|
|
end
|
2017-12-14 16:23:15 +01:00
|
|
|
end
|