From 3fefaf1e4dddbbf91f596d62a29fdaf447513ba5 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 3 Sep 2021 13:59:31 +0200 Subject: [PATCH] household summary: put member box in a reused include template --- .../views/Household/_render_member.html.twig | 65 +++++++++ .../views/Household/summary.html.twig | 127 ++++-------------- 2 files changed, 93 insertions(+), 99 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/Household/_render_member.html.twig diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/_render_member.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/_render_member.html.twig new file mode 100644 index 000000000..f1c96e5fa --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/_render_member.html.twig @@ -0,0 +1,65 @@ +{% macro addHolder(holder) %} + {% if holder %} + + + T + + {% endif %} +{% endmacro %} + +
+
+
+ {{ member.person|chill_entity_render_box({ + 'render': 'label', + 'addLink': true, + 'addInfo': true, + 'customArea': { + 'afterLabel': _self.addHolder(member.holder) + } + }) }} +
+
+
+ +
+
    + + {% if customButtons['before'] is defined %} + {{ customButtons['before'] }} + {% endif %} + +
  • + +
  • + + {% if customButtons['after'] is defined %} + {{ customButtons['after'] }} + {% endif %} + +
+
+ +
    + {% if member.startDate is not empty %} +
  • + {{ 'Since %date%'|trans({'%date%': member.startDate|format_date('short') }) }}
  • + {% endif %} + {% if member.endDate is not empty %} +
  • + {{ 'Until %date%'|trans({'%date%': member.endDate|format_date('short') }) }}
  • + {% endif %} +
+ + {% if member.comment is not empty %} +
+ {{ member.comment|chill_markdown_to_html }} +
+ {% endif %} + +
+
+
+
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig index 933032426..1b1d22775 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig @@ -12,11 +12,13 @@ {% set address = household.currentAddress %} {% if address is empty %} -

{{ 'household.Household does not have any address currently'|trans }}

+

{{ 'household.Household does not have any address currently'|trans }}

{% else %} -
- {{ address|chill_entity_render_box({'multiline': true}) }} -
+
+
+ {{ address|chill_entity_render_box({'multiline': true}) }} +
+
{% endif %}

{{ 'household.Household members'|trans }}

@@ -81,67 +83,31 @@ {% endif %} {%- set members = household.currentMembersByPosition(p) %} + + {% macro customButtons(member, household) %} +
  • + + {{ 'household.Change position'|trans }} +
  • +
  • + + {{ 'household.Leave'|trans }} +
  • + {% endmacro %} + {% if members|length > 0 %}
    {% for m in members %} -
    -
    -
    -
    - {{ m.person|chill_entity_render_box({'addLink': true}) }} - {% if m.holder %} - {{ 'household.holder'|trans }} - {% endif %} -
    -
    - {{ 'Born the date'|trans({ 'gender': m.person.gender, 'birthdate': m.person.birthdate|format_date('long') }) }} -
    -
    -
    -
      - {% if m.startDate is not empty %} -
    • {{ 'Since %date%'|trans({'%date%': m.startDate|format_date('long') }) }}
    • - {% endif %} - {% if m.endDate is not empty %} -
    • {{ 'Until %date%'|trans({'%date%': m.endDate|format_date('long') }) }}
    • - {% endif %} -
    - -
    -
    - {% if m.comment is not empty %} -
    -
    - {{ m.comment|chill_markdown_to_html }} -
    -
    - {% endif %} -
    + {% include '@ChillPerson/Household/_render_member.html.twig' with { + 'member': m, + 'customButtons': { 'after': _self.customButtons(m, household) } + } %} {% endfor %}
    {% else %} -

    {{ 'household.Any persons into this position'|trans }}

    +

    {{ 'household.Any persons into this position'|trans }}

    {% endif %} {% set members = household.nonCurrentMembersByPosition(p) %} @@ -154,46 +120,9 @@
    {% for m in members %} -
    -
    -
    -
    - {{ m.person|chill_entity_render_box({'addLink': true}) }} - {% if m.holder %} - {{ 'household.holder'|trans }} - {% endif %} -
    -
    - {{ 'Born the date'|trans({ 'gender': m.person.gender, 'birthdate': m.person.birthdate|format_date('long') }) }} -
    -
    -
    -
      - {% if m.startDate is not empty %} -
    • {{ 'Since %date%'|trans({'%date%': m.startDate|format_date('long') }) }}
    • - {% endif %} - {% if m.endDate is not empty %} -
    • {{ 'Until %date%'|trans({'%date%': m.endDate|format_date('long') }) }}
    • - {% endif %} -
    - -
    -
    - {% if m.comment is not empty %} -
    -
    - {{ m.comment|chill_markdown_to_html }} -
    -
    - {% endif %} -
    + {% include '@ChillPerson/Household/_render_member.html.twig' with { + 'member': m + } %} {% endfor %}