mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-24 11:06:14 +00:00
134 lines
5.0 KiB
Twig
134 lines
5.0 KiB
Twig
{#
|
|
Template to render a person
|
|
OPTIONS
|
|
* render string ['raw'|'label'|'bloc']
|
|
* addAltNames bool
|
|
* addLink bool
|
|
* addEntity bool
|
|
* addId bool
|
|
* addInfo bool
|
|
* addAge bool
|
|
* hLevel integer
|
|
* customButtons [
|
|
'before' Twig\Markup, (injected with macro)
|
|
'replace' Twig\Markup,
|
|
'after' Twig\Markup
|
|
]
|
|
#}
|
|
|
|
{% macro raw(person, options) %}
|
|
<span class="firstname">{{ person.firstName }}</span>
|
|
<span class="lastname">{{ person.lastName }}</span>
|
|
{%- if options['addAltNames'] -%}
|
|
<span class="altnames">
|
|
{%- for n in person.altNames -%}
|
|
<span class="altname altname-{{ n.key }}">
|
|
{{- n.label -}}
|
|
</span>
|
|
{%- endfor -%}
|
|
</span>
|
|
{%- endif -%}
|
|
{% endmacro raw %}
|
|
|
|
{% macro label(person, options) %}
|
|
<div class="entity-label">
|
|
|
|
<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['addEntity'] -%}
|
|
<span class="badge rounded-pill bg-secondary">{{ 'Person'|trans }}</span>
|
|
{%- endif -%}
|
|
{%- if options['addId'] -%}
|
|
<span class="id-number" title="{{ 'Person'|trans ~ ' n° ' ~ person.id }}">
|
|
{{ person.id|upper }}
|
|
</span>
|
|
{%- endif -%}
|
|
</div>
|
|
{%- if options['addInfo'] -%}
|
|
{% set gender = (person.gender == 'woman') ? 'fa-venus' :
|
|
(person.gender == 'man') ? 'fa-mars' : 'fa-neuter' %}
|
|
{% set genderTitle = (person.gender == 'woman') ? 'woman' :
|
|
(person.gender == 'man') ? 'man' : 'neuter' %}
|
|
<p class="moreinfo">
|
|
<i class="fa fa-fw {{ gender }}" title="{{ genderTitle|trans }}"></i>
|
|
<time datetime="{{ person.birthdate|date('Y-m-d') }}" title="{{ 'Birthdate'|trans }}">
|
|
{{ 'Born the date'|trans({'gender': person.gender,
|
|
'birthdate': person.birthdate|format_date("medium") }) }}
|
|
</time>
|
|
{%- if options['addAge'] -%}
|
|
<span class="age">
|
|
{{ person.age ~ ((person.age > 1) ? ' ans' : ' an') }}
|
|
</span>
|
|
{%- endif -%}
|
|
</p>
|
|
{%- endif -%}
|
|
{#- tricks to remove easily whitespace after template -#}
|
|
{%- if true -%}</div>{%- endif -%}
|
|
{% endmacro label %}
|
|
|
|
|
|
{%- if render == 'raw' -%}
|
|
{{ _self.raw(person, options) }}
|
|
{%- endif -%}
|
|
|
|
{%- if render == 'label' -%}
|
|
{{ _self.label(person, options) }}
|
|
{%- endif -%}
|
|
|
|
{%- if render == 'bloc' -%}
|
|
<div class="item-row entity-bloc">
|
|
<div class="item-col">
|
|
{{ _self.label(person, options) }}
|
|
</div>
|
|
<div class="item-col">
|
|
<ul class="list-content fa-ul">
|
|
<li>
|
|
{% if person.mobilenumber %}
|
|
<i class="fa fa-li fa-mobile"></i><a href="{{ 'tel:' ~ person.mobilenumber }}">{{ person.mobilenumber }}</a>
|
|
{% else %}
|
|
<i class="fa fa-li fa-phone"></i>
|
|
{% if person.phonenumber %}
|
|
<a href="{{ 'tel:' ~ person.phonenumber }}">{{ person.phonenumber }}</a>
|
|
{% else %}
|
|
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
|
|
{% endif %}
|
|
{% endif %}
|
|
</li>
|
|
<li>
|
|
<i class="fa fa-li fa-map-marker"></i>
|
|
{%- if person.lastAddress is not empty -%}
|
|
{{ person.getLastAddress|chill_entity_render_box({'with_valid_from': false}) }}
|
|
{%- else -%}
|
|
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
|
|
{%- endif -%}
|
|
</li>
|
|
</ul>
|
|
<ul class="record_actions">
|
|
{% 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 person'|trans }}"
|
|
href="{{ path('chill_person_view', { person_id: person.id }) }}"></a>
|
|
</li>
|
|
{%- else -%}
|
|
{{ options['customButtons']['replace'] }}
|
|
{%- endif -%}
|
|
|
|
{% if options['customButtons']['after'] is defined %}
|
|
{{ options['customButtons']['after'] }}
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
{%- endif -%}
|
|
|