From 1a2e1eaf2a6d7221d16e41a61cb290b0df1de2fd Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Sun, 23 Jan 2022 15:09:04 +0100 Subject: [PATCH] put notification comments in a separate include --- .../Notification/_item_comments.html.twig | 77 +++++++++++++++++++ .../views/Notification/show.html.twig | 76 +----------------- 2 files changed, 78 insertions(+), 75 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Notification/_item_comments.html.twig diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/_item_comments.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/_item_comments.html.twig new file mode 100644 index 000000000..b741abf4a --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Notification/_item_comments.html.twig @@ -0,0 +1,77 @@ +{% import '@ChillPerson/AccompanyingCourse/Comment/macro_showItem.html.twig' as m %} + +{% macro recordAction(comment) %} + {% if is_granted('CHILL_MAIN_NOTIFICATION_COMMENT_EDIT', comment) %} +
  • + +
  • + {% endif %} +{% endmacro %} + +
    +

    {{ 'notification.comments_list'|trans }}

    + + {% if notification.comments|length > 0 %} +
    + {% for comment in notification.comments %} + + {% if editedCommentForm is null or editedCommentId != comment.id %} + {{ m.show_comment(comment, { + 'recordAction': _self.recordAction(comment) + }) }} + {% else %} +
    +
    + + + {{ form_start(editedCommentForm) }} + {{ form_errors(editedCommentForm) }} + {{ form_widget(editedCommentForm.content) }} + + + {{ form_end(editedCommentForm) }} + +
    +
    + {% endif %} + + {% endfor %} +
    + {% else %} + {{ 'No comments'|trans }} + {% endif %} + + {% if appendCommentForm is not null %} +
    +

    {{ 'Write a new comment'|trans }}

    + + {{ form_start(appendCommentForm) }} + {{ form_errors(appendCommentForm) }} + {{ form_widget(appendCommentForm.content) }} + +
      +
    • + +
    • +
    + {{ form_end(appendCommentForm) }} + +
    + {% endif %} +
    \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/show.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/show.html.twig index ed4a05c34..c8834c07c 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Notification/show.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Notification/show.html.twig @@ -14,21 +14,6 @@ {{ encore_entry_link_tags('mod_notification_toggle_read_status') }} {% endblock %} -{% import '@ChillPerson/AccompanyingCourse/Comment/macro_showItem.html.twig' as m %} - -{% macro recordAction(comment) %} - {% if is_granted('CHILL_MAIN_NOTIFICATION_COMMENT_EDIT', comment) %} -
  • - -
  • - {% endif %} -{% endmacro %} - {% block content %}
    @@ -45,66 +30,7 @@ } %}
    -
    -

    {{ 'notification.comments_list'|trans }}

    - - {% if notification.comments|length > 0 %} -
    - {% for comment in notification.comments %} - - {% if editedCommentForm is null or editedCommentId != comment.id %} - {{ m.show_comment(comment, { - 'recordAction': _self.recordAction(comment) - }) }} - {% else %} -
    -
    - - - {{ form_start(editedCommentForm) }} - {{ form_errors(editedCommentForm) }} - {{ form_widget(editedCommentForm.content) }} - - - {{ form_end(editedCommentForm) }} - -
    -
    - {% endif %} - - {% endfor %} -
    - {% endif %} - - {% if appendCommentForm is not null %} -
    -

    {{ 'Write a new comment'|trans }}

    - - {{ form_start(appendCommentForm) }} - {{ form_errors(appendCommentForm) }} - {{ form_widget(appendCommentForm.content) }} - -
      -
    • - -
    • -
    - {{ form_end(appendCommentForm) }} - -
    - {% endif %} -
    + {% include 'ChillMainBundle:Notification:_item_comments.html.twig' %}