Skip to content

Commit

Permalink
fix: change heightType check to string (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
maharshivpatel authored May 24, 2024
2 parents 7dd7f66 + 39f7ea6 commit d4c18f8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% from 'print_designer/page/print_designer/jinja/macros/spantag.html' import span_tag with context %}

{% macro dynamictext(element, send_to_jinja, is_parent_dynamic_height) -%}
<div style="position:{%- if is_parent_dynamic_height != 'fixed' -%}relative{% else %}absolute{%- endif -%}; {%- if is_parent_dynamic_height == 'fixed' -%}top: {%- else -%}margin-top: {%- endif -%}{{ element.startY }}px; left:{{ element.startX }}px;{% if element.isFixedSize %}width:{{ element.width }}px; {%- if is_parent_dynamic_height == 'fixed' -%}height:{{ element.height }}px; {%- endif -%} {% else %} width:fit-content; height:fit-content; white-space:nowrap; max-width: {{ (settings.page.width - settings.page.marginLeft - settings.page.marginRight - element.startX) + 2 }}px;{%endif%}" class="
{% macro dynamictext(element, send_to_jinja, heightType) -%}
<div style="position:{%- if heightType != 'fixed' -%}relative{% else %}absolute{%- endif -%}; {%- if heightType == 'fixed' -%}top: {%- else -%}margin-top: {%- endif -%}{{ element.startY }}px; left:{{ element.startX }}px;{% if element.isFixedSize %}width:{{ element.width }}px; {%- if heightType == 'fixed' -%}height:{{ element.height }}px; {%- endif -%} {% else %} width:fit-content; height:fit-content; white-space:nowrap; max-width: {{ (settings.page.width - settings.page.marginLeft - settings.page.marginRight - element.startX) + 2 }}px;{%endif%}" class="
{{ element.classes | join(' ') }}">
<div style="{% if element.isFixedSize %}width:{{ element.width }}px; {%- if not is_parent_dynamic_height -%}height:{{ element.height }}px; {%- endif -%}{% else %}width:fit-content; height:fit-content; white-space:nowrap; max-width: {{ (settings.page.width - settings.page.marginLeft - settings.page.marginRight - element.startX) + 2 }}px;{%endif%} {{convert_css(element.style)}}"
<div style="{% if element.isFixedSize %}width:{{ element.width }}px; {%- if heightType == 'fixed' -%}height:{{ element.height }}px; {%- endif -%}{% else %}width:fit-content; height:fit-content; white-space:nowrap; max-width: {{ (settings.page.width - settings.page.marginLeft - settings.page.marginRight - element.startX) + 2 }}px;{%endif%} {{convert_css(element.style)}}"
class="dynamicText {{ element.classes | join(' ') }}">
{% for field in element.dynamicContent %}
<!-- third Arg is row which is not sent outside table -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{% macro rectangle(element, render_element, send_to_jinja, is_parent_dynamic_height) -%}
{% macro rectangle(element, render_element, send_to_jinja, heightType) -%}
{%- set heightType = element.get("heightType") -%}
{%- if settings.get("schema_version") == "1.1.0" -%}
{%- set heightType = "auto" if element.get("isDynamicHeight", False) else "fixed" -%}
{%- endif -%}
<div id="{{ element.id }}" style="position:{%- if is_parent_dynamic_height != 'fixed' -%}relative{% else %}absolute{%- endif -%}; {%- if is_parent_dynamic_height == 'fixed' -%}top: {%- else -%}margin-top: {%- endif -%}{{ element.startY }}px; left:{{ element.startX }}px; width:{{ element.width }}px; {%- if heightType != 'auto' -%} {%- if heightType == 'auto-min-height' -%}min-{%- endif -%}height:{{ element.height }}px; {%- endif -%} {{convert_css(element.style)}}"
<div id="{{ element.id }}" style="position:{%- if heightType != 'fixed' -%}relative{% else %}absolute{%- endif -%}; {%- if heightType == 'fixed' -%}top: {%- else -%}margin-top: {%- endif -%}{{ element.startY }}px; left:{{ element.startX }}px; width:{{ element.width }}px; {%- if heightType != 'auto' -%} {%- if heightType == 'auto-min-height' -%}min-{%- endif -%}height:{{ element.height }}px; {%- endif -%} {{convert_css(element.style)}}"
class="rectangle {{ element.classes | join(' ') }}">
{% if element.childrens %}
{% for object in element.childrens %}
{{ render_element(object, send_to_jinja, is_parent_dynamic_height) }}
{{ render_element(object, send_to_jinja, heightType) }}
{% endfor %}
{% endif %}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
{% from 'print_designer/page/print_designer/jinja/macros/table.html' import table with context %}


{% macro render_element(element, send_to_jinja, is_parent_dynamic_height = 'fixed') -%}
{% macro render_element(element, send_to_jinja, heightType = 'fixed') -%}
{% if element.type == "rectangle" %}
{{ rectangle(element, render_element, send_to_jinja, is_parent_dynamic_height) }}
{{ rectangle(element, render_element, send_to_jinja, heightType) }}
{% elif element.type == "image" %}
{{image(element)}}
{% elif element.type == "table" %}
{{table(element, send_to_jinja, is_parent_dynamic_height)}}
{{table(element, send_to_jinja, heightType)}}
{% elif element.type == "text" %}
{% if element.isDynamic %}
{{dynamictext(element, send_to_jinja, is_parent_dynamic_height)}}
{{dynamictext(element, send_to_jinja, heightType)}}
{% else%}
{{statictext(element, send_to_jinja, is_parent_dynamic_height)}}
{{statictext(element, send_to_jinja, heightType)}}
{% endif %}
{% elif element.type == "barcode" %}
{{barcode(element, send_to_jinja)}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- third Arg in render_user_text is row which is not sent outside table -->
{% macro statictext(element, send_to_jinja, is_parent_dynamic_height) -%}
<div style="position:{%- if is_parent_dynamic_height != 'fixed' -%}relative{% else %}absolute{%- endif -%}; {%- if is_parent_dynamic_height == 'fixed' -%}top: {%- else -%}margin-top: {%- endif -%}{{ element.startY }}px; left:{{ element.startX }}px;{% if element.isFixedSize %}width:{{ element.width }}px;{%- if is_parent_dynamic_height == 'fixed' -%}height:{{ element.height }}px; {%- endif -%}{% else %}width:fit-content; height:fit-content; max-width: {{ (settings.page.width - settings.page.marginLeft - settings.page.marginRight - element.startX) + 2 }}px; white-space:nowrap; {%endif%}" class="
{% macro statictext(element, send_to_jinja, heightType) -%}
<div style="position:{%- if heightType != 'fixed' -%}relative{% else %}absolute{%- endif -%}; {%- if heightType == 'fixed' -%}top: {%- else -%}margin-top: {%- endif -%}{{ element.startY }}px; left:{{ element.startX }}px;{% if element.isFixedSize %}width:{{ element.width }}px;{%- if heightType == 'fixed' -%}height:{{ element.height }}px; {%- endif -%}{% else %}width:fit-content; height:fit-content; max-width: {{ (settings.page.width - settings.page.marginLeft - settings.page.marginRight - element.startX) + 2 }}px; white-space:nowrap; {%endif%}" class="
{{ element.classes | join(' ') }}">
<p style="{% if element.isFixedSize %}width:{{ element.width }}px; {%- if is_parent_dynamic_height == 'fixed' -%}height:{{ element.height }}px; {%- endif -%}{% else %}width:fit-content; height:fit-content; max-width: {{ (settings.page.width - settings.page.marginLeft - settings.page.marginRight - element.startX ) + 2 }}px; white-space:nowrap;{%endif%} {{convert_css(element.style)}}"
<p style="{% if element.isFixedSize %}width:{{ element.width }}px; {%- if heightType == 'fixed' -%}height:{{ element.height }}px; {%- endif -%}{% else %}width:fit-content; height:fit-content; max-width: {{ (settings.page.width - settings.page.marginLeft - settings.page.marginRight - element.startX ) + 2 }}px; white-space:nowrap;{%endif%} {{convert_css(element.style)}}"
class="staticText {{ element.classes | join(' ') }}">
{% if element.parseJinja %}
{{ render_user_text(element.content, doc, {}, send_to_jinja).get("message", "") }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% macro table(element, send_to_jinja, is_parent_dynamic_height) -%}
{% macro table(element, send_to_jinja, heightType) -%}
{%- set heightType = element.get("heightType") -%}
{%- if settings.get("schema_version") == "1.1.0" -%}
{%- set heightType = "auto" if element.get("isDynamicHeight", False) else "fixed" -%}
{%- endif -%}
<table style="position:{%- if is_parent_dynamic_height != 'fixed' -%}relative{% else %}absolute{%- endif -%}; {%- if is_parent_dynamic_height == 'fixed' -%}top: {%- else -%}margin-top: {%- endif -%}{{ element.startY }}px; left:{{ element.startX }}px; width:{{ element.width }}px;{%- if is_parent_dynamic_height != 'fixed' and heightType != 'auto' -%}{%- if heightType == 'auto-min-height' -%}min-{%- endif -%}height:{{ element.height }}px;{%- endif -%} max-width:{{ element.width }}px;" class="table-container printTable {{ element.classes | join(' ') }}">
<table style="position:{%- if heightType != 'fixed' -%}relative{% else %}absolute{%- endif -%}; {%- if heightType == 'fixed' -%}top: {%- else -%}margin-top: {%- endif -%}{{ element.startY }}px; left:{{ element.startX }}px; width:{{ element.width }}px;{%- if heightType != 'fixed' and heightType != 'auto' -%}{%- if heightType == 'auto-min-height' -%}min-{%- endif -%}height:{{ element.height }}px;{%- endif -%} max-width:{{ element.width }}px;" class="table-container printTable {{ element.classes | join(' ') }}">
<thead>
{% if element.columns %}
<tr>
Expand Down

0 comments on commit d4c18f8

Please sign in to comment.