demarches-normaliennes/app/helpers/champ_helper.rb

19 lines
702 B
Ruby
Raw Normal View History

module ChampHelper
def has_label?(champ)
types_without_label = [TypeDeChamp.type_champs.fetch(:header_section), TypeDeChamp.type_champs.fetch(:explication)]
!types_without_label.include?(champ.type_champ)
end
2018-10-17 12:07:25 +02:00
def geo_data(champ)
# rubocop:disable Rails/OutputSafety
raw({
position: champ.position,
selection: champ.value.present? ? JSON.parse(champ.value) : [],
quartiersPrioritaires: champ.quartiers_prioritaires? ? champ.quartiers_prioritaires : [],
2018-10-23 15:38:20 +02:00
cadastres: champ.cadastres? ? champ.cadastres : [],
parcellesAgricoles: champ.parcelles_agricoles? ? champ.parcelles_agricoles : []
2018-10-17 12:07:25 +02:00
}.to_json)
# rubocop:enable Rails/OutputSafety
end
end