108 lines
4.1 KiB
Twig

{#
Template to render an address
OPTIONS
* render string ['list'|'bloc'|'inline']
* with_valid_from bool start date
* with_valid_to bool end date
* with_picto bool add a forkawesome pictogram
* with_delimiter bool add a delimiter between fragments
* has_no_address bool
* multiline bool multiline display
* extended_infos bool add extra informations (step, floor, etc.) DEPRECATED
#}
{% macro raw(lines) %}
{% for l in lines %}
<p>{{ l }}</p>
{% endfor %}
{% endmacro %}
{% macro inline(address, options, streetLine, lines) %}
{% if options['has_no_address'] == true and address.isNoAddress == true %}
{% if address.postCode is not empty %}
<p class="postcode">
<span class="code">{{ address.postCode.code }}</span>
<span class="name">{{ address.postCode.name }}</span>
<span class="name">{{ address.distribution }}</span>
</p>
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
{% endif %}
<span class="noaddress">
{{ 'address.consider homeless'|trans }}
</span>
{% else %}
<span class="address{% if options['multiline'] %} multiline{% endif %}{% if options['with_delimiter'] %} delimiter{% endif %}">
{{ _self.raw(lines) }}
</span>
{% endif %}
{{ _self.validity(address, options) }}
{% endmacro %}
{% macro validity(address, options) %}
{%- if options['with_valid_from'] == true -%}
<span class="address-valid date-since">
{{ 'Since %date%'|trans( { '%date%' : address.validFrom|format_date('long') } ) }}
</span>
{%- endif -%}
{%- if options['with_valid_to'] == true -%}
<span class="address-valid date-until">
{{ 'Until %date%'|trans( { '%date%' : address.validTo|format_date('long') } ) }}
</span>
{%- endif -%}
{% endmacro %}
{#
this enclose the rendering inside a "li", which ease the placement operation when the address
must be shown in such list
#}
{%- if render == 'list' -%}
<li class="chill-entity entity-address {% if address.confidential %}confidential{% endif %}">
{% if options['with_picto'] %}
<i class="fa fa-li fa-map-marker"></i>
{% endif %}
{{ _self.inline(address, options, streetLine, lines) }}
</li>
{%- endif -%}
{%- if render == 'inline' -%}
<span class="chill-entity entity-address {% if address.confidential %}confidential{% endif %}">
{% if options['with_picto'] %}
<i class="fa fa-fw fa-map-marker"></i>
{% endif %}
{{ _self.inline(address, options, streetLine, lines) }}
</span>
{%- endif -%}
{%- if render == 'bloc' -%}
<div class="chill-entity entity-address {% if address.confidential %}confidential{% endif %}">
{% if options['has_no_address'] == true and address.isNoAddress == true %}
{% if address.postCode is not empty %}
<div class="address{% if options['multiline'] %} multiline{% endif %}{% if options['with_delimiter'] %} delimiter{% endif %}">
<p class="postcode">
<span class="code">{{ address.postCode.code }}</span>
<span class="name">{{ address.postCode.name }}</span>
<span class="name">{{ address.distribution }}</span>
</p>
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
</div>
{% endif %}
<div class="noaddress">
{{ 'address.consider homeless'|trans }}
</div>
{% else %}
<div class="address{% if options['multiline'] %} multiline{% endif %}{% if options['with_delimiter'] %} delimiter{% endif %}">
{% if options['with_picto'] %}
<i class="fa fa-fw fa-map-marker"></i>
{% endif %}
{{ _self.raw(lines) }}
</div>
{% endif %}
{{ _self.validity(address, options) }}
</div>
{%- endif -%}