From 95c5d20c440b5d10b0a2b2ac47c6a477696394c2 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Fri, 6 Dec 2024 12:25:21 +0100 Subject: [PATCH] fix: improve handling for other fields * fix show_dates * fix _identifiers_for_group * fix show_related_identifiers by filtering with selectattr: https://jinja.palletsprojects.com/en/stable/templates/#jinja-filters.selectattr --- .../records/macros/detail.html | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html b/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html index 7789a358d..bfe18b40e 100644 --- a/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html +++ b/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html @@ -60,20 +60,25 @@ {% macro show_add_descriptions(add_descriptions) %} {% for add_description in add_descriptions %} -
-

{{ add_description.type.title_l10n if add_description.type is defined else _('Missing Additional description type!') }} + {% set desc_type_defined = add_description.type is defined %} + {% set desc_text = add_description.description|default('') %} +
+

+ {{ add_description.type.title_l10n if desc_type_defined else _('Missing description type!') }} - {{ '(' + add_description.lang.title_l10n + ')' if add_description.lang is defined else '' }} + {{ '(' ~ add_description.lang.title_l10n ~ ')' if add_description.lang is defined else '' }}

- - {% if add_description.type is defined and add_description.type.id == "notes" %} + {% if desc_type_defined and add_description.type.id == "notes" %}
- {{ add_description.description | sanitize_html() | safe }} + {{ desc_text | sanitize_html() | safe }}
{% else %} - {{ add_description.description | sanitize_html() | safe }} + {{ desc_text | sanitize_html() | safe }} {% endif %}
{% endfor %} @@ -82,7 +87,7 @@

{{ add_description.type.title_l10n if add_description.type is defined else _ {% macro show_dates(dates) %} {% for date in dates %} -
{{ date.type.title_l10n }}
+
{{ date.type.title_l10n if date.type is defined else _('Unknown date type') }}
{{ date.date }}
{{ date.description }}
@@ -160,16 +165,19 @@

{{ add_description.type.title_l10n if add_description.type is defined else _ {{ identifier.resource_type.title_l10n }}: {% endif %} - {% set url = identifier.identifier|pid_url %} + {% set ident_val = identifier.identifier if identifier.identifier is defined else '' %} + {% set url = ident_val|pid_url %} {% if url %} - {{ identifier.identifier }} + {{ ident_val }} {% else %} - {{ identifier.identifier }} + {{ ident_val }} {% endif %} - {{ ' (' + identifier.scheme | get_scheme_label + ')' }} + {% if identifier.scheme is defined %} + {{ ' (' ~ (identifier.scheme|get_scheme_label) ~ ')' }} + {% endif %}

{% endfor %} {% endmacro %} @@ -177,7 +185,7 @@

{{ add_description.type.title_l10n if add_description.type is defined else _ {% macro show_related_identifiers(related_identifiers) %}
- {%- for group in related_identifiers | groupby('relation_type.title_l10n') %} + {%- for group in (related_identifiers|selectattr("relation_type","defined")|list) | groupby('relation_type.title_l10n') %}
{{ group.grouper }}
{{ _identifiers_for_group(group.list) }} {%- endfor %}