Merge pull request #8746 from mfo/US/8739/export-pdf-header-section
correctif(dossier.export.pdf): l'export au format pdf d'un dossier ayant un champ de type repetition contenant un titre etait mal rendu
This commit is contained in:
commit
1eab329d3f
2 changed files with 21 additions and 4 deletions
|
@ -22,14 +22,19 @@ module DossierSectionsConcern
|
|||
|
||||
def index_for_section_header(champ)
|
||||
champs = champ.private? ? champs_private : champs_public
|
||||
|
||||
index = 1
|
||||
champs.each do |c|
|
||||
return index if c.stable_id == champ.stable_id
|
||||
next unless c.visible?
|
||||
if c.repetition?
|
||||
index_in_repetition = c.rows.flatten.filter { _1.stable_id == champ.stable_id }.find_index(champ)
|
||||
return "#{index}.#{index_in_repetition + 1}" if index_in_repetition
|
||||
else
|
||||
return index if c.stable_id == champ.stable_id
|
||||
next unless c.visible?
|
||||
|
||||
index += 1 if c.type_de_champ.header_section?
|
||||
index += 1 if c.type_de_champ.header_section?
|
||||
end
|
||||
end
|
||||
index
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1317,6 +1317,18 @@ describe Dossier do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'index_for_section_header' do
|
||||
let(:procedure) { create(:procedure, types_de_champ_public: types_de_champ) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||
let(:types_de_champ) { [{ type: :repetition, mandatory: true, children: [{ type: :header_section }] }] }
|
||||
|
||||
it 'index classly' do
|
||||
repetition = dossier.champs.find(&:repetition?)
|
||||
header_in_repetition = repetition.champs.find(&:header_section?)
|
||||
expect(dossier.index_for_section_header(header_in_repetition)).to eq("1.1")
|
||||
end
|
||||
end
|
||||
|
||||
describe '#repasser_en_instruction!' do
|
||||
let(:dossier) { create(:dossier, :refuse, :with_attestation, archived: true, termine_close_to_expiration_notice_sent_at: Time.zone.now) }
|
||||
let!(:instructeur) { create(:instructeur) }
|
||||
|
|
Loading…
Reference in a new issue