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 7789a358d0..bfe18b40ee 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 %} - <section id="additional-description-{{ loop.index }}" class="rel-mt-2 rich-input-content" - aria-label="{{ _( add_description.type.title_l10n ) if add_description.type is defined else 'Missing description!' }}"> - <h2>{{ 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('') %} + <section + id="additional-description-{{ loop.index }}" + class="rel-mt-2 rich-input-content" + aria-label="{{ (add_description.type.title_l10n if desc_type_defined else _('Missing description type!')) }}" + > + <h2> + {{ add_description.type.title_l10n if desc_type_defined else _('Missing description type!') }} <span class="text-muted language"> - {{ '(' + add_description.lang.title_l10n + ')' if add_description.lang is defined else '' }} + {{ '(' ~ add_description.lang.title_l10n ~ ')' if add_description.lang is defined else '' }} </span> </h2> - - {% if add_description.type is defined and add_description.type.id == "notes" %} + {% if desc_type_defined and add_description.type.id == "notes" %} <div class="ui message warning"> - {{ add_description.description | sanitize_html() | safe }} + {{ desc_text | sanitize_html() | safe }} </div> {% else %} - {{ add_description.description | sanitize_html() | safe }} + {{ desc_text | sanitize_html() | safe }} {% endif %} </section> {% endfor %} @@ -82,7 +87,7 @@ <h2>{{ add_description.type.title_l10n if add_description.type is defined else _ {% macro show_dates(dates) %} {% for date in dates %} - <dt class="ui tiny header">{{ date.type.title_l10n }}</dt> + <dt class="ui tiny header">{{ date.type.title_l10n if date.type is defined else _('Unknown date type') }}</dt> <dd> <div>{{ date.date }}</div> <div class="text-muted">{{ date.description }}</div> @@ -160,16 +165,19 @@ <h2>{{ 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 %} <a href="{{ url }}" target="_blank" title="{{ _('Opens in new tab') }}"> - {{ identifier.identifier }} + {{ ident_val }} </a> {% else %} - {{ identifier.identifier }} + {{ ident_val }} {% endif %} - {{ ' (' + identifier.scheme | get_scheme_label + ')' }} + {% if identifier.scheme is defined %} + {{ ' (' ~ (identifier.scheme|get_scheme_label) ~ ')' }} + {% endif %} </dd> {% endfor %} {% endmacro %} @@ -177,7 +185,7 @@ <h2>{{ add_description.type.title_l10n if add_description.type is defined else _ {% macro show_related_identifiers(related_identifiers) %} <dl class="details-list"> - {%- 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') %} <dt class="ui tiny header">{{ group.grouper }}</dt> {{ _identifiers_for_group(group.list) }} {%- endfor %}