From 485243e1a0beba3b62d7ebba5a60ab70bab6772b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= Date: Mon, 12 Dec 2022 17:54:13 +0100 Subject: [PATCH] wcs: card cell & link entry with file field (#71984) --- combo/apps/wcs/templates/combo/wcs/card.html | 25 ++++-- .../wcs/templates/combo/wcs/cards-field.html | 43 ++++++---- combo/apps/wcs/templates/combo/wcs/cards.html | 3 +- .../wcs/manager/card-cell-form-display.html | 12 +-- combo/manager/static/js/combo.manager.js | 58 ++++++++++--- tests/wcs/test_card.py | 85 ++++++++++++++++++- 6 files changed, 183 insertions(+), 43 deletions(-) diff --git a/combo/apps/wcs/templates/combo/wcs/card.html b/combo/apps/wcs/templates/combo/wcs/card.html index e324b7ef..89b25067 100644 --- a/combo/apps/wcs/templates/combo/wcs/card.html +++ b/combo/apps/wcs/templates/combo/wcs/card.html @@ -33,14 +33,27 @@ {% endif %} {% elif item.varname == "@link@" %} - {% if item.template and item.page|default:item.url_template %} + {% firstof item.link_field item.page item.url_template as link %} + {% if item.template and link %}
- {% with item.page|default:item.url_template as url_key %} - {% with card.custom_fields|get:item.template|force_escape as link_label and card.urls|get:url_key|force_escape as link_url %} - {% if link_label and link_url %} - + {% with card.custom_fields|get:item.template|force_escape as link_label %} + {% if link_label %} + {% if item.link_field %} + {% with fields_by_varnames|get:item.link_field as field and card.fields|get:item.link_field as value %} + {% if field and value and field.type == 'file' %} + + {% endif %} + {% endwith %} + {% else %} + {% with item.page|default:item.url_template as url_key %} + {% with card.urls|get:url_key|force_escape as link_url %} + {% if link_url %} + + {% endif %} + {% endwith %} + {% endwith %} {% endif %} - {% endwith %} + {% endif %} {% endwith %}
{% endif %} diff --git a/combo/apps/wcs/templates/combo/wcs/cards-field.html b/combo/apps/wcs/templates/combo/wcs/cards-field.html index d008327d..6e9d0444 100644 --- a/combo/apps/wcs/templates/combo/wcs/cards-field.html +++ b/combo/apps/wcs/templates/combo/wcs/cards-field.html @@ -6,28 +6,37 @@ {% endwith %} {% endif %} {% elif item.varname == "@link@" %} - {% if item.template and item.page|default:item.url_template %} - {% with item.page|default:item.url_template as url_key %} - {% with card.custom_fields|get:item.template|force_escape as link_label and card.urls|get:url_key|force_escape as link_url %} - {% if not ul_display %}{% endif %} - {% if link_label and link_url %} - {{ link_label }} + {% firstof item.link_field item.page item.url_template as link %} + {% if item.template and link %} + {% if not ul_display %}{% endif %} + {% with card.custom_fields|get:item.template|force_escape as link_label %} + {% if link_label %} + {% if item.link_field %} + {% with fields_by_varnames|get:item.link_field as field and card.fields|get:item.link_field as value %} + {% if field and value and field.type == 'file' %} + {{ link_label }} + {% endif %} + {% endwith %} + {% else %} + {% with item.page|default:item.url_template as url_key %} + {% with card.urls|get:url_key|force_escape as link_url %} + {% if link_url %} + {{ link_label }} + {% endif %} + {% endwith %} + {% endwith %} {% endif %} - {% if not ul_display %}{% endif %} - {% endwith %} + {% endif %} {% endwith %} + {% if not ul_display %}{% endif %} {% endif %} {% else %} {% if item.varname %} - {% with fields_by_varnames|get:item.varname as field %} - {% if field %} - {% with card.fields|get:item.varname as value %} - {% if value %} - {% if not ul_display %}{% endif %}{% include "combo/wcs/card-field-value.html" with mode='inline' %}{% if not ul_display %}{% endif %} - {% else %} - {% if not ul_display %}{% endif %}{% include "combo/wcs/card-field-value.html" with mode='inline' value=item.empty_value %}{% if not ul_display %}{% endif %} - {% endif %} - {% endwith %} + {% with fields_by_varnames|get:item.varname as field and card.fields|get:item.varname as value %} + {% if field and value %} + {% if not ul_display %}{% endif %}{% include "combo/wcs/card-field-value.html" with mode='inline' %}{% if not ul_display %}{% endif %} + {% elif field %} + {% if not ul_display %}{% endif %}{% include "combo/wcs/card-field-value.html" with mode='inline' value=item.empty_value %}{% if not ul_display %}{% endif %} {% endif %} {% endwith %} {% endif %} diff --git a/combo/apps/wcs/templates/combo/wcs/cards.html b/combo/apps/wcs/templates/combo/wcs/cards.html index 36f69034..c8dd72a7 100644 --- a/combo/apps/wcs/templates/combo/wcs/cards.html +++ b/combo/apps/wcs/templates/combo/wcs/cards.html @@ -20,7 +20,8 @@ {{ item.header|default:"" }} {% endif %} {% elif item.varname == "@link@" %} - {% if item.template and item.page|default:item.url_template %} + {% firstof item.link_field item.page item.url_template as link %} + {% if item.template and link %} {{ item.header|default:"" }} {% endif %} {% else %} diff --git a/combo/apps/wcs/templates/combo/wcs/manager/card-cell-form-display.html b/combo/apps/wcs/templates/combo/wcs/manager/card-cell-form-display.html index 494719ec..244e72c5 100644 --- a/combo/apps/wcs/templates/combo/wcs/manager/card-cell-form-display.html +++ b/combo/apps/wcs/templates/combo/wcs/manager/card-cell-form-display.html @@ -127,12 +127,12 @@

@@ -166,7 +166,7 @@

- -