demarches-normaliennes/app/models/concerns/addressable_column_concern.rb

44 lines
1.1 KiB
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(table:)
super.concat([
Columns::JSONPathColumn.new(
table:,
displayable: false,
column: stable_id,
label: "#{libelle} code postal (5 chiffres)",
type: :text,
value_column: ['postal_code']
),
Columns::JSONPathColumn.new(
table:,
displayable: false,
column: stable_id,
label: "#{libelle} commune",
type: :text,
value_column: ['city_name']
),
Columns::JSONPathColumn.new(
table:,
displayable: false,
column: stable_id,
label: "#{libelle} département",
type: :enum,
value_column: ['departement_code']
),
Columns::JSONPathColumn.new(
table:,
displayable: false,
column: stable_id,
label: "#{libelle} région",
type: :enum,
value_column: ['region_name']
)
])
end
end
end