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
|
|
|
|
|
def columns(table:)
|
|
|
|
|
super.concat([
|
|
|
|
|
Columns::JSONPathColumn.new(
|
|
|
|
|
table:,
|
|
|
|
|
virtual: true,
|
|
|
|
|
column: stable_id,
|
|
|
|
|
label: "#{libelle} – code postal (5 chiffres)",
|
|
|
|
|
type: :text,
|
|
|
|
|
value_column: ['postal_code']
|
|
|
|
|
),
|
|
|
|
|
Columns::JSONPathColumn.new(
|
|
|
|
|
table:,
|
|
|
|
|
virtual: true,
|
|
|
|
|
column: stable_id,
|
|
|
|
|
label: "#{libelle} – commune",
|
|
|
|
|
type: :text,
|
|
|
|
|
value_column: ['city_name']
|
|
|
|
|
),
|
|
|
|
|
Columns::JSONPathColumn.new(
|
|
|
|
|
table:,
|
|
|
|
|
virtual: true,
|
|
|
|
|
column: stable_id,
|
|
|
|
|
label: "#{libelle} – département",
|
|
|
|
|
type: :enum,
|
|
|
|
|
value_column: ['departement_code']
|
|
|
|
|
),
|
|
|
|
|
Columns::JSONPathColumn.new(
|
|
|
|
|
table:,
|
|
|
|
|
virtual: true,
|
|
|
|
|
column: stable_id,
|
|
|
|
|
label: "#{libelle} – region",
|
|
|
|
|
type: :enum,
|
|
|
|
|
value_column: ['region_name']
|
|
|
|
|
)
|
|
|
|
|
])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|