-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Multi Page and Multi Header/Footer
- added patch to convert all json to match new format with pages. - updated jinja formats to loop over pages and render them. - modified code to design multiple headers and footers. - added option to add new pages. - updated drag, resize, drop to work with multiple pages. - updated marquee tool. - added options to select headers / footers for first / last / odd /even pages - Changed Canvas to render multiple pages. - Header / footer now needs to designed separately.
- Loading branch information
1 parent
5b1cb6e
commit 353f1d0
Showing
26 changed files
with
1,588 additions
and
930 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
print_designer/patches/move_header_footers_to_new_schema.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import frappe | ||
|
||
|
||
def patch_format(): | ||
print_formats = frappe.get_all( | ||
"Print Format", | ||
filters={"print_designer": 1}, | ||
fields=[ | ||
"name", | ||
"print_designer_header", | ||
"print_designer_body", | ||
"print_designer_after_table", | ||
"print_designer_footer", | ||
"print_designer_print_format", | ||
"print_designer_settings", | ||
], | ||
) | ||
for pf in print_formats: | ||
settings = frappe.json.loads(pf.print_designer_settings or "{}") | ||
|
||
header_childrens = frappe.json.loads(pf.print_designer_header or "[]") | ||
header_data = [ | ||
{ | ||
"type": "page", | ||
"childrens": header_childrens, | ||
"firstPage": True, | ||
"oddPage": True, | ||
"evenPage": True, | ||
"lastPage": True, | ||
} | ||
] | ||
|
||
footer_childrens = frappe.json.loads(pf.print_designer_footer or "[]") | ||
footer_data = [ | ||
{ | ||
"type": "page", | ||
"childrens": footer_childrens, | ||
"firstPage": True, | ||
"oddPage": True, | ||
"evenPage": True, | ||
"lastPage": True, | ||
} | ||
] | ||
for child in footer_childrens: | ||
child["startY"] -= ( | ||
settings["page"].get("height", 0) | ||
- settings["page"].get("marginTop", 0) | ||
- settings["page"].get("footerHeight", 0) | ||
) | ||
|
||
childrens = frappe.json.loads(pf.print_designer_body or "[]") | ||
bodyPage = [ | ||
{ | ||
"index": 0, | ||
"type": "page", | ||
"childrens": childrens, | ||
"isDropZone": True, | ||
} | ||
] | ||
|
||
frappe.set_value( | ||
"Print Format", | ||
pf.name, | ||
{ | ||
"print_designer_header": frappe.json.dumps(header_data), | ||
"print_designer_body": frappe.json.dumps(bodyPage), | ||
"print_designer_footer": frappe.json.dumps(footer_data), | ||
"print_designer_settings": frappe.json.dumps(settings), | ||
}, | ||
) | ||
return print_formats | ||
|
||
|
||
def execute(): | ||
"""Updating Table and Dynamic Text Elements to have property isDynamicHeight with default value as True""" | ||
patch_format() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.