style: formatting

This commit is contained in:
Faris Ansari 2021-10-20 19:06:16 +05:30
parent 952eb004b8
commit 239ec49612
5 changed files with 16 additions and 16 deletions

View file

@ -621,14 +621,14 @@ frappe.ui.form.PrintView = class {
name: this.frm.doc.name,
print_format: print_format.name,
letterhead: this.get_letterhead()
})
});
let w = window.open(`/api/method/frappe.utils.weasyprint.download_pdf?${params}`);
if (!w) {
frappe.msgprint(__('Please enable pop-ups'));
return;
}
} else {
this.render_page('/api/method/frappe.utils.print_format.download_pdf?')
this.render_page('/api/method/frappe.utils.print_format.download_pdf?');
}
}

View file

@ -136,7 +136,7 @@ frappe.PrintFormatBuilder = class PrintFormatBuilder {
beta: Boolean(beta)
},
callback: (r) => {
if(r.message) {
if (r.message) {
let print_format = r.message;
if (print_format.print_format_builder_beta) {
frappe.set_route('print-format-builder-beta', print_format.name);

View file

@ -1,5 +1,5 @@
frappe.pages["print-format-builder-beta"].on_page_load = function(wrapper) {
var page = frappe.ui.make_app_page({
frappe.ui.make_app_page({
parent: wrapper,
title: __("Print Format Builder"),
single_column: true

View file

@ -106,8 +106,8 @@ export function get_table_columns(df) {
typeof tf.width == "number" && tf.width < 100
? tf.width
: tf.width
? 20
: 10;
? 20
: 10;
table_columns.push({
label: tf.label,
fieldname: tf.fieldname,

View file

@ -37,11 +37,11 @@ class PrintFormatGenerator:
Parameters
----------
print_format: str
Name of the Print Format
Name of the Print Format
doc: str
Document to print
Document to print
letterhead: str
Letter Head to apply (optional)
Letter Head to apply (optional)
"""
self.base_url = frappe.utils.get_url()
self.print_format = frappe.get_doc("Print Format", print_format)
@ -101,7 +101,7 @@ class PrintFormatGenerator:
Returns
-------
pdf: a bytes sequence
The rendered PDF.
The rendered PDF.
"""
self._make_header_footer()
@ -124,14 +124,14 @@ class PrintFormatGenerator:
Parameters
----------
element: str
Either 'header' or 'footer'
Either 'header' or 'footer'
Returns
-------
element_body: BlockBox
A Weasyprint pre-rendered representation of an html element
A Weasyprint pre-rendered representation of an html element
element_height: float
The height of this element, which will be then translated in a html height
The height of this element, which will be then translated in a html height
"""
html = HTML(string=getattr(self, f"{element}_html"), base_url=self.base_url,)
element_doc = html.render(
@ -160,11 +160,11 @@ class PrintFormatGenerator:
Parameters
----------
main_doc: Document
The top level representation for a PDF page in Weasyprint.
The top level representation for a PDF page in Weasyprint.
header_body: BlockBox
A representation for an html element in Weasyprint.
A representation for an html element in Weasyprint.
footer_body: BlockBox
A representation for an html element in Weasyprint.
A representation for an html element in Weasyprint.
"""
for page in main_doc.pages:
page_body = PrintFormatGenerator.get_element(page._page_box.all_children(), "body")