-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
2,336 additions
and
1,319 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
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,24 @@ | ||
import frappe | ||
|
||
from print_designer.patches.patch_utils import patch_formats | ||
|
||
|
||
def execute(): | ||
"""changing isDynamicHeight property to heightType property in text and table elements""" | ||
|
||
def element_callback(el): | ||
if el.get("type") == "text" and not (el.get("isDynamic") or el.get("parseJinja")): | ||
return | ||
|
||
if not "isDynamicHeight" in el: | ||
el["isDynamicHeight"] = False | ||
|
||
if el["isDynamicHeight"]: | ||
el["heightType"] = "auto" | ||
else: | ||
el["heightType"] = "fixed" | ||
|
||
patch_formats( | ||
{"element": element_callback}, | ||
types=["text", "table"], | ||
) |
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,14 @@ | ||
import frappe | ||
|
||
from print_designer.patches.patch_utils import patch_formats | ||
|
||
|
||
def execute(): | ||
"""Updating all style objects to have zIndex 0 in print formats that uses print designer""" | ||
|
||
def style(style): | ||
style["zIndex"] = 0 | ||
|
||
patch_formats( | ||
{"style": style}, | ||
) |
96 changes: 96 additions & 0 deletions
96
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,96 @@ | ||
import frappe | ||
|
||
from print_designer.pdf import is_older_schema | ||
|
||
|
||
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, | ||
} | ||
] | ||
object_to_save = { | ||
"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), | ||
} | ||
if not is_older_schema(settings=settings, current_version="1.1.0"): | ||
pf_print_format = frappe.json.loads(pf.print_designer_print_format) | ||
if "header" in pf_print_format: | ||
pf_print_format["header"] = { | ||
"firstPage": pf_print_format["header"], | ||
"oddPage": pf_print_format["header"], | ||
"evenPage": pf_print_format["header"], | ||
"lastPage": pf_print_format["header"], | ||
} | ||
if "footer" in pf_print_format: | ||
pf_print_format["footer"] = { | ||
"firstPage": pf_print_format["footer"], | ||
"oddPage": pf_print_format["footer"], | ||
"evenPage": pf_print_format["footer"], | ||
"lastPage": pf_print_format["footer"], | ||
} | ||
object_to_save["print_designer_print_format"] = frappe.json.dumps(pf_print_format) | ||
|
||
frappe.set_value( | ||
"Print Format", | ||
pf.name, | ||
object_to_save, | ||
) | ||
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
6 changes: 3 additions & 3 deletions
6
print_designer/print_designer/page/print_designer/jinja/macros/dynamictext.html
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
10 changes: 7 additions & 3 deletions
10
print_designer/print_designer/page/print_designer/jinja/macros/rectangle.html
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
28 changes: 24 additions & 4 deletions
28
print_designer/print_designer/page/print_designer/jinja/macros/relative_containers.html
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.