engelsystem/resources/views/pages/news/news.twig

62 lines
2.4 KiB
Twig

{% extends 'pages/news/overview.twig' %}
{% import 'macros/base.twig' as m %}
{% import 'macros/form.twig' as f %}
{% block title %}{% if news.is_meeting %}{{ __('news.is_meeting') }} {% endif %}{{ news.title }}{% endblock %}
{% block news %}
{{ _self.news(news) }}
{% endblock %}
{% block comments %}
<div class="col-md-12 mt-4">
<h2>{{ __('news.comments') }}</h2>
{% for comment in news.comments %}
<div class="card {% if theme.type == 'light' %}bg-light{% else %}bg-secondary{% endif %} mb-4">
<div class="card-body {{ m.type_bg_class() }}">
{{ comment.text|nl2br }}
</div>
<div class="card-footer {% if theme.type =='light' %}bg-light{% else %}bg-dark{% endif %} text-muted d-flex align-items-center">
<div class="me-3">
{{ m.icon('clock') }}
{{ comment.created_at.format(__('general.datetime')) }}
</div>
{{ m.user(comment.user, {'pronoun': true}) }}
{% if comment.user.id == user.id or has_permission_to('admin_news') or has_permission_to('comment.delete') %}
<div class="ms-auto">
<form
action="{{ url('/news/comment/' ~ comment.id) }}" enctype="multipart/form-data"
method="post">
{{ csrf() }}
{{ f.delete(null, {
'size': 'sm',
'confirm_title': __('news.comments.delete.title', [comment.text[:40]|e]),
'confirm_button_text': __('form.delete'),
}) }}
</form>
</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
{% endblock %}
{% block write_comment %}
{% if has_permission_to('news_comments') %}
<div class="col-md-12 mt-4">
<h3>{{ __('news.comments.new') }}</h3>
<form action="" enctype="multipart/form-data" method="post">
{{ csrf() }}
{{ f.textarea('comment', __('news.comments.message'), {
'required': true,
}) }}
{{ f.submit() }}
</form>
</div>
{% endif %}
{% endblock %}