Skip to content

Commit

Permalink
feat: nice page breaks for long item descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Apr 4, 2024
1 parent cd8dd42 commit ada1fb0
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 47 deletions.
51 changes: 32 additions & 19 deletions print_format/delivery_note.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,38 @@
{% endif %}
</td>
</tr>
<tr>
<td></td>
<td colspan="2">
{{ n.description }}
{% if n.against_sales_order %}
<br>{{ _("Sales Order: {0}").format(n.against_sales_order) }}
{% endif %}
{% if n.against_sales_invoice %}
<br>{{ _("Sales Invoice: {0}").format(n.against_sales_invoice) }}
{% endif %}
{% if n.batch_no %}
<br>{{ _("Batch No: {0}").format(n.batch_no) }}
{% endif %}
{% if n.serial_no %}
<br>{{ _("Serial Numbers: {0}").format(n.serial_no) }}
{% endif %}
</td>
<td></td>
</tr>

{% set paragraphs = n.description.split("<p>") %}
{# the first paragraph is always an empty div, skip that #}
{% for p in paragraphs[1:] %}
<tr class="
{{ 'no-bottom-padding' if loop.first and loop.nextitem else '' }}
{{ 'no-top-padding' if loop.previtem and loop.last else '' }}
{{ 'no-y-padding' if loop.nextitem and loop.previtem else '' }}
">
<td></td>
<td colspan="2">
<div class="ql-editor">{{ p.removesuffix("</p>") }}</div>

{% if loop.last %}
{% if n.against_sales_order %}
<br>{{ _("Sales Order: {0}").format(n.against_sales_order) }}
{% endif %}
{% if n.against_sales_invoice %}
<br>{{ _("Sales Invoice: {0}").format(n.against_sales_invoice) }}
{% endif %}
{% if n.batch_no %}
<br>{{ _("Batch No: {0}").format(n.batch_no) }}
{% endif %}
{% if n.serial_no %}
<br>{{ _("Serial Numbers: {0}").format(n.serial_no) }}
{% endif %}
{% endif %}
</td>
<td></td>
</tr>
{% endfor %}

{% endfor %}
</tbody>
</table>
Expand Down
22 changes: 17 additions & 5 deletions print_format/purchase_order.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,23 @@
<!-- <td>{{ n.get_formatted("discount_amount") }}</td> -->
<td class="text-right">{{ n.get_formatted("amount") }}</td>
</tr>
<tr>
<td></td>
<td colspan="4">{{ n.description }}</td>
<td></td>
</tr>

{% set paragraphs = n.description.split("<p>") %}
{# the first paragraph is always an empty div, skip that #}
{% for p in paragraphs[1:] %}
<tr class="
{{ 'no-bottom-padding' if loop.first and loop.nextitem else '' }}
{{ 'no-top-padding' if loop.previtem and loop.last else '' }}
{{ 'no-y-padding' if loop.nextitem and loop.previtem else '' }}
">
<td></td>
<td colspan="4">
<div class="ql-editor">{{ p.removesuffix("</p>") }}</div>
</td>
<td></td>
</tr>
{% endfor %}

{% endfor %}
</tbody>

Expand Down
22 changes: 17 additions & 5 deletions print_format/quotation.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,23 @@
<!-- <td>{{ n.get_formatted("discount_amount") }}</td> -->
<td class="text-right">{{ n.get_formatted("amount") }}</td>
</tr>
<tr>
<td></td>
<td colspan="4">{{ n.description }}</td>
<td></td>
</tr>

{% set paragraphs = n.description.split("<p>") %}
{# the first paragraph is always an empty div, skip that #}
{% for p in paragraphs[1:] %}
<tr class="
{{ 'no-bottom-padding' if loop.first and loop.nextitem else '' }}
{{ 'no-top-padding' if loop.previtem and loop.last else '' }}
{{ 'no-y-padding' if loop.nextitem and loop.previtem else '' }}
">
<td></td>
<td colspan="4">
<div class="ql-editor">{{ p.removesuffix("</p>") }}</div>
</td>
<td></td>
</tr>
{% endfor %}

{% endfor %}
</tbody>

Expand Down
24 changes: 24 additions & 0 deletions print_format/request_for_quotation.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,30 @@
</td>
<td></td>
</tr>

{% set paragraphs = n.description.split("<p>") %}
{# the first paragraph is always an empty div, skip that #}
{% for p in paragraphs[1:] %}
<tr class="
{{ 'no-bottom-padding' if loop.first and loop.nextitem else '' }}
{{ 'no-top-padding' if loop.previtem and loop.last else '' }}
{{ 'no-y-padding' if loop.nextitem and loop.previtem else '' }}
">
<td></td>
<td colspan="2">
<div class="ql-editor">{{ p.removesuffix("</p>") }}</div>

{% if loop.last %}
{{ _("Our Part No.: {0}").format(n.item_code) }}
{% if n.supplier_part_no %}
<br>
{{ _("Your Part No.: {0}").format(n.supplier_part_no) }}
{% endif %}
{% endif %}
</td>
<td></td>
</tr>
{% endfor %}
{% endfor %}
</tbody>

Expand Down
22 changes: 17 additions & 5 deletions print_format/sales_invoice.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,23 @@
<!-- <td>{{ n.get_formatted("discount_amount") }}</td> -->
<td class="text-right">{{ n.get_formatted("amount") }}</td>
</tr>
<tr>
<td></td>
<td colspan="4">{{ n.description }}</td>
<td></td>
</tr>

{% set paragraphs = n.description.split("<p>") %}
{# the first paragraph is always an empty div, skip that #}
{% for p in paragraphs[1:] %}
<tr class="
{{ 'no-bottom-padding' if loop.first and loop.nextitem else '' }}
{{ 'no-top-padding' if loop.previtem and loop.last else '' }}
{{ 'no-y-padding' if loop.nextitem and loop.previtem else '' }}
">
<td></td>
<td colspan="4">
<div class="ql-editor">{{ p.removesuffix("</p>") }}</div>
</td>
<td></td>
</tr>
{% endfor %}

{% endfor %}
</tbody>

Expand Down
32 changes: 21 additions & 11 deletions print_format/sales_order.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,27 @@
<!-- <td>{{ n.get_formatted("discount_amount") }}</td> -->
<td class="text-right">{{ n.get_formatted("amount") }}</td>
</tr>
<tr>
<td></td>
<td colspan="4">
{{ n.description }}
{% if n.prevdoc_docname %}
<!-- Angebot: A-2020-001 -->
({{ _("Quotation") }}: {{ n.prevdoc_docname }})
{% endif %}
</td>
<td></td>
</tr>

{% set paragraphs = n.description.split("<p>") %}
{# the first paragraph is always an empty div, skip that #}
{% for p in paragraphs[1:] %}
<tr class="
{{ 'no-bottom-padding' if loop.first and loop.nextitem else '' }}
{{ 'no-top-padding' if loop.previtem and loop.last else '' }}
{{ 'no-y-padding' if loop.nextitem and loop.previtem else '' }}
">
<td></td>
<td colspan="4">
<div class="ql-editor">{{ p.removesuffix("</p>") }}</div>
{% if loop.last and n.prevdoc_docname %}
<!-- (Angebot: A-2020-001) -->
({{ _("Quotation") }}: {{ n.prevdoc_docname }})
{% endif %}
</td>
<td></td>
</tr>
{% endfor %}

{% endfor %}
</tbody>

Expand Down
18 changes: 16 additions & 2 deletions print_style/print_style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,24 @@
page-break-inside: avoid;
page-break-after: auto;
}


tr.no-y-padding td {
padding-top: 0 !important;
padding-bottom: 0 !important;
}

tr.no-top-padding td {
padding-top: 0 !important;
}

tr.no-bottom-padding td {
padding-bottom: 0 !important;
}

thead {
display: table-header-group;
}

tfoot {
display: table-row-group;
}
Expand All @@ -126,6 +139,7 @@
line-height: 1.42857143;
font-family: Inter, "Helvetica Neue", Helvetica, Arial, "Open Sans", sans-serif; // use `var(--font-stack)` for v16+
overflow: hidden;
padding: 0 !important;

p {
margin: unset;
Expand Down

0 comments on commit ada1fb0

Please sign in to comment.