render box, custom buttons before, after or remplacing default

This commit is contained in:
Mathieu Jaumotte 2021-07-29 14:06:00 +02:00
parent ad3fe7cf91
commit 39f6f14467
8 changed files with 55 additions and 33 deletions

View File

@ -10,10 +10,8 @@
{% if person.isSharingHousehold %}
<li>
<a href="{{ chill_path_add_return_path('chill_person_household_summary', { 'household_id': person.getCurrentHousehold.id }) }}"
class="btn btn-misc">
class="btn btn-chill-pink" title="{{ 'Show household'|trans ~ ' n° ' ~ person.getCurrentHousehold.id }}">
<i class="fa fa-home"></i>
n°&nbsp;
{{ person.getCurrentHousehold.id }}
</a>
</li>
{% endif %}
@ -40,7 +38,8 @@
{% if participation.enddate is null %}
<div class="item-bloc">
{{ participation.person|chill_entity_render_box({
'render': 'bloc', 'addLink': false, 'addInfo': true, 'customButtons': _self.button_person(participation.person)
'render': 'bloc', 'addLink': false, 'addInfo': true,
'customButtons': { 'before': _self.button_person(participation.person) }
}) }}
</div>
{% endif %}

View File

@ -1,13 +1,17 @@
{#
Template to render a person
* render [raw|label|bloc]
* render string ['raw'|'label'|'bloc']
OPTIONS
* addAltNames bool
* addLink bool
* addEntity bool
* addInfo bool
* hLevel integer
* customButtons Twig\Markup (html)
* addAltNames bool
* addLink bool
* addEntity bool
* addInfo bool
* hLevel integer
* customButtons [
'before' Twig\Markup, (injected with macro)
'replace' Twig\Markup,
'after' Twig\Markup
]
#}
{% macro raw(person, options) %}
@ -94,14 +98,21 @@
</li>
</ul>
<ul class="record_actions">
{%- if is_granted('CHILL_PERSON_SEE', person) -%}
{% if options['customButtons']['before'] is defined %}
{{ options['customButtons']['before'] }}
{% endif %}
{%- if options['customButtons']['replace'] is not defined and is_granted('CHILL_PERSON_SEE', person) -%}
<li>
<a class="btn btn-show" target="_blank" title="{{ 'Show'|trans }}"
<a class="btn btn-show" target="_blank" title="{{ 'Show person'|trans }}"
href="{{ path('chill_person_view', { person_id: person.id }) }}"></a>
</li>
{%- else -%}
{{ options['customButtons']['replace'] }}
{%- endif -%}
{% if options['customButtons'] %}
{{ options['customButtons'] }}
{% if options['customButtons']['after'] is defined %}
{{ options['customButtons']['after'] }}
{% endif %}
</ul>
</div>

View File

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

View File

@ -119,6 +119,7 @@ address_country_code: Code pays
'Alreay existing person': 'Dossiers déjà encodés'
'Add the person': 'Ajouter la personne'
Show person: Voir le dossier de la personne
'Confirm the creation': 'Confirmer la création'
'You will create this person': 'Vous allez créer le dossier suivant'
Return: Retour
@ -351,6 +352,7 @@ Addresses history for household: Historique des adresses
Household accompanying period: Parcours d'accompagnement du ménage
Household summary: Résumé du ménage
Edit household address: Modifier l'adresse du ménage
Show household: Voir le ménage
# accompanying course work
Accompanying Course Actions: Actions d'accompagnements

View File

@ -1,14 +1,17 @@
{#
Template to render a thirdparty
* render [raw|label|bloc]
* render string ['raw'|'label'|'bloc']
OPTIONS
* with_valid_from bool
* addAltNames bool
* addLink bool
* addEntity bool
* addInfo bool
* hLevel integer
* customButtons Twig\Markup (html)
* addLink bool
* addEntity bool
* addInfo bool
* hLevel integer
* customButtons [
'before' Twig\Markup, (injected with macro)
'replace' Twig\Markup,
'after' Twig\Markup
]
#}
{% macro raw(thirdparty, options) %}
@ -78,14 +81,21 @@
</li>
</ul>
<ul class="record_actions">
{%- if is_granted('CHILL_3PARTY_3PARTY_SHOW', thirdparty) -%}
{% if options['customButtons']['before'] is defined %}
{{ options['customButtons']['before'] }}
{% endif %}
{%- if options['customButtons']['replace'] is not defined and is_granted('CHILL_3PARTY_3PARTY_SHOW', thirdparty) -%}
<li>
<a class="btn btn-show" target="_blank" title="{{ 'Show'|trans }}"
<a class="btn btn-show" target="_blank" title="{{ 'Show thirdparty'|trans }}"
href="{{ path('chill_3party_3party_show', { thirdparty_id: thirdparty.id }) }}"></a>
</li>
{% endif %}
{% if options['customButtons'] %}
{{ options['customButtons'] }}
{%- else -%}
{{ options['customButtons']['replace'] }}
{%- endif -%}
{% if options['customButtons']['after'] is defined %}
{{ options['customButtons']['after'] }}
{% endif %}
</ul>
</div>

View File

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

View File

@ -1,6 +1,6 @@
services:
Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender:
arguments:
$templating: '@templating.engine.twig'
$engine: '@Symfony\Component\Templating\EngineInterface'
tags:
- 'chill.render_entity'
- 'chill.render_entity'

View File

@ -20,7 +20,7 @@ Third party updated: Le tiers a été mis à jour
Third party created: Le tiers a été créé
Active, shown to users: Actif, visible par les utilisateurs
Inactive, not shown to users: Inactif, invisible par les utilisateurs
Show thirdparty: Voir le tiers
The party is visible in those centers: Le tiers est visible dans ces centres
No third parties: Aucun tiers
@ -28,4 +28,4 @@ No third parties: Aucun tiers
# ROLES
CHILL_3PARTY_3PARTY_CREATE: Ajouter un Tiers
CHILL_3PARTY_3PARTY_SHOW: Voir un Tiers
CHILL_3PARTY_3PARTY_UPDATE: Modifier un Tiers
CHILL_3PARTY_3PARTY_UPDATE: Modifier un Tiers