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
|
2019-02-19 16:14:42 +01:00
|
|
|
|
|
|
|
def champ_carte_params(champ)
|
|
|
|
if champ.persisted?
|
|
|
|
{ champ_id: champ.id }
|
|
|
|
else
|
|
|
|
{ type_de_champ_id: champ.type_de_champ_id }
|
|
|
|
end
|
|
|
|
end
|
2019-09-26 17:40:52 +02:00
|
|
|
|
|
|
|
def format_text_value(text)
|
|
|
|
sanitized_text = sanitize(text)
|
|
|
|
auto_linked_text = Anchored::Linker.auto_link(sanitized_text, target: '_blank', rel: 'noopener') do |link_href|
|
|
|
|
truncate(link_href, length: 60)
|
|
|
|
end
|
|
|
|
simple_format(auto_linked_text, {}, sanitize: false)
|
|
|
|
end
|
2019-11-20 20:47:36 +01:00
|
|
|
|
|
|
|
def describedby_id(champ)
|
|
|
|
if champ.description.present?
|
|
|
|
"desc-#{champ.type_de_champ.id}-#{champ.row}"
|
|
|
|
end
|
|
|
|
end
|
2017-12-14 16:23:15 +01:00
|
|
|
end
|