{% extends "orga/mails/base.html" %}
{% load bootstrap4 %}
{% load i18n %}

{% block mail_content %}
    {% if form.instance.sent %}
    <div class="alert alert-info">
        {% blocktrans trimmed with timestamp=form.instance.sent %}
            This email was sent on {{ timestamp }}.
        {% endblocktrans %}
    </div>
    {% endif %}
    <form method="post">
        {% csrf_token %}
        <h2>{% trans "Mail Editor" %}</h2>
        {% bootstrap_form_errors form %}
        {% bootstrap_field form.to layout='event' %}
        {% if form.to_users %}{% bootstrap_field form.to_users layout='event' %}{% endif %}
        {% bootstrap_field form.reply_to layout='event' %}
        {% bootstrap_field form.cc layout='event' %}
        {% bootstrap_field form.bcc layout='event' %}
        {% bootstrap_field form.subject layout='event' %}
        {% bootstrap_field form.text layout='event' %}
        <div class="submit-group">
            <span></span>
            <span>
                {% if action == "edit" %}
                    <button type="submit" class="btn btn-lg btn-success" name="form" value="save">{% trans "Save" %}</button>
                    <button class="btn btn-lg btn-info" name="form" value="send">{% trans "Save and send" %}</button>
                    <a class="btn btn-lg btn-danger" href={{ form.instance.urls.delete }}>{% trans "Discard" %}</a>
                {% elif action == "view" %}
                    {% if form.instance.sent %}
                        <a class="btn btn-lg btn-success" href={{ form.instance.urls.copy }}>{% trans "Copy to draft" %}</a>
                    {% endif %}
                {% endif %}
            </span>
        </div>
    </form>

{% endblock %}
