From 42a14fbd6b6f180136590b91e723a9e56bc83cf7 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 10 Jan 2022 16:55:01 +0100 Subject: [PATCH] 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' ! --- .../views/AccompanyingPeriod/_list.html.twig | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig index 413080a78..307c462e2 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig @@ -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 ... #}
  • {# {{ 'See this period'|trans }} #}
  • - {% if period.step == 'DRAFT' %} + {% if period.step == 'DRAFT' and contextEntity.type == 'person' %} + {% set person = contextEntity.entity %}
  • {# {{ 'Delete this period'|trans }} #}
  • {% endif %} + {# DISABLED if new accompanying course, this is not necessary {% if person is defined %}
  • @@ -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 %}