feat(attestation): tiptap default attestation
This commit is contained in:
parent
ce2ae53def
commit
7e02342518
3 changed files with 52 additions and 2 deletions
|
@ -87,7 +87,7 @@ module Administrateurs
|
|||
end
|
||||
|
||||
def retrieve_attestation_template
|
||||
@attestation_template = @procedure.attestation_template_v2 || @procedure.build_attestation_template_v2
|
||||
@attestation_template = @procedure.attestation_template_v2 || @procedure.build_attestation_template_v2(json_body: AttestationTemplate::TIPTAP_BODY_DEFAULT)
|
||||
end
|
||||
|
||||
def editor_params
|
||||
|
|
|
@ -21,6 +21,51 @@ class AttestationTemplate < ApplicationRecord
|
|||
scope :v1, -> { where(version: 1) }
|
||||
scope :v2, -> { where(version: 2) }
|
||||
|
||||
TIPTAP_BODY_DEFAULT = {
|
||||
"type" => "doc",
|
||||
"content" => [
|
||||
{
|
||||
"type" => "header",
|
||||
"content" => [
|
||||
{
|
||||
"type" => "headerColumn",
|
||||
"content" => [
|
||||
{
|
||||
"type" => "paragraph",
|
||||
"attrs" => { "textAlign" => "left" },
|
||||
"content" => [{ "type" => "mention", "attrs" => { "id" => "dossier_service_name", "label" => "nom du service" } }]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type" => "headerColumn",
|
||||
"content" => [
|
||||
{
|
||||
"type" => "paragraph",
|
||||
"attrs" => { "textAlign" => "left" },
|
||||
"content" => [
|
||||
{ "text" => "Fait le ", "type" => "text" },
|
||||
{ "type" => "mention", "attrs" => { "id" => "dossier_processed_at", "label" => "date de décision" } }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "type" => "title", "attrs" => { "textAlign" => "center" }, "content" => [{ "text" => "Titre de l’attestation", "type" => "text" }] },
|
||||
{
|
||||
"type" => "paragraph",
|
||||
"attrs" => { "textAlign" => "left" },
|
||||
"content" => [
|
||||
{
|
||||
"text" => "Vous pouvez éditer ce texte pour personnaliser votre attestation. Pour ajouter du contenu issu du dossier, utilisez les balises situées sous cette zone de saisie.",
|
||||
"type" => "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}.freeze
|
||||
|
||||
def attestation_for(dossier)
|
||||
attestation = Attestation.new(title: replace_tags(title, dossier, escape: false))
|
||||
attestation.pdf.attach(
|
||||
|
|
|
@ -102,7 +102,12 @@ describe 'As an administrateur, I want to manage the procedure’s attestation',
|
|||
|
||||
wait_until {
|
||||
body = JSON.parse(attestation.reload.tiptap_body)
|
||||
body.dig("content").first&.dig("content")&.first&.dig("content")&.first&.dig("content") == [{ "type" => "mention", "attrs" => { "id" => "dossier_processed_at", "label" => "date de décision" } }]
|
||||
first_content = body.dig("content").first&.dig("content")&.first&.dig("content")&.first&.dig("content")
|
||||
|
||||
first_content == [
|
||||
{ "type" => "mention", "attrs" => { "id" => "dossier_processed_at", "label" => "date de décision" } }, # added by click above
|
||||
{ "type" => "mention", "attrs" => { "id" => "dossier_service_name", "label" => "nom du service" } } # defaut initial content
|
||||
]
|
||||
}
|
||||
|
||||
find("label", text: /à la charte de l’état/).click
|
||||
|
|
Loading…
Reference in a new issue