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

104 lines
3.9 KiB
Twig
Raw Normal View History

2020-04-05 16:54:45 +02:00
{% extends 'layouts/app.twig' %}
{% import 'macros/base.twig' as m %}
{% import 'macros/form.twig' as f %}
2020-12-06 00:16:15 +01:00
{% block title %}{{ news and news.id ? __('news.edit.edit') : __('news.edit.add') }}{% endblock %}
2020-04-05 16:54:45 +02:00
{% block content %}
<div class="container">
<h1>
{{ m.button(m.icon('chevron-left'), url('/news'), null, 'sm') }}
{{ block('title') }}
</h1>
2020-04-05 16:54:45 +02:00
{% include 'layouts/parts/messages.twig' %}
2020-12-06 00:16:15 +01:00
{% if news and news.id %}
2020-04-05 16:54:45 +02:00
<div class="row">
<div class="col-md-6">
<p>
{{ m.icon('clock') }} {{ news.updated_at.format(__('Y-m-d H:i')) }}
2020-04-05 16:54:45 +02:00
{% if news.updated_at != news.created_at %}
&emsp;{{ __('news.updated') }}
<br>
{{ m.icon('clock') }} {{ news.created_at.format(__('Y-m-d H:i')) }}
2020-04-05 16:54:45 +02:00
{% endif %}
&emsp;{{ m.user(news.user) }}
</p>
</div>
</div>
{% endif %}
<form action="" enctype="multipart/form-data" method="post">
{{ csrf() }}
<div class="row">
<div class="col-md-6">
{{ f.input(
'title',
__('news.edit.subject'),
{
'required': true,
'value': news ? news.title : '',
}
2020-04-05 16:54:45 +02:00
) }}
</div>
<div class="col-md-6">
{{ f.checkbox('is_meeting', __('news.edit.is_meeting'), {
'checked': is_meeting,
}) }}
{{ f.checkbox('is_pinned', __('news.edit.is_pinned'), {
'checked': is_pinned,
}) }}
{% if has_permission_to('news.highlight') %}
{{ f.checkbox('is_highlighted', __('news.edit.is_highlighted'), {
'checked': is_highlighted,
}) }}
{% endif %}
2020-04-05 16:54:45 +02:00
</div>
</div>
2021-07-24 12:38:23 +02:00
<div class="row mb-4">
2020-04-05 16:54:45 +02:00
<div class="col-md-12">
{{ f.textarea('text', __('news.edit.message'), {
'required': true,
'rows': 10,
'value': news ? news.text : '',
}) }}
2020-04-05 16:54:45 +02:00
2021-12-10 22:24:18 +01:00
<p>{{ m.info(__('news.edit.hint')) }}</p>
{{ f.submit(__('form.save'), {'icon_left': 'save'}) }}
2020-04-05 16:54:45 +02:00
2021-07-24 12:38:23 +02:00
{{ f.submit(m.icon('eye'), {'name': 'preview', 'btn_type': 'info', 'title': __('form.preview')}) }}
2020-10-21 00:12:29 +02:00
2020-12-06 00:16:15 +01:00
{% if news and news.id %}
2023-11-10 16:20:01 +01:00
{{ f.delete(__('form.delete'), {'confirm_title': __('news.delete.title', [news.title[:40]|e])}) }}
2020-04-05 16:54:45 +02:00
{% endif %}
</div>
</div>
2020-10-21 00:12:29 +02:00
{% if news %}
<div class="row">
<div class="col-md-12">
2020-12-06 00:16:15 +01:00
<h2>{{ __('form.preview') }}</h2>
2020-10-21 00:12:29 +02:00
<div class="card {% if news.is_highlighted %}bg-warning{% elseif news.is_meeting %}bg-info{% elseif theme.type =='light' %}bg-light{% else %}bg-secondary{% endif %} mb-4">
2021-07-24 12:38:23 +02:00
<div class="card-header {% if news.is_meeting and theme.type == 'dark' %}text-white{% endif %}">
{% if news.is_meeting %}{{ __('news.is_meeting') }}{% endif %}
{{ news.title }}
2020-10-21 00:12:29 +02:00
</div>
2021-08-05 01:00:12 +02:00
<div class="card-body bg-body">
{{ news.text|markdown }}
2020-10-21 00:12:29 +02:00
</div>
</div>
</div>
</div>
{% endif %}
2020-04-05 16:54:45 +02:00
</form>
</div>
{% endblock %}