feat(export.linked_drop_down_list): render compound value

This commit is contained in:
mfo 2024-11-14 09:55:10 +01:00
parent 1fccf0fd18
commit 6cdd801326
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
3 changed files with 19 additions and 11 deletions

View file

@ -46,10 +46,10 @@ class Columns::LinkedDropDownColumn < Columns::ChampColumn
def column_id = "type_de_champ/#{stable_id}->#{path}"
def typed_value(champ)
return nil if path == :value
primary_value, secondary_value = unpack_values(champ.value)
case path
when :value
"#{primary_value} / #{secondary_value}"
when :primary
primary_value
when :secondary

View file

@ -30,7 +30,7 @@ describe Columns::ChampColumn do
expect_type_de_champ_values('checkbox', eq([true]))
expect_type_de_champ_values('drop_down_list', eq(['val1']))
expect_type_de_champ_values('multiple_drop_down_list', eq([["val1", "val2"]]))
expect_type_de_champ_values('linked_drop_down_list', eq([nil, "primary", "secondary"]))
expect_type_de_champ_values('linked_drop_down_list', eq(["primary / secondary", "primary", "secondary"]))
expect_type_de_champ_values('yes_no', eq([true]))
expect_type_de_champ_values('annuaire_education', eq([nil]))
expect_type_de_champ_values('piece_justificative', be_an_instance_of(Array))

View file

@ -44,7 +44,7 @@ describe ProcedureExportService do
end
describe 'Dossiers sheet' do
context 'multiple columns' do
context 'with multiple columns' do
let(:exported_columns) do
[
ExportedColumn.new(libelle: 'Date du dernier évènement', column: procedure.find_column(label: 'Date du dernier évènement')),
@ -72,7 +72,7 @@ describe ProcedureExportService do
end
end
context 'with a procedure having multiple groupe instructeur' do
context 'with multiple groupe instructeur' do
let(:exported_columns) { [ExportedColumn.new(libelle: 'Groupe instructeur', column: procedure.find_column(label: 'Groupe instructeur'))] }
let(:types_de_champ_public) { [] }
@ -87,7 +87,7 @@ describe ProcedureExportService do
end
end
context 'with a dossier having multiple pjs' do
context 'with multiple pjs' do
let(:types_de_champ_public) { [{ type: :piece_justificative, libelle: "PJ" }] }
let(:exported_columns) { [ExportedColumn.new(libelle: 'PJ', column: procedure.find_column(label: 'PJ'))] }
before do
@ -100,39 +100,47 @@ describe ProcedureExportService do
it { expect(dossiers_sheet.data.last.last).to eq "toto.txt, toto.txt" }
end
context 'with a dossier TypeDeChamp::MutlipleDropDownList' do
context 'with TypeDeChamp::MutlipleDropDownListTypeDeChamp' do
let(:types_de_champ_public) { [{ type: :multiple_drop_down_list, libelle: "multiple_drop_down_list", mandatory: true }] }
let(:exported_columns) { [ExportedColumn.new(libelle: 'Date du dernier évènement', column: procedure.find_column(label: 'multiple_drop_down_list'))] }
before { create(:dossier, :with_populated_champs, procedure:) }
it { expect(dossiers_sheet.data.last.last).to eq "val1, val2" }
end
context 'with a dossier TypeDeChamp:YesNo' do
context 'with TypeDeChamp:YesNoTypeDeChamp' do
let(:types_de_champ_public) { [{ type: :yes_no, libelle: "yes_no", mandatory: true }] }
let(:exported_columns) { [ExportedColumn.new(libelle: 'yes_no', column: procedure.find_column(label: 'yes_no'))] }
before { create(:dossier, :with_populated_champs, procedure:) }
it { expect(dossiers_sheet.data.last.last).to eq true }
end
context 'with a dossier TypeDeChamp:Checkbox' do
context 'with TypeDeChamp:CheckboxTypeDeChamp' do
let(:types_de_champ_public) { [{ type: :checkbox, libelle: "checkbox", mandatory: true }] }
let(:exported_columns) { [ExportedColumn.new(libelle: 'checkbox', column: procedure.find_column(label: 'checkbox'))] }
before { create(:dossier, :with_populated_champs, procedure:) }
it { expect(dossiers_sheet.data.last.last).to eq true }
end
context 'with a dossier TypeDeChamp:DecimalNumber' do
context 'with TypeDeChamp:DecimalNumberTypeDeChamp' do
let(:types_de_champ_public) { [{ type: :decimal_number, libelle: "decimal", mandatory: true }] }
let(:exported_columns) { [ExportedColumn.new(libelle: 'decimal', column: procedure.find_column(label: 'decimal'))] }
before { create(:dossier, :with_populated_champs, procedure:) }
it { expect(dossiers_sheet.data.last.last).to eq 42.1 }
end
context 'with a dossier TypeDeChamp:IntegerNumber' do
context 'with TypeDeChamp:IntegerNumberTypeDeChamp' do
let(:types_de_champ_public) { [{ type: :integer_number, libelle: "integer", mandatory: true }] }
let(:exported_columns) { [ExportedColumn.new(libelle: 'integer', column: procedure.find_column(label: 'integer'))] }
before { create(:dossier, :with_populated_champs, procedure:) }
it { expect(dossiers_sheet.data.last.last).to eq 42.0 }
end
context 'with having TypesDeChamp::LinkedDropDownListTypeDeChamp' do
let(:types_de_champ_public) { [{ type: :linked_drop_down_list, libelle: "linked_drop_down_list", mandatory: true }] }
let(:exported_columns) { [ExportedColumn.new(libelle: 'linked_drop_down_list', column: procedure.find_column(label: 'linked_drop_down_list'))] }
before { create(:dossier, :with_populated_champs, procedure:) }
it { expect(dossiers_sheet.data.last.last).to eq "primary / secondary" }
end
end
describe 'Etablissement sheet' do