refactor(pdf): use projected champs when render pdf
This commit is contained in:
parent
e1e497bd7b
commit
5fa697df95
1 changed files with 9 additions and 11 deletions
|
@ -175,7 +175,7 @@ def add_single_champ(pdf, champ)
|
||||||
if champ.etablissement.present?
|
if champ.etablissement.present?
|
||||||
add_identite_etablissement(pdf, champ.etablissement)
|
add_identite_etablissement(pdf, champ.etablissement)
|
||||||
end
|
end
|
||||||
when 'Champs::NumberChamp'
|
when 'Champs::NumberChamp', 'Champs::IntegerNumberChamp', 'Champs::DecimalNumberChamp'
|
||||||
value = champ.blank? ? 'Non communiqué' : number_with_delimiter(champ.to_s)
|
value = champ.blank? ? 'Non communiqué' : number_with_delimiter(champ.to_s)
|
||||||
format_in_2_lines(pdf, tdc.libelle, value)
|
format_in_2_lines(pdf, tdc.libelle, value)
|
||||||
when 'Champs::AddressChamp'
|
when 'Champs::AddressChamp'
|
||||||
|
@ -200,14 +200,12 @@ def add_single_champ(pdf, champ)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_champs(pdf, types_de_champ)
|
def add_champs(pdf, champs)
|
||||||
types_de_champ.each do |tdc|
|
champs.each do |champ|
|
||||||
champ = @dossier.project_champ(tdc, nil)
|
if champ.repetition?
|
||||||
if tdc.repetition?
|
champ.rows.each do |row|
|
||||||
inner_types_de_champ = @dossier.revision.children_of(tdc)
|
row.each do |champ|
|
||||||
champ.row_ids.each do |row_id|
|
add_single_champ(pdf, champ)
|
||||||
inner_types_de_champ.each do |inner_tdc|
|
|
||||||
add_single_champ(pdf, @dossier.project_champ(inner_tdc, row_id))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -351,11 +349,11 @@ prawn_document(page_size: "A4") do |pdf|
|
||||||
end
|
end
|
||||||
|
|
||||||
add_title(pdf, 'Formulaire')
|
add_title(pdf, 'Formulaire')
|
||||||
add_champs(pdf, @dossier.revision.types_de_champ_public)
|
add_champs(pdf, @dossier.project_champs_public)
|
||||||
|
|
||||||
if @acls[:include_infos_administration] && @dossier.has_annotations?
|
if @acls[:include_infos_administration] && @dossier.has_annotations?
|
||||||
add_title(pdf, "Annotations privées")
|
add_title(pdf, "Annotations privées")
|
||||||
add_champs(pdf, @dossier.revision.types_de_champ_private)
|
add_champs(pdf, @dossier.project_champs_private)
|
||||||
end
|
end
|
||||||
|
|
||||||
if @acls[:include_infos_administration] && @dossier.avis.present?
|
if @acls[:include_infos_administration] && @dossier.avis.present?
|
||||||
|
|
Loading…
Reference in a new issue