Skip to content

Commit

Permalink
fix: improve handling for other fields
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Samk13 committed Dec 6, 2024
1 parent 9c97131 commit 95c5d20
Showing 1 changed file with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -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>
Expand Down Expand Up @@ -160,24 +165,27 @@ <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 %}


{% 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 %}
Expand Down

0 comments on commit 95c5d20

Please sign in to comment.