From 69b5c98d2e7ec7004902f515194e7c5311a1e6c0 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 7 Jan 2022 15:24:06 +0100 Subject: [PATCH] inject record_actions buttons inside macro --- .../Comment/index.html.twig | 36 ++++++++++++++++--- .../Comment/macro_showItem.html.twig | 26 ++++---------- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig index 56dda187e..5af407d2b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig @@ -4,7 +4,28 @@ {{ 'Accompanying Course Comment list'|trans }} {% endblock %} -{% import '@ChillPerson/AccompanyingCourse/Comment/macro_showItem.html.twig' as macro %} +{% import '@ChillPerson/AccompanyingCourse/Comment/macro_showItem.html.twig' as m %} + +{% macro recordAction(comment, isPinned) %} + {% if isPinned is defined and isPinned == 'true' %} + {% else %} +
  • + +
  • + {% endif %} +
  • + +
  • +
  • + +
  • +{% endmacro %} {% macro form_comment(type, form) %} {% if type == 'edit' %} @@ -38,14 +59,19 @@ {% if commentEditId == accompanyingCourse.pinnedComment.id %} {{ _self.form_comment('edit', edit_form) }} {% else %} - {{ macro.show_comment(accompanyingCourse.pinnedComment, {'pinned': 'true'}) }} + {{ m.show_comment(accompanyingCourse.pinnedComment, { + 'pinned': 'true', + 'recordAction': _self.recordAction(accompanyingCourse.pinnedComment, 'true') + }) }} {% endif %} {% endif %} - {% for c in accompanyingCourse.comments %} - {% if commentEditId == c.id %} + {% for comment in accompanyingCourse.comments %} + {% if commentEditId == comment.id %} {{ _self.form_comment('edit', edit_form) }} {% else %} - {{ macro.show_comment(c) }} + {{ m.show_comment(comment, { + 'recordAction': _self.recordAction(comment) + }) }} {% endif %} {% endfor %} 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 82309300e..8812dcdae 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 @@ -5,28 +5,16 @@ {% if options.pinned is defined %} {% endif %} - - {{ 'by'|trans }}{{ comment.creator }}{{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}
    + + + {% set creator = comment.creator is defined ? comment.creator : comment.createdBy %} + {{ 'by'|trans }}{{ creator }} + + {{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}
    {{ 'Last updated on'|trans ~ ' ' ~ comment.updatedAt|format_datetime('long', 'short') }}