wcs: don't add cell's div if empty value have to be skipped (#64451)
This commit is contained in:
parent
096d396c84
commit
ebab8fdb4e
|
@ -1,11 +1,9 @@
|
|||
{% if item.field_content == "label" %}
|
||||
{% if value or item.empty_value != '@skip@' %}
|
||||
<{{ title_tag }}>{{ field.label }}</{{ title_tag }}>
|
||||
{% endif %}
|
||||
<{{ title_tag }}>{{ field.label }}</{{ title_tag }}>
|
||||
{% elif item.field_content == "value" %}
|
||||
{% if value or item.empty_value == '@empty@' %}
|
||||
<{{ title_tag }}>{% include "combo/wcs/card-field-value.html" with mode="inline" %}</{{ title_tag }}>
|
||||
{% elif item.empty_value != '@skip@' and item.empty_value != '@empty@' %}
|
||||
{% else %}
|
||||
{% with item.empty_value as value %}
|
||||
<{{ title_tag }}>{% include "combo/wcs/card-field-value.html" with mode="inline" %}</{{ title_tag }}>
|
||||
{% endwith %}
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
{% with cell.get_custom_schema as custom_schema %}
|
||||
<div class="{{ custom_schema.grid_class }}">
|
||||
{% for item in custom_schema.cells %}
|
||||
<div class="{{ item.cell_size|default:"" }}">
|
||||
{% if item.varname == "@custom@" and item.template %}
|
||||
<div class="{{ item.cell_size|default:"" }}">
|
||||
{% with card.custom_fields|get:item.template|force_escape as value %}
|
||||
{% if item.display_mode == "title" %}
|
||||
<h3>{{ value }}</h3>
|
||||
|
@ -29,14 +29,19 @@
|
|||
<div class="value">{{ value }}</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% elif item.varname == "@link@" and item.url_template and item.template %}
|
||||
<div class="{{ item.cell_size|default:"" }}">
|
||||
{% with card.custom_fields|get:item.template|force_escape as link_label and card.urls|get:item.url_template|force_escape as link_url %}
|
||||
<div class="value"><a href="{{ link_url }}"{% if item.display_mode == 'button' %} class="pk-button"{% endif %}>{{ link_label }}</a></div>
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% with fields_by_varnames|get:item.varname as field %}
|
||||
{% if field %}
|
||||
{% with card.fields|get:item.varname as value %}
|
||||
{% if value or item.empty_value != '@skip@' %}
|
||||
<div class="{{ item.cell_size|default:"" }}">
|
||||
{% if item.display_mode == "title" %}
|
||||
{% include "combo/wcs/card-field-as-title.html" with title_tag="h3" %}
|
||||
{% elif item.display_mode == "subtitle" %}
|
||||
|
@ -44,17 +49,18 @@
|
|||
{% elif item.display_mode == "text" %}
|
||||
{% if value or item.empty_value == '@empty@' %}
|
||||
{% include "combo/wcs/card-field-as-text.html" %}
|
||||
{% elif item.empty_value != '@skip@' and item.empty_value != '@empty@' %}
|
||||
{% else %}
|
||||
{% with item.empty_value as value %}
|
||||
{% include "combo/wcs/card-field-as-text.html" %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor%}
|
||||
</div>
|
||||
{% endwith %}
|
||||
|
|
|
@ -2897,6 +2897,7 @@ def test_card_cell_render_custom_schema_card_empty_field(mock_send, context):
|
|||
context['synchronous'] = True # to get fresh content
|
||||
|
||||
result = cell.render(context)
|
||||
assert len(PyQuery(result).find('.cell--body > div > div')) == 0
|
||||
assert PyQuery(result).find('.label') == []
|
||||
assert PyQuery(result).find('.value') == []
|
||||
|
||||
|
@ -2908,6 +2909,7 @@ def test_card_cell_render_custom_schema_card_empty_field(mock_send, context):
|
|||
}
|
||||
cell.save()
|
||||
result = cell.render(context)
|
||||
assert len(PyQuery(result).find('.cell--body > div > div')) == 1
|
||||
assert PyQuery(result).find('.label').text() == 'Empty'
|
||||
assert PyQuery(result).find('.value').text() == ''
|
||||
|
||||
|
@ -2919,6 +2921,7 @@ def test_card_cell_render_custom_schema_card_empty_field(mock_send, context):
|
|||
}
|
||||
cell.save()
|
||||
result = cell.render(context)
|
||||
assert len(PyQuery(result).find('.cell--body > div > div')) == 1
|
||||
assert PyQuery(result).find('.label').text() == 'Empty'
|
||||
assert PyQuery(result).find('.value').text() == 'Custom text'
|
||||
|
||||
|
@ -2940,6 +2943,7 @@ def test_card_cell_render_custom_schema_card_empty_field(mock_send, context):
|
|||
}
|
||||
cell.save()
|
||||
result = cell.render(context)
|
||||
assert len(PyQuery(result).find('.cell--body > div > div')) == 0
|
||||
assert PyQuery(result).find(html_tag) == []
|
||||
|
||||
cell.custom_schema['cells'][0] = {
|
||||
|
@ -2950,6 +2954,7 @@ def test_card_cell_render_custom_schema_card_empty_field(mock_send, context):
|
|||
}
|
||||
cell.save()
|
||||
result = cell.render(context)
|
||||
assert len(PyQuery(result).find('.cell--body > div > div')) == 1
|
||||
assert PyQuery(result).find(html_tag).text() == ('Empty' if field_content == 'label' else '')
|
||||
|
||||
cell.custom_schema['cells'][0] = {
|
||||
|
@ -2960,6 +2965,7 @@ def test_card_cell_render_custom_schema_card_empty_field(mock_send, context):
|
|||
}
|
||||
cell.save()
|
||||
result = cell.render(context)
|
||||
assert len(PyQuery(result).find('.cell--body > div > div')) == 1
|
||||
assert PyQuery(result).find(html_tag).text() == (
|
||||
'Empty' if field_content == 'label' else 'Custom text'
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue