2024-04-29 00:17:15 +02:00
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2024-07-22 14:58:16 +02:00
|
|
|
|
module AddressableColumnConcern
|
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
|
|
included do
|
2024-11-04 11:39:08 +01:00
|
|
|
|
def columns(procedure:, displayable: true, prefix: nil)
|
2024-11-06 11:28:51 +01:00
|
|
|
|
addressable_columns = [
|
|
|
|
|
["code postal (5 chiffres)", '$.postal_code', :text, []],
|
|
|
|
|
["commune", '$.city_name', :text, []],
|
2024-11-07 10:27:35 +01:00
|
|
|
|
["département", '$.departement_code', :enum, APIGeoService.departement_options],
|
|
|
|
|
["region", '$.region_name', :enum, APIGeoService.region_options]
|
2024-11-06 11:28:51 +01:00
|
|
|
|
].map do |(label, jsonpath, type, options_for_select)|
|
2024-07-22 14:58:16 +02:00
|
|
|
|
Columns::JSONPathColumn.new(
|
2024-11-04 11:39:08 +01:00
|
|
|
|
procedure_id: procedure.id,
|
2024-11-04 10:18:07 +01:00
|
|
|
|
stable_id:,
|
2024-11-04 16:34:00 +01:00
|
|
|
|
tdc_type: type_champ,
|
2024-08-22 12:37:10 +02:00
|
|
|
|
label: "#{libelle_with_prefix(prefix)} – #{label}",
|
2024-11-04 10:18:07 +01:00
|
|
|
|
jsonpath:,
|
|
|
|
|
displayable:,
|
2024-11-06 11:28:51 +01:00
|
|
|
|
options_for_select:,
|
2024-11-04 10:18:07 +01:00
|
|
|
|
type:
|
2024-07-22 14:58:16 +02:00
|
|
|
|
)
|
2024-11-06 11:28:51 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
super.concat(addressable_columns)
|
2024-07-22 14:58:16 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|