feat(rna/rnf): expose rnf/rna title

This commit is contained in:
mfo 2024-11-15 09:42:44 +01:00
parent cfd568b98d
commit 9a70a9526d
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
6 changed files with 42 additions and 6 deletions

View file

@ -4,8 +4,8 @@ module AddressableColumnConcern
extend ActiveSupport::Concern
included do
def columns(procedure:, displayable: true, prefix: nil)
addressable_columns = [
def addressable_columns(procedure:, displayable: true, prefix: nil)
[
["code postal (5 chiffres)", '$.postal_code', :text, []],
["commune", '$.city_name', :text, []],
["département", '$.departement_code', :enum, APIGeoService.departement_options],
@ -22,8 +22,6 @@ module AddressableColumnConcern
type:
)
end
super.concat(addressable_columns)
end
end
end

View file

@ -10,4 +10,20 @@ class TypesDeChamp::RNATypeDeChamp < TypesDeChamp::TypeDeChampBase
def champ_value_for_export(champ, path = :value)
champ.identifier
end
def columns(procedure:, displayable: true, prefix: nil)
super
.concat(addressable_columns(procedure:, displayable:, prefix:))
.concat([
Columns::JSONPathColumn.new(
procedure_id: procedure.id,
stable_id:,
tdc_type: type_champ,
label: "#{libelle_with_prefix(prefix)} Titre au répertoire national des associations",
type: :text,
jsonpath: '$.title',
displayable:
)
])
end
end

View file

@ -35,6 +35,22 @@ class TypesDeChamp::RNFTypeDeChamp < TypesDeChamp::TextTypeDeChamp
def champ_blank?(champ) = champ.external_id.blank?
def columns(procedure:, displayable: true, prefix: nil)
super
.concat(addressable_columns(procedure:, displayable:, prefix:))
.concat([
Columns::JSONPathColumn.new(
procedure_id: procedure.id,
stable_id:,
tdc_type: type_champ,
label: "#{libelle_with_prefix(prefix)} Titre au répertoire national des fondations ",
type: :text,
jsonpath: '$.title',
displayable:
)
])
end
private
def paths

View file

@ -8,4 +8,8 @@ class TypesDeChamp::SiretTypeDeChamp < TypesDeChamp::TypeDeChampBase
end
def champ_blank_or_invalid?(champ) = Siret.new(siret: champ.value).invalid?
def columns(procedure:, displayable: true, prefix: nil)
super.concat(addressable_columns(procedure:, displayable:, prefix:))
end
end

View file

@ -170,7 +170,7 @@ FactoryBot.define do
factory :champ_do_not_use_rna, class: 'Champs::RNAChamp' do
value { 'W173847273' }
value_json { AddressProxy::ADDRESS_PARTS.index_by(&:itself) }
value_json { AddressProxy::ADDRESS_PARTS.index_by(&:itself).merge(title: "LA PRÉVENTION ROUTIERE") }
end
factory :champ_do_not_use_engagement_juridique, class: 'Champs::EngagementJuridiqueChamp' do
@ -183,7 +183,7 @@ FactoryBot.define do
factory :champ_do_not_use_rnf, class: 'Champs::RNFChamp' do
value { '075-FDD-00003-01' }
external_id { '075-FDD-00003-01' }
value_json { AddressProxy::ADDRESS_PARTS.index_by(&:itself) }
value_json { AddressProxy::ADDRESS_PARTS.index_by(&:itself).merge(title: "Fondation SFR") }
end
factory :champ_do_not_use_expression_reguliere, class: 'Champs::ExpressionReguliereChamp' do

View file

@ -41,6 +41,8 @@ describe Columns::ChampColumn do
expect_type_de_champ_values('mesri', eq([nil]))
expect_type_de_champ_values('cojo', eq([nil]))
expect_type_de_champ_values('expression_reguliere', eq([nil]))
expect_type_de_champ_values('rna', eq(["W173847273", "postal_code", "city_name", "departement_code", "region_name", "LA PRÉVENTION ROUTIERE"]))
expect_type_de_champ_values('rnf', eq(["075-FDD-00003-01", "postal_code", "city_name", "departement_code", "region_name", "Fondation SFR"]))
end
end