add pj for export template

This commit is contained in:
Christophe Robillard 2024-03-03 10:03:12 +01:00 committed by simon lehericey
parent d1c3b84ea2
commit 24922605cd
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
2 changed files with 71 additions and 0 deletions

View file

@ -22,6 +22,15 @@ class ExportTemplate < ApplicationRecord
tiptap_content("pdf_name")
end
def content_for_pj(pj)
content_for_pj_id(pj.stable_id)&.to_json
end
def content_for_pj_id(stable_id)
content_for_stable_id = content["pjs"].find { _1.symbolize_keys[:stable_id] == stable_id.to_s }
content_for_stable_id.symbolize_keys.fetch(:path)
end
def attachment_and_path(dossier, attachment, index: 0, row_index: nil)
[
attachment,