wcs: add subtitle display mode for card cell custom schema (#60369)
This commit is contained in:
parent
980fafe428
commit
1be114cafe
|
@ -20,7 +20,9 @@
|
|||
{% if item.varname == "@custom@" and item.template %}
|
||||
{% with card.custom_fields|get:item.template|force_escape as value %}
|
||||
{% if item.display_mode == "title" %}
|
||||
<h3>{{ value }}</h3>
|
||||
<h3>{{ value }}</h3>
|
||||
{% elif item.display_mode == "subtitle" %}
|
||||
<h4>{{ value }}</h4>
|
||||
{% elif item.display_mode == "label" %}
|
||||
<p class="label">{{ value }}</p>
|
||||
{% elif item.display_mode == "text" %}
|
||||
|
@ -37,6 +39,12 @@
|
|||
{% elif item.field_content == "value" %}
|
||||
<h3>{% include "combo/wcs/card-field-value.html" with mode="inline" %}</h3>
|
||||
{% endif %}
|
||||
{% elif item.display_mode == "subtitle" %}
|
||||
{% if item.field_content == "label" %}
|
||||
<h4>{{ field.label }}</h4>
|
||||
{% elif item.field_content == "value" %}
|
||||
<h4>{% include "combo/wcs/card-field-value.html" with mode="inline" %}</h4>
|
||||
{% endif %}
|
||||
{% elif item.display_mode == "text" %}
|
||||
{% if item.field_content == "label" or item.field_content == "label-and-value" %}
|
||||
<p class="label">{{ field.label }}</p>
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
<select name="field_display_mode" data-dynamic-display-child-of="entry_type" data-dynamic-display-value="@field@">
|
||||
<option value="text">{% trans "Text" %}</option>
|
||||
<option value="title">{% trans "Title" %}</option>
|
||||
<option value="subtitle">{% trans "Subtitle" %}</option>
|
||||
</select>
|
||||
</label>
|
||||
</p>
|
||||
|
@ -85,6 +86,7 @@
|
|||
<option value="label">{% trans "Label" %}</option>
|
||||
<option value="text">{% trans "Text" %}</option>
|
||||
<option value="title">{% trans "Title" %}</option>
|
||||
<option value="subtitle">{% trans "Subtitle" %}</option>
|
||||
</select>
|
||||
</label>
|
||||
</p>
|
||||
|
|
|
@ -2090,11 +2090,29 @@ def test_card_cell_render_custom_schema_card_field(mock_send, context):
|
|||
result = cell.render(context)
|
||||
assert PyQuery(result).find('h3').text() == 'a'
|
||||
|
||||
cell.custom_schema['cells'][0] = {
|
||||
'varname': 'fielda',
|
||||
'field_content': 'value',
|
||||
'display_mode': 'subtitle',
|
||||
}
|
||||
cell.save()
|
||||
result = cell.render(context)
|
||||
assert PyQuery(result).find('h4').text() == 'a'
|
||||
|
||||
cell.custom_schema['cells'][0] = {'varname': 'fielda', 'field_content': 'label', 'display_mode': 'title'}
|
||||
cell.save()
|
||||
result = cell.render(context)
|
||||
assert PyQuery(result).find('h3').text() == 'Field A'
|
||||
|
||||
cell.custom_schema['cells'][0] = {
|
||||
'varname': 'fielda',
|
||||
'field_content': 'label',
|
||||
'display_mode': 'subtitle',
|
||||
}
|
||||
cell.save()
|
||||
result = cell.render(context)
|
||||
assert PyQuery(result).find('h4').text() == 'Field A'
|
||||
|
||||
cell.custom_schema['cells'][0] = {'varname': 'fielda', 'field_content': 'label', 'display_mode': 'text'}
|
||||
cell.save()
|
||||
result = cell.render(context)
|
||||
|
@ -2228,9 +2246,10 @@ def test_card_cell_render_custom_schema_custom_entry(mock_send, context, app):
|
|||
cell.custom_schema['cells'][0][
|
||||
'template'
|
||||
] = '{{ card.fields.fielda }} - {{ card.fields.related }} ({{ card.fields.related_structured.id }})'
|
||||
cell.custom_schema['cells'][0]['display_mode'] = 'subtitle'
|
||||
cell.save()
|
||||
result = cell.render(context)
|
||||
assert PyQuery(result).find('h3').text() == 'a - Foo Bar (42)'
|
||||
assert PyQuery(result).find('h4').text() == 'a - Foo Bar (42)'
|
||||
|
||||
# test display_mode & filters in template
|
||||
cell.custom_schema = {
|
||||
|
|
Loading…
Reference in New Issue