From 8b7c976f680b2aac1b33cf45720beaf653ccdad0 Mon Sep 17 00:00:00 2001 From: prssanna Date: Mon, 14 Dec 2020 18:05:02 +0530 Subject: [PATCH] feat: alternate print format column layout --- frappe/printing/page/print/print.js | 1 + .../print_format_builder.js | 4 +- frappe/templates/print_formats/standard.html | 5 +- .../print_formats/standard_macros.html | 65 ++++++++++++------- frappe/templates/styles/standard.css | 6 +- 5 files changed, 49 insertions(+), 32 deletions(-) diff --git a/frappe/printing/page/print/print.js b/frappe/printing/page/print/print.js index 8dfffa18c0..82cfd6adf5 100644 --- a/frappe/printing/page/print/print.js +++ b/frappe/printing/page/print/print.js @@ -453,6 +453,7 @@ frappe.ui.form.PrintView = class { display: block !important; order: 1; margin-top: auto; + padding-top: var(--padding-xl) ` ); } diff --git a/frappe/printing/page/print_format_builder/print_format_builder.js b/frappe/printing/page/print_format_builder/print_format_builder.js index 1aeda6f86c..eb87190ab5 100644 --- a/frappe/printing/page/print_format_builder/print_format_builder.js +++ b/frappe/printing/page/print_format_builder/print_format_builder.js @@ -208,8 +208,8 @@ frappe.PrintFormatBuilder = Class.extend({ if(!this.print_heading_template) { // default print heading template this.print_heading_template = ''; } diff --git a/frappe/templates/print_formats/standard.html b/frappe/templates/print_formats/standard.html index fde0158b53..796663a248 100644 --- a/frappe/templates/print_formats/standard.html +++ b/frappe/templates/print_formats/standard.html @@ -25,10 +25,11 @@ {%- if doc.print_section_headings and section.label and section.has_data -%}

{{ _(section.label) }}

{%- endif -%} + {%- set no_of_cols = section.columns|len -%} {% for column in section.columns %} -
+
{% for df in column.fields %} - {{ render_field(df, doc) }} + {{ render_field(df, doc, no_of_cols) }} {% endfor %}
{% endfor %} diff --git a/frappe/templates/print_formats/standard_macros.html b/frappe/templates/print_formats/standard_macros.html index e9c64007fc..19c8dafc9e 100644 --- a/frappe/templates/print_formats/standard_macros.html +++ b/frappe/templates/print_formats/standard_macros.html @@ -1,4 +1,4 @@ -{% macro render_field(df, doc) -%} +{% macro render_field(df, doc, no_of_cols) -%} {%- if df.fieldtype=="Table" -%} {{ render_table(df, doc) }} {%- elif df.fieldtype=="HTML" and df.options -%} @@ -17,10 +17,10 @@ doc.print_templates.get(df.fieldname) -%} {% include doc.print_templates[df.fieldname] %} {%- else -%} - {{ render_field_with_label(df, doc) }} + {{ render_field_with_label(df, doc, no_of_cols) }} {%- endif -%} {%- else -%} - {{ render_field_with_label(df, doc) }} + {{ render_field_with_label(df, doc, no_of_cols) }} {%- endif -%} {%- endmacro -%} @@ -71,26 +71,34 @@ data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}" {%- endmacro %} -{%- macro render_field_with_label(df, doc) -%} -
-
+{%- macro render_field_with_label(df, doc, no_of_cols) -%} + {%- set label_col_class = resolve_class({ + 'col-xs-9': df.fieldtype=="Check", + 'col-xs-5': df.fieldtype!="Check" and no_of_cols < 3, + 'col-xs-12': df.fieldtype!="Check" and no_of_cols >= 3, + }) -%} - {% if df.fieldtype not in ("Image", "HTML", "Check") and - doc.get(df.fieldname) != None %} - - {% endif %} - {% if df.fieldtype == "Check" and - doc.get(df.fieldname) != 0 %} - - {% endif %} + {%- set value_col_class = resolve_class({ + 'col-xs-3': df.fieldtype=="Check", + 'col-xs-7': df.fieldtype!="Check" and no_of_cols < 3, + 'col-xs-12': df.fieldtype!="Check" and no_of_cols >= 3, + }) -%} + + {% set render_field = doc.get(df.fieldname) != 0 if df.fieldtype == "Check" else doc.get(df.fieldname) != None %} + {% if render_field %} +
+
+ {% if df.fieldtype not in ("Image", "HTML") %} + + {% endif %} +
+
+ {{ _(print_value(df, doc)) }} +
-
- {% if doc.get(df.fieldname) != None -%} - {{ _(print_value(df, doc)) }}{% endif %} -
-
+ {% endif %} {%- endmacro -%} {%- macro render_text_field(df, doc) -%} @@ -121,8 +129,14 @@ data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}" {%- macro print_value(df, doc, parent_doc=None, visible_columns=None, child_templates=None) -%} {% if child_templates and child_templates[df.fieldname] %} {% include child_templates[df.fieldname] %} - {% elif df.fieldtype=="Check" %} - + {% elif df.fieldtype=="Check" and doc[df.fieldname] %} + + + + {% elif df.fieldtype=="Image" %} = 3 %}{{ "" }} + {%- elif df.align -%}{{ "text-" + df.align }} {%- elif df.fieldtype in ("Int", "Float", "Currency", "Check", "Percent") -%}{{ "text-right" }} {%- else -%}{{ "" }} {%- endif -%} diff --git a/frappe/templates/styles/standard.css b/frappe/templates/styles/standard.css index b60e1e983c..b6ba34872e 100644 --- a/frappe/templates/styles/standard.css +++ b/frappe/templates/styles/standard.css @@ -19,13 +19,13 @@ } .page-break { - padding: 30px 0px; + /* padding: 15px 0px; */ border-bottom: 1px dashed #888; } - .page-break:first-child { + /* .page-break:first-child { padding-top: 0px; - } + } */ .page-break:last-child { border-bottom: 0px;