{# Display existing ticket with all comments,  textarea to add new comment, and buttons to reply to comments. #}

{% extends "ticket/base.html" %}

{% import "forms.html" as forms with context %}
{% import "ticket/ticket_macros.html" as ticket_macros with context %}

{% block title_text %}
    {{ item.meta['summary'] }}
{% endblock %}

{% block ticket_content %}

    <h2>{{ _("Description") }}</h2>
    <div class="moin-ticket-layout">
        {% if data_rendered %}
            {{ data_rendered }}
        {% endif %}
    </div>
    <div style="clear:both;"></div>

    {% if ordered_comments %}
        <h2>{{ _("Comments") }}</h2>
        <div class="moin-ticket-layout">
            {{ ticket_macros.render_comments() }}
        </div>
    {% endif %}

    <h2>{{ _("Add Comment") }}</h2>
    <div class="form-group">
        {{ gen.textarea(form['message'], class='form-control') }}
    </div>
    <div>
        {{ ticket_macros.subscribe(exists) }}
        <button type="submit" name="submit" class="moin-button" value="update">
            Update ticket
        </button>
        {% if closed %}
            {% set txt = _('Update & reopen ticket') %}
        {% else %}
            {% set txt = _('Update & close ticket') %}
        {% endif %}
        <button type="submit" name="submit" class="moin-button" value="update_negate_status">
            {{ txt }}
        </button>
    </div>

    <h2>{{ _("Metadata") }}</h2>
    <div class="moin-ticket-layout">
        <dl>
            <dt>
                <label>{{ _("Summary") }}</label>
            </dt>
            <dd>
                {{ forms.render(form['meta']['summary']) }}
            </dd>
        </dl>
        <dl>
            {{ forms.render_errors(form) }}
            {{ ticket_macros.render_meta() }}
        </dl>
        <div class="moin-ticket-tags">
            {{ _("Suggested Tags: ") }}
            {% for suggested_tag in suggested_tags | sort %}
                <a href="#">{{ suggested_tag }}</a>
            {% endfor %}
        </div>
    </div>
    <div class="moin-ticket-layout">
        <dl>
            {{ ticket_macros.render_selectlists() }}
        </dl>
    </div>
    <div style="clear:both;"></div>

    <h2>{{ _("Back references") }}</h2>
    <div class="moin-ticket-layout">
        <dl>
            {{ ticket_macros.render_backref() }}
        </dl>
    </div>
    <div style="clear:both;"></div>

    <h2>{{ _("Files") }}</h2>
    <div class="moin-ticket-layout">
        {% if files %}
            <div class="moin-item-index">
                {% for file in files %}
                    {{ ticket_macros.render_file(file) }}
                {% endfor %}
            </div>
            <div class="moin-clr"></div>
        {% else %}
            <p>No file uploaded.</p>
        {% endif %}
    </div>
    <div class="moin-ticket-layout">
        <dl>
            <dt>
                {{ gen.label(form['data_file']) }}
            </dt>
            <dd>
                {{ gen.input(form['data_file'], type='file') }}
            </dd>
        </dl>
    </div>
    <div style="clear:both;"></div>
    {{ ticket_macros.subscribe(exists) }}
    {{ forms.render(form['submit']) }}

{% endblock %}
