From 68a0ef7115c5d86710e5bbe9681065d1f9790d62 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 30 Sep 2025 15:30:14 +0200 Subject: [PATCH] Reorganize templates to allow re-use of _list.html.twig within listByUser.html.twig template --- .../Resources/views/Calendar/_list.html.twig | 443 +++++++++--------- .../listByAccompanyingCourse.html.twig | 13 +- .../views/Calendar/listByPerson.html.twig | 12 +- .../views/Invitations/_list_item.html.twig | 172 ------- .../views/Invitations/listByUser.html.twig | 17 +- 5 files changed, 254 insertions(+), 403 deletions(-) delete mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Invitations/_list_item.html.twig diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig index cff5c00cc..01241643b 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig @@ -1,240 +1,229 @@ -{# list used in context of person or accompanyingPeriod #} +{# list used in context of person, accompanyingPeriod or user #} -{% if calendarItems|length > 0 %} -
+
+
+
+
+
+
+

+ {% if context == 'person' and calendar.context == 'accompanying_period' %} + + + {{ calendar.accompanyingPeriod.id }} + + + {% endif %} + {% if calendar.endDate.diff(calendar.startDate).days >= 1 %} + {{ calendar.startDate|format_datetime('short', 'short') }} + - {{ calendar.endDate|format_datetime('short', 'short') }} + {% else %} + {{ calendar.startDate|format_datetime('short', 'short') }} + - {{ calendar.endDate|format_datetime('none', 'short') }} + {% endif %} +

- {% for calendar in calendarItems %} - -
-
-
-
-
-
-

- {% if context == 'person' and calendar.context == 'accompanying_period' %} - - - {{ calendar.accompanyingPeriod.id }} - - - {% endif %} - {% if calendar.endDate.diff(calendar.startDate).days >= 1 %} - {{ calendar.startDate|format_datetime('short', 'short') }} - - {{ calendar.endDate|format_datetime('short', 'short') }} - {% else %} - {{ calendar.startDate|format_datetime('short', 'short') }} - - {{ calendar.endDate|format_datetime('none', 'short') }} - {% endif %} -

- -
- - {{ calendar.duration|date('%H:%I') }} - {% if false == calendar.sendSMS or null == calendar.sendSMS %} - - {% else %} - {% if calendar.smsStatus == 'sms_sent' %} - - - - - {% else %} - - - - - {% endif %} - {% endif %} -
- -
-
+
+ + {{ calendar.duration|date('%H:%I') }} + {% if false == calendar.sendSMS or null == calendar.sendSMS %} + + {% else %} + {% if calendar.smsStatus == 'sms_sent' %} + + + + + {% else %} + + + + + {% endif %} + {% endif %}
-
-
    - {% if calendar.mainUser is not empty %} - {{ calendar.mainUser|chill_entity_render_box({'at_date': calendar.startDate}) }} +
+
+
+ +
+
    + {% if calendar.mainUser is not empty %} + {{ calendar.mainUser|chill_entity_render_box({'at_date': calendar.startDate}) }} + {% endif %} +
+
+ +
+
+ + {% if calendar.comment.comment is not empty + or calendar.users|length > 0 + or calendar.thirdParties|length > 0 + or calendar.users|length > 0 %} +
+
+ {% include '@ChillActivity/Activity/concernedGroups.html.twig' with { + 'context': calendar.context == 'person' ? 'calendar_person' : 'calendar_accompanyingCourse', + 'render': 'wrap-list', + 'entity': calendar + } %} +
+ +
+ {% endif %} + + {% if calendar.comment.comment is not empty %} +
+
+ {{ calendar.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }} +
+
+ {% endif %} + + {% if calendar.location is not empty %} +
+
+ {% if calendar.location.address is not same as(null) and calendar.location.name is not empty %} + {% endif %} + {% if calendar.location.name is not empty %}{{ calendar.location.name }}{% endif %} + {% if calendar.location.address is not same as(null) %}{{ calendar.location.address|chill_entity_render_box({'multiline': false, 'with_picto': (calendar.location.name is empty)}) }}{% else %} + {% endif %} + {% if calendar.location.phonenumber1 is not empty %} {{ calendar.location.phonenumber1|chill_format_phonenumber }}{% endif %} + {% if calendar.location.phonenumber2 is not empty %} {{ calendar.location.phonenumber2|chill_format_phonenumber }}{% endif %} +
+
+ {% endif %} + +
+
+ + {{ include('@ChillCalendar/Calendar/_documents.twig.html') }} +
+
+ + {% if calendar.activity is not null %} +
+
+
+
+

{{ 'Activity'|trans }}

+
+

+ + + {{ calendar.activity.type.name | localize_translatable_string }} + + {% if calendar.activity.emergency %} + {{ 'Emergency'|trans|upper }} + {% endif %} + +

+ +
    +
  • + + {{ 'Created by'|trans }} + {{ calendar.activity.createdBy|chill_entity_render_string({'at_date': calendar.activity.createdAt}) }}, {{ 'on'|trans }} {{ calendar.activity.createdAt|format_datetime('short', 'short') }} + +
  • + {% if is_granted('CHILL_ACTIVITY_SEE', calendar.activity) %} +
  • + +
  • {% endif %}
-
+
- - {% if calendar.comment.comment is not empty - or calendar.users|length > 0 - or calendar.thirdParties|length > 0 - or calendar.users|length > 0 %} -
-
- {% include '@ChillActivity/Activity/concernedGroups.html.twig' with { - 'context': calendar.context == 'person' ? 'calendar_person' : 'calendar_accompanyingCourse', - 'render': 'wrap-list', - 'entity': calendar - } %} -
- -
- {% endif %} - - {% if calendar.comment.comment is not empty %} -
-
- {{ calendar.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }} -
-
- {% endif %} - - {% if calendar.location is not empty %} -
-
- {% if calendar.location.address is not same as(null) and calendar.location.name is not empty %} - {% endif %} - {% if calendar.location.name is not empty %}{{ calendar.location.name }}{% endif %} - {% if calendar.location.address is not same as(null) %}{{ calendar.location.address|chill_entity_render_box({'multiline': false, 'with_picto': (calendar.location.name is empty)}) }}{% else %} - {% endif %} - {% if calendar.location.phonenumber1 is not empty %} {{ calendar.location.phonenumber1|chill_format_phonenumber }}{% endif %} - {% if calendar.location.phonenumber2 is not empty %} {{ calendar.location.phonenumber2|chill_format_phonenumber }}{% endif %} -
-
- {% endif %} - -
-
- - {{ include('@ChillCalendar/Calendar/_documents.twig.html') }} -
-
- - {% if calendar.activity is not null %} -
-
-
-
-

{{ 'Activity'|trans }}

-
-

- - - {{ calendar.activity.type.name | localize_translatable_string }} - - {% if calendar.activity.emergency %} - {{ 'Emergency'|trans|upper }} - {% endif %} - -

- -
    -
  • - - {{ 'Created by'|trans }} - {{ calendar.activity.createdBy|chill_entity_render_string({'at_date': calendar.activity.createdAt}) }}, {{ 'on'|trans }} {{ calendar.activity.createdAt|format_datetime('short', 'short') }} - -
  • - {% if is_granted('CHILL_ACTIVITY_SEE', calendar.activity) %} -
  • - -
  • - {% endif %} -
- -
-
-
-
-
- {% endif %} - -
-
    - {% if is_granted('CHILL_CALENDAR_DOC_EDIT', calendar) %} - {% if templates|length == 0 %} -
  • - - {{ 'chill_calendar.Add a document'|trans }} - -
  • - {% else %} -
  • - -
  • - {% endif %} - {% endif %} - {% if calendar.activity is null and ( - (calendar.context == 'accompanying_period' and is_granted('CHILL_ACTIVITY_CREATE', calendar.accompanyingPeriod)) - or - (calendar.context == 'person' and is_granted('CHILL_ACTIVITY_CREATE', calendar.person)) - ) - %} -
  • - - {{ 'Transform to activity'|trans }} - -
  • - {% endif %} - - {% if (calendar.isInvited(app.user)) %} - {% set invite = calendar.inviteForUser(app.user) %} -
  • -
    -
  • - {% endif %} - {% if false %} -
  • - -
  • - {% endif %} - {% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', calendar) %} -
  • - -
  • - {% endif %} - {% if is_granted('CHILL_CALENDAR_CALENDAR_DELETE', calendar) %} -
  • - -
  • - {% endif %} -
- -
-
- {% endfor %} +
+ {% endif %} - {% if calendarItems|length < paginator.getTotalItems %} - {{ chill_pagination(paginator) }} - {% endif %} +
+
    + {% if is_granted('CHILL_CALENDAR_DOC_EDIT', calendar) %} + {% if templates|length == 0 %} +
  • + + {{ 'chill_calendar.Add a document'|trans }} + +
  • + {% else %} +
  • + +
  • + {% endif %} + {% endif %} + {% if calendar.activity is null and ( + (calendar.context == 'accompanying_period' and is_granted('CHILL_ACTIVITY_CREATE', calendar.accompanyingPeriod)) + or + (calendar.context == 'person' and is_granted('CHILL_ACTIVITY_CREATE', calendar.person)) + ) + %} +
  • + + {{ 'Transform to activity'|trans }} + +
  • + {% endif %} + + {% if (calendar.isInvited(app.user)) %} + {% set invite = calendar.inviteForUser(app.user) %} +
  • +
    +
  • + {% endif %} + {% if false %} +
  • + +
  • + {% endif %} + {% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', calendar) %} +
  • + +
  • + {% endif %} + {% if is_granted('CHILL_CALENDAR_CALENDAR_DELETE', calendar) %} +
  • + +
  • + {% endif %} +
-{% endif %} + +
+ + diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig index 7ce1003bc..96ddb3388 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig @@ -34,7 +34,18 @@ {% endif %}

{% else %} - {{ include('@ChillCalendar/Calendar/_list.html.twig', {context: 'accompanying_course'}) }} + {% if calendarItems|length > 0 %} +
+ {% for calendar in calendarItems %} + {{ include('@ChillCalendar/Calendar/_list.html.twig', {context: 'accompanying_course'}) }} + {% endfor %} +
+ + {% if calendarItems|length < paginator.getTotalItems %} + {{ chill_pagination(paginator) }} + {% endif %} + + {% endif %} {% endif %}
    diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByPerson.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByPerson.html.twig index 9e3b59d2a..dc44b721c 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByPerson.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByPerson.html.twig @@ -33,7 +33,17 @@ {% endif %}

    {% else %} - {{ include ('@ChillCalendar/Calendar/_list.html.twig', {context: 'person'}) }} + {% if calendarItems|length > 0 %} +
    + {% for calendar in calendarItems %} + {{ include ('@ChillCalendar/Calendar/_list.html.twig', {context: 'person'}) }} + {% endfor %} +
    + + {% if calendarItems|length < paginator.getTotalItems %} + {{ chill_pagination(paginator) }} + {% endif %} + {% endif %} {% endif %}
      diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Invitations/_list_item.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Invitations/_list_item.html.twig deleted file mode 100644 index 10a6a2282..000000000 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Invitations/_list_item.html.twig +++ /dev/null @@ -1,172 +0,0 @@ -{% if invitations|length > 0 %} -
      - - {% for invitation in invitations %} - {% set calendar = invitation.getCalendar %} - - {% if calendar is not null %} -
      -
      -
      -
      -
      -
      -

      - {% if calendar.endDate.diff(calendar.startDate).days >= 1 %} - {{ calendar.startDate|format_datetime('short', 'short') }} - - {{ calendar.endDate|format_datetime('short', 'short') }} - {% else %} - {{ calendar.startDate|format_datetime('short', 'short') }} - - {{ calendar.endDate|format_datetime('none', 'short') }} - {% endif %} -

      - -
      - - {{ calendar.duration|date('%H:%I') }} - {% if false == calendar.sendSMS or null == calendar.sendSMS %} - - {% else %} - {% if calendar.smsStatus == 'sms_sent' %} - - - - - {% else %} - - - - - {% endif %} - {% endif %} -
      - -
      -
      -
      - -
      -
        - {% if calendar.mainUser is not empty %} - {{ calendar.mainUser|chill_entity_render_box({'at_date': calendar.startDate}) }} - {% endif %} -
      -
      - -
      -
      - - {% if calendar.comment.comment is not empty - or calendar.users|length > 0 - or calendar.thirdParties|length > 0 - or calendar.users|length > 0 %} -
      -
      - {% include '@ChillActivity/Activity/concernedGroups.html.twig' with { - 'context': calendar.context == 'person' ? 'calendar_person' : 'calendar_accompanyingCourse', - 'render': 'wrap-list', - 'entity': calendar - } %} -
      - -
      - {% endif %} - - {% if calendar.comment.comment is not empty %} -
      -
      - {{ calendar.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }} -
      -
      - {% endif %} - - {% if calendar.location is not empty %} -
      -
      - {% if calendar.location.address is not same as(null) and calendar.location.name is not empty %} - {% endif %} - {% if calendar.location.name is not empty %}{{ calendar.location.name }}{% endif %} - {% if calendar.location.address is not same as(null) %}{{ calendar.location.address|chill_entity_render_box({'multiline': false, 'with_picto': (calendar.location.name is empty)}) }}{% else %} - {% endif %} - {% if calendar.location.phonenumber1 is not empty %} {{ calendar.location.phonenumber1|chill_format_phonenumber }}{% endif %} - {% if calendar.location.phonenumber2 is not empty %} {{ calendar.location.phonenumber2|chill_format_phonenumber }}{% endif %} -
      -
      - {% endif %} - -
      -
      - - {{ include('@ChillCalendar/Calendar/_documents.twig.html') }} -
      -
      - - {% if calendar.activity is not null %} -
      -
      -
      -
      -

      {{ 'Activity'|trans }}

      -
      -

      - - - {{ calendar.activity.type.name | localize_translatable_string }} - - {% if calendar.activity.emergency %} - {{ 'Emergency'|trans|upper }} - {% endif %} - -

      - -
        -
      • - - {{ 'Created by'|trans }} - {{ calendar.activity.createdBy|chill_entity_render_string({'at_date': calendar.activity.createdAt}) }}, {{ 'on'|trans }} {{ calendar.activity.createdAt|format_datetime('short', 'short') }} - -
      • - {% if is_granted('CHILL_ACTIVITY_SEE', calendar.activity) %} -
      • - -
      • - {% endif %} -
      - -
      -
      -
      -
      -
      - {% endif %} - -
      -
        - - {% if (calendar.isInvited(app.user)) %} - {% set invite = calendar.inviteForUser(app.user) %} -
      • -
        -
      • - {% endif %} -
      • - -
      • -
      - -
      - -
      - {% endif %} - {% endfor %} - - {% if invitations|length < paginator.getTotalItems %} - {{ chill_pagination(paginator) }} - {% endif %} - -
      -{% endif %} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Invitations/listByUser.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Invitations/listByUser.html.twig index 282b83dfe..8030df0a0 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Invitations/listByUser.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Invitations/listByUser.html.twig @@ -6,22 +6,35 @@ {% block content %} -

      {{ 'Invitation list' |trans }}

      +

      {{ 'invite.list.title'|trans }}

      {% if invitations|length == 0 %}

      {{ "invite.list.none"|trans }}

      {% else %} - {{ include ('@ChillCalendar/Invitations/_list_item.html.twig') }} +
      + {% for invitation in invitations %} + {% set calendar = invitation.getCalendar %} + {{ include('@ChillCalendar/Calendar/_list.html.twig', {context: 'user'}) }} + {% endfor %} +
      + + {% if invitations|length < paginator.getTotalItems %} + {{ chill_pagination(paginator) }} + {% endif %} {% endif %} {% endblock %} {% block js %} {{ parent() }} + {{ encore_entry_script_tags('mod_answer') }} + {{ encore_entry_script_tags('mod_document_action_buttons_group') }} {% endblock %} {% block css %} {{ parent() }} + {{ encore_entry_link_tags('mod_answer') }} + {{ encore_entry_link_tags('mod_document_action_buttons_group') }} {% endblock %}