Skip to content

Commit

Permalink
Add preview example and supporting code
Browse files Browse the repository at this point in the history
  • Loading branch information
nonprofittechy committed Oct 30, 2024
1 parent 3ed0be6 commit 55a886d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docassemble/AssemblyLine/data/questions/al_document.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ code: |
from_file = action_argument('from_file')
background_response(ocrmypdf_task(from_file, to_pdf))
---
############## Background document assembly #################
---
generic object: ALDocumentBundle
code: |
x.generate_downloads_task = background_action(x.attr_name('create_downloads'))
Expand Down Expand Up @@ -137,4 +139,34 @@ subquestion: |
<span class="sr-only">Making documents...</span>
</div>
event: al_download_waiting_screen
reload: True
---
########## Background preview assembly ################
---
generic object: ALDocumentBundle
code: |
x.generate_preview_task = background_action(x.attr_name('generate_preview_event'))
---
generic object: ALDocumentBundle
event: x.generate_preview_event
code: |
preview_response = x.as_pdf(key="preview")
background_response_action(x.attr_name('save_preview'), preview_response=preview_response)
---
generic object: ALDocumentBundle
event: x.save_preview
code: |
x._preview_file = action_argument('preview_response')
background_response()
---
id: preview waiting screen
question: |
Please wait while we generate a preview of your document
subquestion: |
This can take a few minutes.
<div class="spinner-border text-primary d-flex justify-content-center" role="status">
<span class="sr-only">Generating preview...</span>
</div>
event: al_preview_waiting_screen
reload: True
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
mandatory: True
code: |
intro_screen
if not al_user_bundle.generate_preview_task.ready():
al_preview_waiting_screen
preview_screen
# if not al_user_bundle.generate_downloads_task.ready(): # Without DOCX
if not al_user_bundle.generate_downloads_with_docx_task.ready(): # With DOCX
al_download_waiting_screen
Expand All @@ -17,6 +20,17 @@ continue button field: intro_screen
question: |
Intro screen
---
id: preview_screen
continue button field: preview_screen
question: |
Preview the documents
subquestion: |
Your documents are ready for preview.
Click the thumbnail below to view the preview of your documents. It will open in a new tab.
${ al_user_bundle._preview_file }
---
id: download
event: download_screen
question: |
Expand Down

0 comments on commit 55a886d

Please sign in to comment.