render box, mechanism to pass custom buttons

This commit is contained in:
Mathieu Jaumotte 2021-07-29 11:20:45 +02:00
parent 4e9916534f
commit ad3fe7cf91
5 changed files with 36 additions and 23 deletions

View File

@ -6,6 +6,19 @@
{{ 'Resume Accompanying Course'|trans }} {{ 'Resume Accompanying Course'|trans }}
{% endblock %} {% endblock %}
{% macro button_person(person) %}
{% if person.isSharingHousehold %}
<li>
<a href="{{ chill_path_add_return_path('chill_person_household_summary', { 'household_id': person.getCurrentHousehold.id }) }}"
class="btn btn-misc">
<i class="fa fa-home"></i>
n°&nbsp;
{{ person.getCurrentHousehold.id }}
</a>
</li>
{% endif %}
{% endmacro %}
{% block content %} {% block content %}
<div class="accompanyingcourse-resume"> <div class="accompanyingcourse-resume">
@ -27,25 +40,11 @@
{% if participation.enddate is null %} {% if participation.enddate is null %}
<div class="item-bloc"> <div class="item-bloc">
{{ participation.person|chill_entity_render_box({ {{ participation.person|chill_entity_render_box({
'render': 'bloc', 'addLink': false, 'addInfo': true 'render': 'bloc', 'addLink': false, 'addInfo': true, 'customButtons': _self.button_person(participation.person)
}) }} }) }}
</div> </div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{# AJOUTER ACTIONS
<ul class="record_actions">
{% if p.person.isSharingHousehold %}
<li>
<a href="{{ chill_path_add_return_path('chill_person_household_summary', { 'household_id': p.person.getCurrentHousehold.id }) }}"
class="btn btn-misc">
<i class="fa fa-home"></i>
n°&nbsp;
{{ p.person.getCurrentHousehold.id }}
</a>
</li>
{% endif %}
</ul>
#}
</div> </div>
{% if withoutHousehold|length > 0 %} {% if withoutHousehold|length > 0 %}
{% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' with {} %} {% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' with {} %}

View File

@ -7,6 +7,7 @@
* addEntity bool * addEntity bool
* addInfo bool * addInfo bool
* hLevel integer * hLevel integer
* customButtons Twig\Markup (html)
#} #}
{% macro raw(person, options) %} {% macro raw(person, options) %}
@ -92,13 +93,17 @@
{%- endif -%} {%- endif -%}
</li> </li>
</ul> </ul>
{%- if is_granted('CHILL_PERSON_SEE', person) -%}
<ul class="record_actions"> <ul class="record_actions">
<li><a class="btn btn-show" target="_blank" title="{{ 'Show'|trans }}" {%- if is_granted('CHILL_PERSON_SEE', person) -%}
href="{{ path('chill_person_view', { person_id: person.id }) }}"></a> <li>
</li> <a class="btn btn-show" target="_blank" title="{{ 'Show'|trans }}"
href="{{ path('chill_person_view', { person_id: person.id }) }}"></a>
</li>
{%- endif -%}
{% if options['customButtons'] %}
{{ options['customButtons'] }}
{% endif %}
</ul> </ul>
{%- endif -%}
</div> </div>
</div> </div>
{%- endif -%} {%- endif -%}

View File

@ -58,6 +58,7 @@ class PersonRender extends AbstractChillEntityRender
'addEntity' => $options['addEntity'] ?? false, 'addEntity' => $options['addEntity'] ?? false,
'addInfo' => $options['addInfo'] ?? false, 'addInfo' => $options['addInfo'] ?? false,
'hLevel' => $options['hLevel'] ?? 3, 'hLevel' => $options['hLevel'] ?? 3,
'customButtons' => $options['customButtons'] ?? null,
]; ];
return return

View File

@ -8,6 +8,7 @@
* addEntity bool * addEntity bool
* addInfo bool * addInfo bool
* hLevel integer * hLevel integer
* customButtons Twig\Markup (html)
#} #}
{% macro raw(thirdparty, options) %} {% macro raw(thirdparty, options) %}
@ -77,9 +78,15 @@
</li> </li>
</ul> </ul>
<ul class="record_actions"> <ul class="record_actions">
<li> {%- if is_granted('CHILL_3PARTY_3PARTY_SHOW', thirdparty) -%}
<a href="{{ path('chill_3party_3party_show', { thirdparty_id: thirdparty.id }) }}" class="btn btn-show" target="_blank" title="Voir"></a> <li>
</li> <a class="btn btn-show" target="_blank" title="{{ 'Show'|trans }}"
href="{{ path('chill_3party_3party_show', { thirdparty_id: thirdparty.id }) }}"></a>
</li>
{% endif %}
{% if options['customButtons'] %}
{{ options['customButtons'] }}
{% endif %}
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -52,6 +52,7 @@ class ThirdPartyRender extends AbstractChillEntityRender
'addEntity' => $options['addEntity'] ?? false, 'addEntity' => $options['addEntity'] ?? false,
'addInfo' => $options['addInfo'] ?? false, 'addInfo' => $options['addInfo'] ?? false,
'hLevel' => $options['hLevel'] ?? 3, 'hLevel' => $options['hLevel'] ?? 3,
'customButtons' => $options['customButtons'] ?? null,
]; ];
return return