[CARD][Note] Refactor notification targets

This commit is contained in:
Eliseu Amaro 2022-03-12 11:56:17 +00:00
parent d91bc5ec66
commit 1244f64bb2
Signed by: eliseuamaro
GPG Key ID: 96DA09D4B97BC2D5
1 changed files with 34 additions and 20 deletions

View File

@ -93,28 +93,42 @@
</header> </header>
{% endblock note_info %} {% endblock note_info %}
{% macro mention_anchor(target) %}
<a href='{{target.getUrl()}}'>{{mention(target)}}<a>
{% endmacro mention_anchor %}
{% block note_context %} {% block note_context %}
{% set notification_targets = note.getNotificationTargets() %} {% set notification_targets = note.getNotificationTargets() %}
{% if notification_targets is not empty %} {% set notification_targets_individuals = notification_targets|filter(nt => nt.isGroup() == false) %}
{% for target in notification_targets %} {% set mention_individuals = [] %}
{% if target.isGroup() %} {% for target in notification_targets_individuals %}
<em tabindex="0" {% set mention_individuals = mention_individuals|merge([_self.mention_anchor(target)]) %}
class="note-replies-parent" {% endfor %}
title="{% trans %}The group in which this note was addressed to{% endtrans %}">
{% set mentionAnchor %}<a href="{{ target.getUrl() }}">{{ mention(target) | raw }}</a>{% endset %} {% set notification_targets_groups = notification_targets|filter(nt => nt.isGroup()) %}
{% trans %}in %mentionAnchor%{% endtrans %} {% set mention_groups = [] %}
</em> {% for target in notification_targets_groups %}
{% else %} {% set mention_groups = mention_groups|merge([_self.mention_anchor(target)]) %}
<em tabindex="0" {% endfor %}
class="note-replies-parent"
title="{% trans %}Whom this is a reply to{% endtrans %}" {% if notification_targets_individuals is not empty %}
aria-flowto="note-anchor-{{ note.getReplyTo() }}"> <em tabindex="0"
{% set replyAnchor %}<a href="{{ note.getConversationUrl() ~ "#note-anchor-" ~ note.getReplyTo() }}">{% endset %} class="note-replies-parent"
{% set mentionAnchor %}<a href="{{ target.getUrl() }}">{{ mention(target) | raw }}</a>{% endset %} title="{{'Whom this is a reply to' | trans}}"
{% trans %}%replyAnchor% in reply to %mentionAnchor%{% endtrans %} aria-flowto="note-anchor-{{ note.getReplyTo() }}">
</em> {% set mentions_anchors = mention_individuals|join(' ⃕ ') %}
{% endif %} <a href="{{ note.getConversationUrl() ~ '#note-anchor-' ~ note.getReplyTo() }}">{% trans %}in reply to %mentions_anchors%{% endtrans %}</a>
{% endfor %} </em>
{% endif %}
{% if notification_targets_groups is not empty %}
<em tabindex="0"
class="note-replies-parent"
title="{{'Group/Organisation this note is intended for' | trans}}"
aria-flowto="note-anchor-{{ note.getReplyTo() }}">
{% set mentions_anchors = mention_groups|join(', ', ' and ') %}
{% trans %}in %mentions_anchors%{% endtrans %}
</em>
{% endif %} {% endif %}
{% endblock note_context %} {% endblock note_context %}