demarches-normaliennes/app/models/concerns/addressable_column_concern.rb
2024-11-05 09:38:26 +01:00

25 lines
687 B
Ruby
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# frozen_string_literal: true
module AddressableColumnConcern
extend ActiveSupport::Concern
included do
def columns(procedure_id:, displayable: true, prefix: nil)
super.concat([
["code postal (5 chiffres)", '$.postal_code', :text],
["commune", '$.city_name', :text],
["département", '$.departement_code', :enum],
["region", '$.region_name', :enum]
].map do |(label, jsonpath, type)|
Columns::JSONPathColumn.new(
procedure_id:,
stable_id:,
label: "#{libelle_with_prefix(prefix)} #{label}",
jsonpath:,
displayable:,
type:
)
end)
end
end
end