From 6bcc28b4bb438d73d2ce61f78c9f7a7fec355304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 11 Jul 2022 15:57:38 +0200 Subject: [PATCH] feature: hide course when the period is not active for the user, in search results and list of periods for a person --- .../views/AccompanyingPeriod/_list.html.twig | 50 +++++++++++++++++-- .../views/Person/list_with_period.html.twig | 3 +- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig index 307c462e2..986392056 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig @@ -48,13 +48,57 @@ {% endmacro %} {% block content %} -
- {% for period in accompanying_periods %} + {%- set acps = [] %} + {%- set acpsClosed = [] %} + {% for acp in accompanying_periods %} + {% if acp.step == 'CLOSED' or (acp.requestorPerson is not same as(person) and acp.openParticipationContainsPerson(person) is null ) %} + {%- set acpsClosed = acpsClosed|merge([acp]) %} + {% else %} + {%- set acps = acps|merge([acp]) %} + {% endif %} + {% endfor %} +
+ {% for period in acps %} {% include 'ChillPersonBundle:AccompanyingPeriod:_list_item.html.twig' with { 'recordAction': _self.recordAction(period, contextEntity) } %} - + {% else %} +

{{ 'Any accompanying periods are open'|trans }}

{% endfor %}
+ + {% if acpsClosed|length > 0 %} +
+
+

+ +

+ +
+ +
+ {% for period in acpsClosed %} + {% include 'ChillPersonBundle:AccompanyingPeriod:_list_item.html.twig' with { + 'recordAction': _self.recordAction(period, contextEntity) + } %} + {% endfor %} +
+ +
+
+
+ {% endif %} {% endblock content %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig index 886fa791b..8cc0128a5 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig @@ -235,7 +235,8 @@ {%- set acpsClosed = [] %} {%- for acp in person.accompanyingPeriodInvolved %} {%- if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', acp) %} - {% if acp.step == 'CLOSED' %} + {# filter for "current" periods: either the person is a requestor, or is member of the period and not closed #} + {% if acp.step == 'CLOSED' or (acp.requestorPerson is not same as(person) and acp.openParticipationContainsPerson(person) is null ) %} {%- set acpsClosed = acpsClosed|merge([acp]) %} {% else %} {%- set acps = acps|merge([acp]) %}