feat: alternate print format column layout
This commit is contained in:
parent
f1a38ab8ed
commit
8b7c976f68
5 changed files with 49 additions and 32 deletions
|
|
@ -453,6 +453,7 @@ frappe.ui.form.PrintView = class {
|
|||
display: block !important;
|
||||
order: 1;
|
||||
margin-top: auto;
|
||||
padding-top: var(--padding-xl)
|
||||
`
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,8 +208,8 @@ frappe.PrintFormatBuilder = Class.extend({
|
|||
if(!this.print_heading_template) {
|
||||
// default print heading template
|
||||
this.print_heading_template = '<div class="print-heading">\
|
||||
<h2>'+__(this.print_format.doc_type)
|
||||
+'<br><small class="sub-heading">{{ doc.name }}</small>\
|
||||
<h2><div>'+__(this.print_format.doc_type)
|
||||
+'</div><br><small class="sub-heading">{{ doc.name }}</small>\
|
||||
</h2></div>';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,10 +25,11 @@
|
|||
{%- if doc.print_section_headings and section.label and section.has_data -%}
|
||||
<h4 class='col-sm-12'>{{ _(section.label) }}</h4>
|
||||
{%- endif -%}
|
||||
{%- set no_of_cols = section.columns|len -%}
|
||||
{% for column in section.columns %}
|
||||
<div class="col-xs-{{ (12 / section.columns|len)|int }} column-break">
|
||||
<div class="col-xs-{{ (12 / no_of_cols)|int }} column-break">
|
||||
{% for df in column.fields %}
|
||||
{{ render_field(df, doc) }}
|
||||
{{ render_field(df, doc, no_of_cols) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
|
|||
|
|
@ -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) -%}
|
||||
<div class="row {% if df.bold %}important{% endif %} data-field" {{ fieldmeta(df) }}>
|
||||
<div class="col-xs-{{ "9" if df.fieldtype=="Check" else "5" }}
|
||||
{%- if doc.align_labels_right %} text-right{%- endif -%}">
|
||||
{%- 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 %}
|
||||
<label>{{ _(df.label) }}</label>
|
||||
{% endif %}
|
||||
{% if df.fieldtype == "Check" and
|
||||
doc.get(df.fieldname) != 0 %}
|
||||
<label>{{ _(df.label) }}</label>
|
||||
{% 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 %}
|
||||
<div class="row {% if df.bold %}important{% endif %} data-field" {{ fieldmeta(df) }}>
|
||||
<div class="{{label_col_class}}
|
||||
{%- if doc.align_labels_right %} text-right{%- endif -%}">
|
||||
{% if df.fieldtype not in ("Image", "HTML") %}
|
||||
<label>{{ _(df.label) }}: </label>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="{{value_col_class}}
|
||||
{{ get_align_class(df, no_of_cols) }} value">
|
||||
{{ _(print_value(df, doc)) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-{{ "3" if df.fieldtype=="Check" else "7" }}
|
||||
{{ get_align_class(df) }} value">
|
||||
{% if doc.get(df.fieldname) != None -%}
|
||||
{{ _(print_value(df, doc)) }}{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% 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" %}
|
||||
<i class="{{ 'fa fa-check' if doc[df.fieldname] }}"></i>
|
||||
{% elif df.fieldtype=="Check" and doc[df.fieldname] %}
|
||||
<!-- <i class="{{ 'fa fa-check' }}"></i> -->
|
||||
<svg viewBox="0 0 16 16"
|
||||
fill="transparent" stroke="var(--icon-stroke)" stroke-width="2"
|
||||
xmlns="http://www.w3.org/2000/svg" id="icon-tick"
|
||||
style="width: 12px; height: 12px; margin-top: 5px;">
|
||||
<path d="M2 9.66667L5.33333 13L14 3" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
{% elif df.fieldtype=="Image" %}
|
||||
<img src="{{ doc[doc.meta.get_field(df.fieldname).options] }}"
|
||||
class="img-responsive"
|
||||
|
|
@ -148,8 +162,9 @@ data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}"
|
|||
{%- else -%}{{ 150 }}px{% endif -%}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro get_align_class(df) %}
|
||||
{%- if df.align -%}{{ "text-" + df.align }}
|
||||
{% macro get_align_class(df, no_of_cols=2) %}
|
||||
{% if no_of_cols >= 3 %}{{ "" }}
|
||||
{%- elif df.align -%}{{ "text-" + df.align }}
|
||||
{%- elif df.fieldtype in ("Int", "Float", "Currency", "Check", "Percent") -%}{{ "text-right" }}
|
||||
{%- else -%}{{ "" }}
|
||||
{%- endif -%}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue