render box, custom buttons before, after or remplacing default

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

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