AccompanyingPeriod list: manage context entity variable in record_actions buttons (TO BE CHECKED)

Need to pass context entity in record_actions buttons to use variables like 'person' !
This commit is contained in:
Mathieu Jaumotte 2022-01-10 16:55:01 +01:00
parent 46ca74fc70
commit 42a14fbd6b

View File

@ -1,15 +1,22 @@
{% macro recordAction(period, person = null) %}
{% if person is defined %}
{% set contextEntity = { 'type': 'person', 'entity': person } %}{% endif %}
{% if household is defined %}
{% set contextEntity = { 'type': 'household', 'entity': household } %}{% endif %}
{% macro recordAction(period, contextEntity) %}
{# TODO if enable_accompanying_course_with_multiple_persons is true ... #}
<li>
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': period.id }) }}"
class="btn btn-show" title="{{ 'See accompanying period'|trans }}">{# {{ 'See this period'|trans }} #}</a>
</li>
{% if period.step == 'DRAFT' %}
{% if period.step == 'DRAFT' and contextEntity.type == 'person' %}
{% set person = contextEntity.entity %}
<li>
<a href="{{ path('chill_person_accompanying_course_delete', { 'accompanying_period_id': period.id, 'person_id' : person.id }) }}"
class="btn btn-delete" title="{{ 'Delete accompanying period'|trans }}">{# {{ 'Delete this period'|trans }} #}</a>
</li>
{% endif %}
{# DISABLED if new accompanying course, this is not necessary
{% if person is defined %}
<li>
@ -45,7 +52,7 @@
{% for period in accompanying_periods %}
{% include 'ChillPersonBundle:AccompanyingPeriod:_list_item.html.twig' with {
'recordAction': _self.recordAction(period, person)
'recordAction': _self.recordAction(period, contextEntity)
} %}
{% endfor %}