Craftform
behaviour
Craftform API
behaviour
Craftform API
Sample data :
- {craft_id} = frozen.temp.mes_ordre_inter.base.craftform
- {session_path} = craft/{craft_id} = craft/frozen.temp.mes_ordre_inter.base.craftform
GET {FRONTEND}/craft/{craft_id}
main craft pageGET {BACKEND}/api/craftform/{craft_id}
get craft defPOST {BACKEND}/api/craft/file/{craft_id}
call on a file dropPOST {BACKEND}/api/craft/{craft_id}
generate PDF (preview or finalize)GET /api/files/session/{session_path}
get user session filesDELETE /api/files/session/{session_path}
delete user session filesGET {BACKEND}/api/craft/{craft_id}/output.pdf
the generated PDF file
Main craftform behaviour
- user change an input field
- user upload a file
- user preview the generated PDF
- user finalize the generated PDF
- user reset the form
change_behaviour
- user change a field and leave focus on this field
- ...
upload_behaviour
- user drop a file on the form drop zone
<ppw-dropfile-main2>
POST {BACKEND}/api/craft/file/{craft_id}
calledlib.file_post()
ctx.script_exec(.. "drop_file" ..)
session.store_fileobj()
form_data_store()
FRONTEND:onFileChange()
called
preview_behaviour
See craftform cheatsheet 1
- user click the preview button
FRONTEND:doPreview()
FRONTEND:generateDocument()
POST {BACKEND}/api/craft2/doc/{doc:path}
generate PDFPOST {BACKEND}/api/craft/{craft_id}
generate PDF (old)lib.form_data_store(..)
tools.generate_files()
with tempfile ...
tools2.CraftContext()
tools2.grab_context_from_storage_to_local_temp()
process_dropped_files()
ctx.script_exec(.. "drop_file_pdf" ..)
ctx.script_exec(.. "drop_file_excel" ..)
ctx.script_exec(.. "template_get" ..)
ctx.script_exec(.. "generate_pdf" ..)
generate_pdf_post()
ctx.script_exec(.. "generate_metadata" ..)
(optional)generate_metadata_post()
if finalize:
ctx.script_exec(.. "generate_signature" ..)
generate_signature_post()
session.store_fileobj()
- .. open preview dialog ?
GET {BACKEND}/api/craft/{craft_id}/output.pdf
the generated PDF file
finalize_behaviour
Same as preview_behaviour.