Merge pull request #11034 from demarches-simplifiees/fix_json_projection

Instructeur: corrige l'affichage de données api dans le tableau d'une démarche
This commit is contained in:
LeSim 2024-11-12 08:38:41 +00:00 committed by GitHub
commit 72d8e43b2a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -207,7 +207,7 @@ class DossierProjectionService
type_de_champ = stable_ids_and_types_de_champ_by_dossier_ids.fetch(champ.dossier_id, {})[champ.stable_id] type_de_champ = stable_ids_and_types_de_champ_by_dossier_ids.fetch(champ.dossier_id, {})[champ.stable_id]
if type_de_champ.present? && type_de_champ.type_champ == champ.last_write_type_champ if type_de_champ.present? && type_de_champ.type_champ == champ.last_write_type_champ
if column.is_a?(Columns::JSONPathColumn) if column.is_a?(Columns::JSONPathColumn)
column.get_value(champ) column.value(champ)
else else
type_de_champ.champ_value(champ) type_de_champ.champ_value(champ)
end end

View file

@ -238,6 +238,18 @@ describe DossierProjectionService do
end end
end end
context 'for a json column' do
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :siret, libelle: 'siret' }]) }
let(:dossier) { create(:dossier, procedure:) }
let(:label) { "siret département" }
before do
dossier.project_champs_public.first.update(value_json: { 'departement_code': '38' })
end
it { is_expected.to eq('38') }
end
context 'for dossier corrections table' do context 'for dossier corrections table' do
let(:table) { 'dossier_corrections' } let(:table) { 'dossier_corrections' }
let(:column) { 'resolved_at' } let(:column) { 'resolved_at' }