inject record_actions buttons inside macro

This commit is contained in:
2022-01-07 15:24:06 +01:00
parent c60d46c68b
commit 69b5c98d2e
2 changed files with 38 additions and 24 deletions

View File

@@ -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 %}
<li>
<button class="btn btn-sm btn-misc" type="button">
<i class="fa fa-flag fa-fw"></i>{{ 'Pin comment'|trans }}
</button>
</li>
{% endif %}
<li>
<a class="btn btn-sm btn-edit" title="{{ 'Edit'|trans }}" href="{{ path('chill_person_accompanying_period_comment_list', {
'_fragment': 'comment-' ~ comment.id,
'edit': comment.id,
'accompanying_period_id': comment.accompanyingPeriod.id
}) }}"></a>
</li>
<li>
<a class="btn btn-sm btn-delete" title="{{ 'Delete'|trans }}" href=""></a>
</li>
{% 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 %}
</div>