put macro show_comment in a separate template

This commit is contained in:
Mathieu Jaumotte 2022-01-07 12:51:03 +01:00
parent be4b8a94f0
commit c60d46c68b
2 changed files with 39 additions and 38 deletions

View File

@ -4,42 +4,7 @@
{{ 'Accompanying Course Comment list'|trans }}
{% endblock %}
{% macro show_comment(comment, options) %}
<div class="item-bloc">
<div class="item-row">
<div>
{% if options.pinned is defined %}
<i class="fa fa-flag fa-fw fa-lg" title="{{ 'pinned'|trans }}"></i>
{% endif %}
<a id="comment{{ comment.id }}" href="{{ '#comment' ~ comment.id }}" class="fa fa-pencil-square-o fa-fw"></a>
{{ 'by'|trans }}<b>{{ comment.creator }}</b>{{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}<br>
<i>{{ 'Last updated on'|trans ~ ' ' ~ comment.updatedAt|format_datetime('long', 'short') }}</i>
</div>
<ul class="record_actions">
{% if options.pinned is not defined %}
<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', {
'accompanying_period_id': comment.accompanyingPeriod.id,
'edit': comment.id
}) ~ '#comment' ~ comment.id }}"></a>
</li>
<li>
<a class="btn btn-sm btn-delete" title="{{ 'Delete'|trans }}" href=""></a>
</li>
</ul>
</div>
<div class="item-row separator">
<blockquote class="chill-user-quote col">{{ comment.content|chill_markdown_to_html }}</blockquote>
</div>
</div>
{% endmacro %}
{% import '@ChillPerson/AccompanyingCourse/Comment/macro_showItem.html.twig' as macro %}
{% macro form_comment(type, form) %}
{% if type == 'edit' %}
@ -73,14 +38,14 @@
{% if commentEditId == accompanyingCourse.pinnedComment.id %}
{{ _self.form_comment('edit', edit_form) }}
{% else %}
{{ _self.show_comment(accompanyingCourse.pinnedComment, {'pinned': 'true'}) }}
{{ macro.show_comment(accompanyingCourse.pinnedComment, {'pinned': 'true'}) }}
{% endif %}
{% endif %}
{% for c in accompanyingCourse.comments %}
{% if commentEditId == c.id %}
{{ _self.form_comment('edit', edit_form) }}
{% else %}
{{ _self.show_comment(c) }}
{{ macro.show_comment(c) }}
{% endif %}
{% endfor %}
</div>

View File

@ -0,0 +1,36 @@
{% macro show_comment(comment, options) %}
<div class="item-bloc">
<div class="item-row">
<div>
{% if options.pinned is defined %}
<i class="fa fa-flag fa-fw fa-lg" title="{{ 'pinned'|trans }}"></i>
{% endif %}
<a id="comment{{ comment.id }}" href="{{ '#comment' ~ comment.id }}" class="fa fa-pencil-square-o fa-fw"></a>
{{ 'by'|trans }}<b>{{ comment.creator }}</b>{{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}<br>
<i>{{ 'Last updated on'|trans ~ ' ' ~ comment.updatedAt|format_datetime('long', 'short') }}</i>
</div>
<ul class="record_actions">
{% if options.pinned is not defined %}
<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', {
'accompanying_period_id': comment.accompanyingPeriod.id,
'edit': comment.id
}) ~ '#comment' ~ comment.id }}"></a>
</li>
<li>
<a class="btn btn-sm btn-delete" title="{{ 'Delete'|trans }}" href=""></a>
</li>
</ul>
</div>
<div class="item-row separator">
<blockquote class="chill-user-quote col">{{ comment.content|chill_markdown_to_html }}</blockquote>
</div>
</div>
{% endmacro %}