diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/render_box.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/render_box.scss
index f95896beb..986adaa97 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/render_box.scss
+++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/render_box.scss
@@ -47,27 +47,33 @@ section.chill-entity {
div.entity-bloc {}
}
- // address render_box
+ // used for addresses
&.entity-address {
- div.noaddress {}
- div.address {
- margin: 0.7em 0;
+
+ .address {
font-size: 98%;
font-variant: small-caps;
&.multiline {
+ margin: 0.7em 0;
p {
display: block;
}
}
+ &.delimiter {
+ p:not(:first-child):before {
+ content: ' — ';
+ }
+ }
p {
display: inline-block;
margin: 0 0 0 1.5em;
text-indent: -1.5em;
&.street {
- &.street1 {}
- &.street2, &.streetnumber {}
+ span.streetnumber {
+ &::before { content: ", "; }
+ }
}
&.postalcode {
span.code {}
@@ -76,6 +82,10 @@ section.chill-entity {
&.country {}
}
}
- span.address-since {}
+
+ .noaddress {}
+
+ span.address-since,
+ span.address-until {}
}
}
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Address/entity_render.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Address/entity_render.html.twig
deleted file mode 100644
index 5fb0d1b4e..000000000
--- a/src/Bundle/ChillMainBundle/Resources/views/Address/entity_render.html.twig
+++ /dev/null
@@ -1,36 +0,0 @@
-{#
- Template to render an address
- OPTIONS
- * has_no_address bool
- * multiline bool
- * with_valid_from bool
-#}
-
- {% if options['has_no_address'] == true and address.isNoAddress == true %}
-
- {{ 'address.consider homeless'|trans }}
-
- {% endif %}
-
-
- {% if address.street is not empty %}
-
{{ address.street }}
- {% endif %}
- {% if address.streetNumber is not empty %}
-
{{ address.streetNumber }}
- {% endif %}
- {% if address.postCode is not empty %}
-
- {{ address.postCode.code }}
- {{ address.postCode.name }}
-
-
{{ address.postCode.country.name|localize_translatable_string }}
- {% endif %}
-
-
- {%- if options['with_valid_from'] == true -%}
-
- {{ 'Since %date%'|trans( { '%date%' : address.validFrom|format_date('long') } ) }}
-
- {%- endif -%}
-
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig
new file mode 100644
index 000000000..95692aca1
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig
@@ -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 %}
+ {{ address.street }}
+ {% if address.streetNumber is not empty %}
+ {{ address.streetNumber }}
+ {% endif %}
+
+ {% endif %}
+ {% if options['extended_infos'] %}
+ {{ _self.extended(address, options) }}
+ {% endif %}
+ {% if address.postCode is not empty %}
+
+ {{ address.postCode.code }}
+ {{ address.postCode.name }}
+
+ {{ address.postCode.country.name|localize_translatable_string }}
+ {% endif %}
+{% endmacro %}
+
+{% macro extended(address, options) %}
+ {% if address.floor is not empty %}
+ {{ address.floor }}
+ {% endif %}
+ {% if address.corridor is not empty %}
+ {{ address.corridor }}
+ {% endif %}
+ {% if address.steps is not empty %}
+ {{ address.steps }}
+ {% endif %}
+ {% if address.buildingName is not empty %}
+ {{ address.buildingName }}
+ {% endif %}
+ {% if address.flat is not empty %}
+ {{ address.flat }}
+ {% endif %}
+ {% if address.distribution is not empty %}
+ {{ address.distribution }}
+ {% endif %}
+ {% if address.extra is not empty %}
+
+ {% endif %}
+{% endmacro %}
+
+{% macro inline(address, options) %}
+ {% if options['has_no_address'] == true and address.isNoAddress == true %}
+
+ {{ 'address.consider homeless'|trans }}
+
+ {% else %}
+
+ {{ _self.raw(address, options) }}
+
+ {% endif %}
+ {{ _self.validity(address, options) }}
+{% endmacro %}
+
+{% macro validity(address, options) %}
+ {%- if options['with_valid_from'] == true -%}
+
+ {{ 'Since %date%'|trans( { '%date%' : address.validFrom|format_date('long') } ) }}
+
+ {%- endif -%}
+ {%- if options['with_valid_to'] == true -%}
+
+ {{ 'Until %date%'|trans( { '%date%' : address.validTo|format_date('long') } ) }}
+
+ {%- endif -%}
+{% endmacro %}
+
+
+{%- if render == 'list' -%}
+
+ {% if options['with_picto'] %}
+
+ {% endif %}
+ {{ _self.inline(address, options) }}
+
+{%- endif -%}
+
+{%- if render == 'inline' -%}
+
+ {% if options['with_picto'] %}
+
+ {% endif %}
+ {{ _self.inline(address, options) }}
+
+{%- endif -%}
+
+{%- if render == 'bloc' -%}
+
+ {% if options['has_no_address'] == true and address.isNoAddress == true %}
+
+ {{ 'address.consider homeless'|trans }}
+
+ {% else %}
+
+ {% if options['with_picto'] %}
+
+ {% endif %}
+ {{ _self.raw(address, options) }}
+
+ {% endif %}
+ {{ _self.validity(address, options) }}
+
+{%- endif -%}
+
diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php
index 90a707e40..788fd43c1 100644
--- a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php
+++ b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php
@@ -10,16 +10,20 @@ class AddressRender implements ChillEntityRenderInterface
private EngineInterface $templating;
public const DEFAULT_OPTIONS = [
- 'with_valid_from' => true,
+ 'with_valid_from' => false,
+ 'with_valid_to' => false,
+ 'with_picto' => false,
+ 'with_delimiter' => false,
'has_no_address' => false,
'multiline' => true,
+ 'extended_infos' => false
];
public function __construct(EngineInterface $templating)
{
$this->templating = $templating;
}
-
+
/**
* {@inheritDoc}
*/
@@ -56,11 +60,12 @@ class AddressRender implements ChillEntityRenderInterface
*/
public function renderBox($addr, array $options): string
{
- $options = \array_merge(self::DEFAULT_OPTIONS, $options);
+ $options = \array_merge(self::DEFAULT_OPTIONS, $options);
return $this->templating
- ->render('@ChillMain/Address/entity_render.html.twig', [
+ ->render('@ChillMain/Entity/address.html.twig', [
'address' => $addr,
+ 'render' => $options['render'] ?? 'bloc',
'options' => $options
]);
}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig
index 93c9c0904..255add35e 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig
@@ -169,7 +169,12 @@ This view should receive those arguments:
{{ 'Address'|trans }}
{%- if person.lastAddress is not empty -%}
- {{ person.lastAddress|chill_entity_render_box({'has_no_address': true}) }}
+ {{ person.lastAddress|chill_entity_render_box({
+ 'render': 'bloc',
+ 'multiline': true,
+ 'extended_infos': true,
+ 'has_no_address': true
+ }) }}