feature: hide course when the period is not active for the user, in search results and list of periods for a person

This commit is contained in:
Julien Fastré 2022-07-11 15:57:38 +02:00
parent a79a2b6ee9
commit 6bcc28b4bb
2 changed files with 49 additions and 4 deletions

View File

@ -48,13 +48,57 @@
{% endmacro %}
{% block content %}
<div class="flex-table accompanyingcourse-list">
{% 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 %}
<div class="flex-table accompanyingcourse-list">
{% for period in acps %}
{% include 'ChillPersonBundle:AccompanyingPeriod:_list_item.html.twig' with {
'recordAction': _self.recordAction(period, contextEntity)
} %}
{% else %}
<p class="chill-no-data-statement">{{ 'Any accompanying periods are open'|trans }}</p>
{% endfor %}
</div>
{% if acpsClosed|length > 0 %}
<div class="accordion" id="member_{{ person.id }}">
<div class="accordion-item">
<h2 class="accordion-header" id="heading_{{ person.id }}">
<button
class="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse_{{ person.id }}"
aria-expanded="false"
aria-controls="collapse_{{ person.id }}">
<span class="folded">{{ 'periods.show closed periods'|trans({ 'nb_items': acpsClosed|length }) }}</span>
<span class="unfolded text-secondary">{{ 'periods.hide closed periods'|trans({ 'nb_items': acpsClosed|length }) }}</span>
</button>
</h2>
<div id="collapse_{{ person.id }}"
class="accordion-collapse collapse"
aria-labelledby="heading_{{ person.id }}"
data-bs-parent="#nonCurrent">
<div class="flex-table accompanyingcourse-list">
{% for period in acpsClosed %}
{% include 'ChillPersonBundle:AccompanyingPeriod:_list_item.html.twig' with {
'recordAction': _self.recordAction(period, contextEntity)
} %}
{% endfor %}
</div>
</div>
</div>
</div>
{% endif %}
{% endblock content %}

View File

@ -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]) %}