mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
render_box address: new options and render modes
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
{#
|
||||
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.)
|
||||
|
||||
#}
|
||||
{% macro raw(address, options) %}
|
||||
{% if address.street is not empty %}
|
||||
<p class="street">{{ address.street }}
|
||||
{% if address.streetNumber is not empty %}
|
||||
<span class="streetnumber">{{ address.streetNumber }}</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if options['extended_infos'] %}
|
||||
{{ _self.extended(address, options) }}
|
||||
{% endif %}
|
||||
{% if address.postCode is not empty %}
|
||||
<p class="postalcode">
|
||||
<span class="code">{{ address.postCode.code }}</span>
|
||||
<span class="name">{{ address.postCode.name }}</span>
|
||||
</p>
|
||||
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro extended(address, options) %}
|
||||
{% if address.floor is not empty %}
|
||||
<span class="floor">{{ address.floor }}</span>
|
||||
{% endif %}
|
||||
{% if address.corridor is not empty %}
|
||||
<span class="corridor">{{ address.corridor }}</span>
|
||||
{% endif %}
|
||||
{% if address.steps is not empty %}
|
||||
<span class="steps">{{ address.steps }}</span>
|
||||
{% endif %}
|
||||
{% if address.buildingName is not empty %}
|
||||
<span class="buildingName">{{ address.buildingName }}</span>
|
||||
{% endif %}
|
||||
{% if address.flat is not empty %}
|
||||
<span class="flat">{{ address.flat }}</span>
|
||||
{% endif %}
|
||||
{% if address.distribution is not empty %}
|
||||
<span class="distribution">{{ address.distribution }}</span>
|
||||
{% endif %}
|
||||
{% if address.extra is not empty %}
|
||||
<span class="extra">{{ address.extra }}</span>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro inline(address, options) %}
|
||||
{% if options['has_no_address'] == true and address.isNoAddress == true %}
|
||||
<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(address, options) }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{{ _self.validity(address, options) }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro validity(address, options) %}
|
||||
{%- if options['with_valid_from'] == true -%}
|
||||
<span class="address-since">
|
||||
{{ 'Since %date%'|trans( { '%date%' : address.validFrom|format_date('long') } ) }}
|
||||
</span>
|
||||
{%- endif -%}
|
||||
{%- if options['with_valid_to'] == true -%}
|
||||
<span class="address-until">
|
||||
{{ 'Until %date%'|trans( { '%date%' : address.validTo|format_date('long') } ) }}
|
||||
</span>
|
||||
{%- endif -%}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{%- if render == 'list' -%}
|
||||
<li class="chill-entity entity-address">
|
||||
{% if options['with_picto'] %}
|
||||
<i class="fa fa-li fa-map-marker"></i>
|
||||
{% endif %}
|
||||
{{ _self.inline(address, options) }}
|
||||
</li>
|
||||
{%- endif -%}
|
||||
|
||||
{%- if render == 'inline' -%}
|
||||
<span class="chill-entity entity-address">
|
||||
{% if options['with_picto'] %}
|
||||
<i class="fa fa-fw fa-map-marker"></i>
|
||||
{% endif %}
|
||||
{{ _self.inline(address, options) }}
|
||||
</span>
|
||||
{%- endif -%}
|
||||
|
||||
{%- if render == 'bloc' -%}
|
||||
<div class="chill-entity entity-address">
|
||||
{% if options['has_no_address'] == true and address.isNoAddress == true %}
|
||||
<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(address, options) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ _self.validity(address, options) }}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
|
Reference in New Issue
Block a user