comments: form controller

This commit is contained in:
2021-12-15 23:13:20 +01:00
parent ecbe30ae53
commit f01b87b348
5 changed files with 147 additions and 62 deletions

View File

@@ -1,63 +1,92 @@
{% extends '@ChillPerson/AccompanyingCourse/layout.html.twig' %}
{% block title %}
{{ '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" title="{{ 'pinned'|trans }}"></i>
<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">
<li><a class="btn btn-edit" title="{{ 'Edit'|trans }}" href="{{ '?edit=' ~ comment.id ~ '#comment' ~ comment.id }}"></a></li>
<li><a class="btn btn-delete" title="{{ 'Delete'|trans }}" href=""></a></li>
{% if options.pinned is not defined %}
<li>
<button class="btn btn-sm btn-misc" type="button">
<i class="fa fa-flag fa-fw"></i>
Épingler
</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 }}</blockquote>
<blockquote class="chill-user-quote col">{{ comment.content|chill_markdown_to_html }}</blockquote>
</div>
</div>
{% endmacro %}
{% block title %}
{{ 'Accompanying Course Comment list'|trans }}
{% endblock %}
{% macro form_comment(type, form) %}
{% if type == 'edit' %}
<div class="item-bloc">
<div class="item-row row">
{% endif %}
{{ form_start(form) }}
{{ form_errors(form) }}
{{ form_widget(form.content) }}
<ul class="record_actions">
<li>
{% if type == 'new' %}
<button class="btn btn-create" type="submit">{{ 'Post a new comment'|trans }}</button>
{% elseif type == 'edit' %}
<button class="btn btn-save" type="submit">{{ 'Save'|trans }}</button>
{% endif %}
</li>
</ul>
{{ form_end(form) }}
{% if type == 'edit' %}
</div>
</div>
{% endif %}
{% endmacro %}
{% block content %}
<div class="accompanyingcourse-comment-list">
<h1>{{ block('title') }}</h1>
<div class="form my-5">
{{ form_start(form) }}
{{ form_errors(form) }}
{{ form_widget(form.content) }}
<ul class="record_actions">
<li>
<button class="btn btn-create" type="submit">{{ 'Post a new comment'|trans }}</button>
{#
<button class="btn btn-update" type="submit">{{ 'Edit a comment'|trans }}</button>
#}
</li>
</ul>
{{ form_end(form) }}
</div>
<div class="flex-table">
{% if accompanyingCourse.pinnedComment %}
{{ _self.show_comment(accompanyingCourse.pinnedComment, {'pinned': 'true'}) }}
{% if commentEditId == accompanyingCourse.pinnedComment.id %}
{{ _self.form_comment('edit', edit_form) }}
{% else %}
{{ _self.show_comment(accompanyingCourse.pinnedComment, {'pinned': 'true'}) }}
{% endif %}
{% endif %}
{% for c in accompanyingCourse.comments %}
{{ _self.show_comment(c) }}
{% if commentEditId == c.id %}
{{ _self.form_comment('edit', edit_form) }}
{% else %}
{{ _self.show_comment(c) }}
{% endif %}
{% endfor %}
</div>
<div class="new-comment my-5">
<h2 class="chill-blue">{{ 'Write a new comment'|trans }}</h2>
{{ _self.form_comment('new', form) }}
</div>
</div>
{% endblock %}