0004-wcs-add-subtitle-display-mode-for-card-cell-custom-s.patch
combo/apps/wcs/templates/combo/wcs/card.html | ||
---|---|---|
19 | 19 |
{% if item.varname == "@custom@" and item.template %} |
20 | 20 |
{% with card.custom_fields|get:item.template|force_escape as value %} |
21 | 21 |
{% if item.display_mode == "title" %} |
22 |
<h3>{{ value }}</h3> |
|
22 |
<h3>{{ value }}</h3> |
|
23 |
{% elif item.display_mode == "subtitle" %} |
|
24 |
<h4>{{ value }}</h4> |
|
23 | 25 |
{% elif item.display_mode == "label" %} |
24 | 26 |
<p class="label">{{ value }}</p> |
25 | 27 |
{% elif item.display_mode == "text" %} |
... | ... | |
35 | 37 |
{% elif item.field_content == "value" %} |
36 | 38 |
<h3>{% include "combo/wcs/card-field-value.html" with mode="inline" %}</h3> |
37 | 39 |
{% endif %} |
40 |
{% elif item.display_mode == "subtitle" %} |
|
41 |
{% if item.field_content == "label" %} |
|
42 |
<h4>{{ field.label }}</h4> |
|
43 |
{% elif item.field_content == "value" %} |
|
44 |
<h4>{% include "combo/wcs/card-field-value.html" with mode="inline" %}</h4> |
|
45 |
{% endif %} |
|
38 | 46 |
{% elif item.display_mode == "text" %} |
39 | 47 |
{% if item.field_content == "label" or item.field_content == "label-and-value" %} |
40 | 48 |
<p class="label">{{ field.label }}</p> |
combo/apps/wcs/templates/combo/wcs/manager/card-infos-cell-form.html | ||
---|---|---|
68 | 68 |
{% trans "Display mode" %} |
69 | 69 |
<select name="field_display_mode" data-dynamic-display-child-of="entry_type" data-dynamic-display-value="@field@"> |
70 | 70 |
<option value="title">{% trans "Title" %}</option> |
71 |
<option value="subtitle">{% trans "Subtitle" %}</option> |
|
71 | 72 |
<option value="text">{% trans "Text" %}</option> |
72 | 73 |
</select> |
73 | 74 |
</label> |
... | ... | |
83 | 84 |
{% trans "Display mode" %} |
84 | 85 |
<select name="custom_display_mode" data-dynamic-display-child-of="entry_type" data-dynamic-display-value="@custom@"> |
85 | 86 |
<option value="title">{% trans "Title" %}</option> |
87 |
<option value="subtitle">{% trans "Subtitle" %}</option> |
|
86 | 88 |
<option value="label">{% trans "Label" %}</option> |
87 | 89 |
<option value="text">{% trans "Text" %}</option> |
88 | 90 |
</select> |
tests/test_wcs.py | ||
---|---|---|
2092 | 2092 |
result = cell.render(context) |
2093 | 2093 |
assert PyQuery(result).find('h3').text() == 'a' |
2094 | 2094 | |
2095 |
cell.custom_schema['cells'][0] = { |
|
2096 |
'varname': 'fielda', |
|
2097 |
'field_content': 'value', |
|
2098 |
'display_mode': 'subtitle', |
|
2099 |
} |
|
2100 |
cell.save() |
|
2101 |
result = cell.render(context) |
|
2102 |
assert PyQuery(result).find('h4').text() == 'a' |
|
2103 | ||
2095 | 2104 |
cell.custom_schema['cells'][0] = {'varname': 'fielda', 'field_content': 'label', 'display_mode': 'title'} |
2096 | 2105 |
cell.save() |
2097 | 2106 |
result = cell.render(context) |
2098 | 2107 |
assert PyQuery(result).find('h3').text() == 'Field A' |
2099 | 2108 | |
2109 |
cell.custom_schema['cells'][0] = { |
|
2110 |
'varname': 'fielda', |
|
2111 |
'field_content': 'label', |
|
2112 |
'display_mode': 'subtitle', |
|
2113 |
} |
|
2114 |
cell.save() |
|
2115 |
result = cell.render(context) |
|
2116 |
assert PyQuery(result).find('h4').text() == 'Field A' |
|
2117 | ||
2100 | 2118 |
cell.custom_schema['cells'][0] = {'varname': 'fielda', 'field_content': 'label', 'display_mode': 'text'} |
2101 | 2119 |
cell.save() |
2102 | 2120 |
result = cell.render(context) |
... | ... | |
2230 | 2248 |
cell.custom_schema['cells'][0][ |
2231 | 2249 |
'template' |
2232 | 2250 |
] = '{{ card.fields.fielda }} - {{ card.fields.related }} ({{ card.fields.related_structured.id }})' |
2251 |
cell.custom_schema['cells'][0]['display_mode'] = 'subtitle' |
|
2233 | 2252 |
cell.save() |
2234 | 2253 |
result = cell.render(context) |
2235 |
assert PyQuery(result).find('h3').text() == 'a - Foo Bar (42)'
|
|
2254 |
assert PyQuery(result).find('h4').text() == 'a - Foo Bar (42)'
|
|
2236 | 2255 | |
2237 | 2256 |
# test display_mode & filters in template |
2238 | 2257 |
cell.custom_schema = { |
2239 |
- |