twig person/thirdparty renderbox: add a customArea option

with 2 areas to begin:
* before the label
* after the label
This commit is contained in:
Mathieu Jaumotte 2021-09-03 13:07:47 +02:00
parent f2f39d0922
commit 9b8b60ed75
4 changed files with 41 additions and 8 deletions

View File

@ -16,6 +16,10 @@
'replace' Twig\Markup,
'after' Twig\Markup
]
* customArea [
'beforeLabel' Twig\Markup,
'afterLabel' Twig\Markup,
]
#}
{% macro raw(person, options) %}
@ -37,11 +41,22 @@
<div class="denomination {{ 'h' ~ options['hLevel'] }}">
{%- if options['addLink'] and is_granted('CHILL_PERSON_SEE', person) -%}
<a href="{{ chill_path_add_return_path('chill_person_view', { 'person_id': person.id }) }}">
{{ _self.raw(person, options) }}
</a>
{%- else -%}
{{ _self.raw(person, options) }}
{%- endif -%}
{% if options['customArea']['beforeLabel'] is defined %}
{{ options['customArea']['beforeLabel'] }}
{% endif %}
{{ _self.raw(person, options) }}
{% if options['customArea']['afterLabel'] is defined %}
{{ options['customArea']['afterLabel'] }}
{% endif %}
{%- if options['addLink'] and is_granted('CHILL_PERSON_SEE', person) -%}
</a>
{%- endif -%}
{%- if options['addEntity'] -%}
<span class="badge rounded-pill bg-secondary">{{ 'Person'|trans }}</span>
{%- endif -%}

View File

@ -62,6 +62,7 @@ class PersonRender extends AbstractChillEntityRender
'address_multiline' => $options['address_multiline'] ?? false,
'hLevel' => $options['hLevel'] ?? 3,
'customButtons' => $options['customButtons'] ?? [],
'customArea' => $options['customArea'] ?? [],
];
return

View File

@ -13,6 +13,10 @@
'replace' Twig\Markup,
'after' Twig\Markup
]
* customArea [
'beforeLabel' Twig\Markup,
'afterLabel' Twig\Markup,
]
#}
{% macro raw(thirdparty, options) %}
@ -23,13 +27,25 @@
<div class="entity-label">
<div class="denomination {{ 'h' ~ options['hLevel'] }}">
{%- if options['addLink'] and is_granted('CHILL_3PARTY_3PARTY_SHOW', thirdparty) -%}
<a href="{{ chill_path_add_return_path('chill_3party_3party_show', { 'thirdparty_id': thirdparty.id }) }}">
{{ _self.raw(thirdparty, options) }}
</a>
{%- else -%}
{{ _self.raw(thirdparty, options) }}
{%- endif -%}
{% if options['customArea']['beforeLabel'] is defined %}
{{ options['customArea']['beforeLabel'] }}
{% endif %}
{{ _self.raw(thirdparty, options) }}
{% if options['customArea']['afterLabel'] is defined %}
{{ options['customArea']['afterLabel'] }}
{% endif %}
{%- if options['addLink'] and is_granted('CHILL_3PARTY_3PARTY_SHOW', thirdparty) -%}
</a>
{%- endif -%}
{%- if options['addEntity'] -%}
<span class="badge rounded-pill bg-secondary">{{ 'Third party'|trans }}</span>
{%- endif -%}

View File

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