wip render box person thirdparty display bloc

This commit is contained in:
2021-07-27 23:15:52 +02:00
parent 89dfea74b3
commit df3d32c653
12 changed files with 412 additions and 264 deletions

View File

@@ -222,103 +222,28 @@
<h2>{{ 'Resources'|trans }}</h2>
{% if accompanyingCourse.resources|length == 0 %}
<p class="chill-no-data-statement">{{ 'Any resource for this accompanying course'|trans }}</p>
<p class="chill-no-data-statement">{{ 'Any resource for this accompanying course'|trans }}</p>
{% else %}
<div class="flex-bloc">
{% for r in accompanyingCourse.resources %}
<div class="flex-bloc">
{% for r in accompanyingCourse.resources %}
<div class="item-bloc">
{% if r.person %}
<div class="item-row">
<div class="item-col">
<h3>
{{ r.person.firstname ~ ' ' ~ r.person.lastname }}
<span class="badge rounded-pill bg-secondary">{{ 'Usager' }}</span>
</h3>
<p>
{% set born = (r.person.gender == 'woman') ? 'née': 'né' %}
{% set gender = (r.person.gender == 'woman') ? 'fa-venus' :
(r.person.gender == 'man') ? 'fa-mars' : 'fa-neuter' %}
{% set genderTitle = (r.person.gender == 'woman') ? 'femme' :
(r.person.gender == 'homme') ? 'fa-mars' : 'neutre' %}
<i class="fa fa-fw {{ gender }}" title="{{ genderTitle }}"></i>{{ born ~ ' le ' ~ r.person.birthdate|format_date('short') }}
</p>
</div>
<div class="item-col">
<ul class="list-content fa-ul">
<li>
{% if r.person.mobilenumber %}
<i class="fa fa-li fa-mobile"></i><a href="{{ 'tel:' ~ r.person.mobilenumber }}">{{ r.person.mobilenumber }}</a>
{% else %}
<i class="fa fa-li fa-phone"></i>
{% if r.person.phonenumber %}
<a href="{{ 'tel:' ~ r.person.phonenumber }}">{{ r.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 r.person.lastAddress is not empty -%}
{{ r.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">
<li>
<a href="{{ path('chill_person_view', { person_id: r.person.id }) }}" class="btn btn-show" target="_blank" title="Voir"></a>
</li>
</ul>
</div>
</div>
{{ r.person|chill_entity_render_box({
'display': 'bloc', 'addLink': true, 'addEntity': true, 'addInfo': true
}) }}
{% endif %}
{% if r.thirdParty %}
<div class="item-row">
<div class="item-col">
<h3>
{{ r.thirdParty.name }}
<span class="badge rounded-pill bg-secondary">{{ 'Tiers' }}</span>
</h3>
</div>
<div class="item-col">
<ul class="list-content fa-ul">
<li><i class="fa fa-li fa-envelope-o"></i>
<a href="{{ 'mailto:' ~ r.thirdParty.email }}">
{{ r.thirdParty.email|chill_print_or_message("thirdparty.No_email") }}
</a>
</li>
<li><i class="fa fa-li fa-phone"></i>
{% if r.thirdParty.telephone %}
<a href="{{ 'tel:' ~ r.thirdParty.telephone }}">{{ r.thirdParty.telephone }}</a>
{% else %}
<span class="chill-no-data-statement">{{ 'thirdparty.No_phonenumber'|trans }}</span>
{% endif %}
</li>
<li><i class="fa fa-li fa-map-marker"></i>
{%- if r.thirdParty.address is not empty -%}
{{ r.thirdParty.getAddress|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">
<li>
<a href="{{ path('chill_3party_3party_show', { thirdparty_id: r.thirdParty.id }) }}" class="btn btn-show" target="_blank" title="Voir"></a>
</li>
</ul>
</div>
</div>
{{ r.thirdParty|chill_entity_render_box({
'display': 'bloc', 'addLink': true, 'addEntity': true, 'addInfo': true
}) }}
{% endif %}
</div>
{% endfor %}
</div>
{% endfor %}
</div>
{% endif %}
<h2>{{ 'Social actions'|trans }}</h2>

View File

@@ -1,17 +1,115 @@
<span class="chill-entity chill-entity__person">
{%- if addLink and is_granted('CHILL_PERSON_SEE', person) -%}
{%- set showLink = true -%}<a href="{{ chill_path_add_return_path('chill_person_view', { 'person_id': person.id }) }}">{%- endif -%}
<span class="chill_denomination">{{ person.firstName }}</span>
<span class="chill_denomination">{{ person.lastName }}</span>
{#
Template to render a person
OPTIONS
* display [raw|label|row|bloc]
* addAltNames bool
* addLink bool
* addEntity bool
* addInfo bool
#}
{% macro raw(person, addAltNames) %}
<span class="firstname">{{ person.firstName }}</span>
<span class="lastname">{{ person.lastName }}</span>
{%- if addAltNames -%}
{%- for n in person.altNames -%}
{%- if loop.first -%}({% else %} {%- endif -%}
<span class="chill-entity__person__alt-name chill-entity__person__altname--{{ n.key }}">
{{- n.label -}}
</span>
{%- if loop.last -%}) {%- endif -%}
{%- endfor -%}
{%- for n in person.altNames -%}
{%- if loop.first -%}({% else %} {%- endif -%}
<span class="altname altname-{{ n.key }}">
{{- n.label -}}
</span>
{%- if loop.last -%}){%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- if showLink is defined -%}</a>{%- endif -%}
{#- tricks to remove easily whitespace after template -#}
{%- if true -%}</span>{%- endif -%}
{% endmacro raw %}
{% macro label(person, addLink, addAltNames, addEntity, addInfo) %}
<div class="chill-entity person label">
<h3 class="denomination">
{%- if 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, addAltNames) }}
</a>
{%- else -%}
{{ _self.raw(person, addAltNames) }}
{%- endif -%}
{%- if addEntity -%}
<span class="badge rounded-pill bg-secondary">{{ 'Person'|trans }}</span>
{%- endif -%}
</h3>
{%- if addInfo -%}
{% set born = (person.gender == 'woman') ? 'née le ': 'né le ' %}
{% 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>
{{ born|trans }}
<time datetime="{{ person.birthdate|date('Y-m-d') }}">
{{ person.birthdate|format_date('medium') }}
</time>
{# TODO
{{ 'Born the %date%'|transchoice(person.genderNumeric, {
'%date%': person.birthdate|format_date("medium") }) }}
#}
</p>
{%- endif -%}
{#- tricks to remove easily whitespace after template -#}
{%- if true -%}</div>{%- endif -%}
{% endmacro label %}
{%- if display == 'raw' -%}
{{ _self.raw(person, addAltNames) }}
{%- endif -%}
{%- if display == 'label' -%}
{{ _self.label(person, addLink, addAltNames, addEntity, addInfo) }}
{%- endif -%}
{%- if display == 'row' -%}
<div class="chill-entity person row">
{{ _self.label(person, addLink, addAltNames, addEntity, addInfo) }}
</div>
{%- endif -%}
{%- if display == 'bloc' -%}
<div class="chill-entity person bloc">
<div class="item-row">
<div class="item-col">
{{ _self.label(person, addLink, addAltNames, addEntity, addInfo) }}
</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>
{%- if is_granted('CHILL_PERSON_SEE', person) -%}
<ul class="record_actions">
<li><a class="btn btn-show" target="_blank" title="{{ 'Show'|trans }}"
href="{{ path('chill_person_view', { person_id: person.id }) }}"></a>
</li>
</ul>
{%- endif -%}
</div>
</div>
</div>
{%- endif -%}

View File

@@ -39,21 +39,24 @@
<div class="flex-table list-with-period">
{% for person in persons %}
<div class="item-bloc">
<div class="item-row person">
<div class="item-col box-person">
<div>{{ person|chill_entity_render_box({'addLink': true}) }}</div>
<div>{{ 'Born the %date%'|transchoice(person.genderNumeric, { '%date%': person.birthdate|format_date("medium") }) }}</div>
<div>
{{ person|chill_entity_render_box({
'display': 'label', 'addLink': true, 'addInfo': true
}) }}
</div>
</div>
<div class="item-col box-where">
<ul class="list-content fa-ul">
<li><i class="fa fa-li fa-long-arrow-right"></i>
{{ person.center }}
</li>
<li>
{% if person.mobilenumber is not empty %}
<i class="fa fa-li fa-mobile"></i> <a href="{{ 'tel:' ~ person.mobilenumber }}">{{ person.mobilenumber|chill_format_phonenumber }}</a>
@@ -66,7 +69,7 @@
{% endif %}
{% endif %}
</li>
<li>
<i class="fa fa-li fa-map-marker"></i>
{% if person.getLastAddress is not null %}
@@ -75,7 +78,7 @@
<span class="chill-no-data-statement">{{ 'No address'|trans }}</span>
{% endif %}
</li>
</ul>
<ul class="record_actions">
<li>
@@ -89,7 +92,7 @@
</li>
</ul>
</div>
</div>
{#- 'apps' is for AccompanyingPeriodParticipationS #}
@@ -100,40 +103,40 @@
{%- set apps = apps|merge([app]) %}
{%- endif %}
{%- endfor %}
{% if apps|length > 0 %}
{% for app in apps %}
<div class="item-row periods">
<div class="header">
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': app.accompanyingPeriod.id }) }}"
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': app.accompanyingPeriod.id }) }}"
class="btn btn-chill-green" title="{{ 'See accompanying period'|trans }}">
<i class="fa fa-random"></i>
</a>
<span>{{ 'Since %date%'|trans({'%date%': app.startDate|format_date('medium') }) }}</span>
{% if app.accompanyingPeriod.user is not null %}
<span class="user">
<abbr class="referrer" title="{{ 'Referrer'|trans }}">ref:</abbr>
<abbr class="referrer" title="{{ 'Referrer'|trans }}">ref:</abbr>
{{ app.accompanyingPeriod.user|chill_entity_render_box }}
</span>
{% endif %}
</div>
<div class="list-content">
{% for issue in app.accompanyingPeriod.socialIssues|slice(0,2) %}
<span>{{ issue|chill_entity_render_box }}</span>
{% endfor %}
{% if app.accompanyingPeriod.socialIssues|length > 2 %}
<span class="more">{{ 'and %number% other'|transchoice(app.accompanyingPeriod.socialIssues|length-2) }}</span>
{% endif %}
</div>
</div>
{% endfor %}
{% endif %}
</div>
{% endfor %}
@@ -162,7 +165,7 @@
</li>
{% endif %}
</ul>
{% else %}
<ul class="record_actions">
<li>