From af6f3043aea5bd60a93ad577eace43aaf051c6a9 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 10 Jan 2022 15:58:11 +0100 Subject: [PATCH] activity list page: put item bloc in a separate include --- .../views/Activity/_list_item.html.twig | 151 ++++++++++ .../Resources/views/Activity/list.html.twig | 271 ++++-------------- 2 files changed, 213 insertions(+), 209 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/Activity/_list_item.html.twig diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/_list_item.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/_list_item.html.twig new file mode 100644 index 000000000..7b46ffb67 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/_list_item.html.twig @@ -0,0 +1,151 @@ +{% set t = activity.type %} +
+ +
+
+
+
+ {% if activity.date %} +

+ {{ activity.date|format_date('short') }} +

+ {% endif %} +
+
+

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

+
+
+
+
+ +
+
+ {% if activity.location and t.locationVisible %} +
+

{{ 'location'|trans }}

+
+

+ {{ activity.location.locationType.title|localize_translatable_string }} + {{ activity.location.name }} +

+
+
+ {% endif %} + + {% if activity.sentReceived is not empty and t.sentReceivedVisible %} +
+

{{ 'Sent received'|trans }}

+
+

+ {{ activity.sentReceived|capitalize|trans }} +

+
+
+ {% endif %} + + {% if activity.user and t.userVisible %} +
+

{{ 'Referrer'|trans }}

+
+

+ {{ activity.user.usernameCanonical|chill_entity_render_string|capitalize }} +

+
+
+ {% endif %} +
+ + {% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with { + 'context': context, + 'with_display': 'wrap-list', + 'entity': activity, + 'badge_person': true + } %} + +
+ {%- if activity.reasons is not empty and t.reasonsVisible -%} +
+
+

{{ 'Reasons'|trans }}

+
+
+ {% for r in activity.reasons %} +

+ {{ r|chill_entity_render_box }} +

+ {% endfor %} +
+
+ {% endif %} + + {%- if activity.socialIssues is not empty and t.socialIssuesVisible -%} +
+
+

{{ 'Social issues'|trans }}

+
+
+ {% for r in activity.socialIssues %} + + {% endfor %} +
+
+ {% endif %} + + {%- if activity.socialActions is not empty and t.socialActionsVisible -%} +
+
+

{{ 'Social actions'|trans }}

+
+
+ {% for r in activity.socialActions %} + + {% endfor %} +
+
+ {% endif %} + + {% if activity.comment.comment is not empty and is_granted('CHILL_ACTIVITY_SEE_DETAILS', activity) %} +
+
+

{{ 'Comment'|trans }}

+
+
+ {{ activity.comment|chill_entity_render_box({ + 'disable_markdown': false, + 'limit_lines': 3, + 'metadata': false + }) }} +
+
+ {% endif %} + + {# Only if ACL SEE_DETAILS AND/OR only on template SHOW ?? + durationTime + travelTime + comment + documents + attendee + #} +
+
+ +
+
    + {{ recordAction }} +
+
+ +
diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig index 5c5e135b3..a64142863 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig @@ -1,3 +1,61 @@ +{% macro recordAction(activity, context = null, person_id = null, accompanying_course_id = null) %} + {% if no_action is not defined or no_action == false %} +
  • + {{ 'notification.Notify'|trans }} +
  • + {% endif %} + {% if context == 'person' and activity.accompanyingPeriod is not empty %} + {# + Disable person_id in following links, for redirect to accompanyingCourse context + #} + {% set person_id = null %} + {% set accompanying_course_id = activity.accompanyingPeriod.id %} +
  • + + + {{ 'Period number %number%'|trans({'%number%': accompanying_course_id}) }} + +
  • + {% endif %} +
  • + +
  • + {% if no_action is not defined or no_action == false %} + {% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %} +
  • + +
  • + {% endif %} + {% if is_granted('CHILL_ACTIVITY_DELETE', activity) %} +
  • + +
  • + {% endif %} + {% endif %} +{% endmacro %} +
    {% if activities|length == 0 %} @@ -8,215 +66,10 @@ {% else %}
    {% for activity in activities %} - {% set t = activity.type %} -
    - -
    -
    -
    -
    - {% if activity.date %} -

    - {{ activity.date|format_date('short') }} -

    - {% endif %} -
    -
    -

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

    -
    -
    -
    -
    - -
    -
    - {% if activity.location and t.locationVisible %} -
    -

    {{ 'location'|trans }}

    -
    -

    - {{ activity.location.locationType.title|localize_translatable_string }} - {{ activity.location.name }} -

    -
    -
    - {% endif %} - - {% if activity.sentReceived is not empty and t.sentReceivedVisible %} -
    -

    {{ 'Sent received'|trans }}

    -
    -

    - {{ activity.sentReceived|capitalize|trans }} -

    -
    -
    - {% endif %} - - {% if activity.user and t.userVisible %} -
    -

    {{ 'Referrer'|trans }}

    -
    -

    - {{ activity.user.usernameCanonical|chill_entity_render_string|capitalize }} -

    -
    -
    - {% endif %} -
    - - {% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with { - 'context': context, - 'with_display': 'wrap-list', - 'entity': activity, - 'badge_person': true - } %} - -
    - {%- if activity.reasons is not empty and t.reasonsVisible -%} -
    -
    -

    {{ 'Reasons'|trans }}

    -
    -
    - {% for r in activity.reasons %} -

    - {{ r|chill_entity_render_box }} -

    - {% endfor %} -
    -
    - {% endif %} - - {%- if activity.socialIssues is not empty and t.socialIssuesVisible -%} -
    -
    -

    {{ 'Social issues'|trans }}

    -
    -
    - {% for r in activity.socialIssues %} - - {% endfor %} -
    -
    - {% endif %} - - {%- if activity.socialActions is not empty and t.socialActionsVisible -%} -
    -
    -

    {{ 'Social actions'|trans }}

    -
    -
    - {% for r in activity.socialActions %} - - {% endfor %} -
    -
    - {% endif %} - - {% if activity.comment.comment is not empty and is_granted('CHILL_ACTIVITY_SEE_DETAILS', activity) %} -
    -
    -

    {{ 'Comment'|trans }}

    -
    -
    - {{ activity.comment|chill_entity_render_box({ - 'disable_markdown': false, - 'limit_lines': 3, - 'metadata': false - }) }} -
    -
    - {% endif %} - - {# Only if ACL SEE_DETAILS AND/OR only on template SHOW ?? - durationTime - travelTime - comment - documents - attendee - #} -
    -
    - - {% set notifications = chill_list_notifications('Chill\\ActivityBundle\\Entity\\Activity', activity.id) %} - {% if notifications is not empty %} -
    - {{ notifications|raw }} -
    - {% endif %} - -
    -
      - {% if no_action is not defined or no_action == false %} -
    • - {{ 'notification.Notify'|trans }} -
    • - {% endif %} - {% if context == 'person' and activity.accompanyingPeriod is not empty %} - {# - Disable person_id in following links, for redirect to accompanyingCourse context - #} - {% set person_id = null %} - {% set accompanying_course_id = activity.accompanyingPeriod.id %} -
    • - - - {{ 'Period number %number%'|trans({'%number%': accompanying_course_id}) }} - -
    • - {% endif %} -
    • - -
    • - {% if no_action is not defined or no_action == false %} - {% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %} -
    • - -
    • - {% endif %} - {% if is_granted('CHILL_ACTIVITY_DELETE', activity) %} -
    • - -
    • - {% endif %} - {% endif %} -
    -
    - -
    + {% include 'ChillActivityBundle:Activity:_list_item.html.twig' with { + 'context': context, + 'recordAction': _self.recordAction(activity, context, person_id, accompanying_course_id) + } %} {% endfor %}
    {% endif %}