From b1cd85971a4555c1ebf3c39adc8c643ea39d2c6b Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 7 Jan 2022 15:30:00 +0100 Subject: [PATCH] notification show page: use macro to display thread comments --- .../views/Notification/show.html.twig | 124 +++++++++--------- .../translations/messages.fr.yml | 2 + .../Comment/macro_showItem.html.twig | 3 + 3 files changed, 70 insertions(+), 59 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/show.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/show.html.twig index b4c2b0196..7d7af99fb 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Notification/show.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Notification/show.html.twig @@ -12,10 +12,25 @@ {{ 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 %}
    -

    {{ notification.title }}

    +

    {{ 'notification.Notification'|trans }}

    {% include 'ChillMainBundle:Notification:_list_item.html.twig' with { @@ -27,72 +42,63 @@ } %}
    - {# - {{ dump() }} -
    - {% include handler.getTemplate(notification) with handler.getTemplateData(notification) %} -
    -
    - à remplacer par un commentEmbeddable - {{ notification.message|chill_markdown_to_html }} -
    - #} +
    +

    {{ 'notification.comments_list'|trans }}

    -
    {% if notification.comments|length > 0 %} - {% for comment in notification.comments %} - {% if editedCommentForm is null or editedCommentId != comment.id %} -
    - -
    - {{ comment.content|chill_markdown_to_html }} -
    +
    + {% for comment in notification.comments %} - {% if is_granted('CHILL_MAIN_NOTIFICATION_COMMENT_EDIT', comment) %} -
      -
    • - -
    • -
    - {% endif %} -
    - {% else %} -
    - - {{ form_start(editedCommentForm) }} - {{ form_widget(editedCommentForm) }} + {% 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) }} -
      -
    • - -
    • -
    • - -
    • -
    - {{ form_end(editedCommentForm) }} -
    - {% endif %} - {% endfor %} - {% endif %} +
    +
    + {% endif %} - {% if appendCommentForm is not null %} -
    - {{ form_start(appendCommentForm) }} - {{ form_widget(appendCommentForm) }} - - - -
      -
    • - -
    • -
    - {{ form_end(appendCommentForm) }} + {% endfor %}
    {% endif %} + +
    +

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

    + + {{ form_start(appendCommentForm) }} + {{ form_errors(appendCommentForm) }} + {{ form_widget(appendCommentForm.content) }} + +
      +
    • + +
    • +
    + {{ form_end(appendCommentForm) }} + +
      diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 622042e20..73bbb5014 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -353,6 +353,7 @@ Created for: Créé pour Created by: Créé par notification: + Notification: Notification My own notifications: Mes notifications Notify: Envoyer une notification Notification created: Notification envoyée @@ -363,6 +364,7 @@ notification: comment_appended: Commentaire ajouté append_comment: Ajouter un commentaire comment_updated: Commentaire mis à jour + comments_list: Fil de commentaires is_unread: Non-lue is_system: notification automatique list: Notifications diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/macro_showItem.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/macro_showItem.html.twig index 8812dcdae..3bf4b98ff 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/macro_showItem.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/macro_showItem.html.twig @@ -22,3 +22,6 @@
    {% endmacro %} +{# + TODO if shared, move this file in Main, out of AccompanyingCourse +#}