export template: set default values
This commit is contained in:
parent
dbf46b1f02
commit
a248eba641
2 changed files with 35 additions and 0 deletions
|
@ -7,6 +7,16 @@ class ExportTemplate < ApplicationRecord
|
||||||
|
|
||||||
DOSSIER_STATE = Dossier.states.fetch(:en_construction)
|
DOSSIER_STATE = Dossier.states.fetch(:en_construction)
|
||||||
|
|
||||||
|
def set_default_values
|
||||||
|
content["default_dossier_directory"] = tiptap_json("dossier-")
|
||||||
|
content["pdf_name"] = tiptap_json("export_")
|
||||||
|
|
||||||
|
content["pjs"] = []
|
||||||
|
procedure.pieces_jointes_exportables_list.each do |pj|
|
||||||
|
content["pjs"] << { "stable_id" => pj.stable_id.to_s, "path" => tiptap_json("#{pj.libelle.parameterize}-") }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def tiptap_default_dossier_directory=(body)
|
def tiptap_default_dossier_directory=(body)
|
||||||
self.content["default_dossier_directory"] = JSON.parse(body)
|
self.content["default_dossier_directory"] = JSON.parse(body)
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,6 +37,31 @@ describe ExportTemplate do
|
||||||
{ type: :piece_justificative, libelle: "Justificatif de domicile", mandatory: true, stable_id: 910 }
|
{ type: :piece_justificative, libelle: "Justificatif de domicile", mandatory: true, stable_id: 910 }
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
it 'set default values' do
|
||||||
|
export_template.set_default_values
|
||||||
|
expect(export_template.content).to eq({
|
||||||
|
"pdf_name" => {
|
||||||
|
"type" => "doc",
|
||||||
|
"content" => [
|
||||||
|
{ "type" => "paragraph", "content" => [{ "text" => "export_", "type" => "text" }, { "type" => "mention", "attrs" => ExportTemplate::DOSSIER_ID_TAG.stringify_keys }] }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"default_dossier_directory" => {
|
||||||
|
"type" => "doc",
|
||||||
|
"content" => [
|
||||||
|
{ "type" => "paragraph", "content" => [{ "text" => "dossier-", "type" => "text" }, { "type" => "mention", "attrs" => ExportTemplate::DOSSIER_ID_TAG.stringify_keys }] }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"pjs" =>
|
||||||
|
[
|
||||||
|
|
||||||
|
{
|
||||||
|
"stable_id" => "910",
|
||||||
|
"path" => { "type" => "doc", "content" => [{ "type" => "paragraph", "content" => [{ "text" => "justificatif-de-domicile-", "type" => "text" }, { "type" => "mention", "attrs" => ExportTemplate::DOSSIER_ID_TAG.stringify_keys }] }] }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#tiptap_default_dossier_directory' do
|
describe '#tiptap_default_dossier_directory' do
|
||||||
|
|
Loading…
Add table
Reference in a new issue