{#
    This template is displayed after user clicks:
        * the destroy link on Item Views to delete all revisions of an item
        * or the destroy link on item history to delete an item revision
    The revision's meta data and rendered content is displayed for user review.
    User may add a comment to be written to server log; the item or revision
    is removed from storage so server log is only record of the transaction.
#}

{% import "forms.html" as forms with context %}
{% extends theme("show.html") %}

{% if alias_names %}
    {% set title = _("Destroy '{item_name}' with alias names {alias_names}").format(item_name=item_name, alias_names=alias_names) %}
{% else %}
    {% set title = _("Destroy '{item_name}'").format(item_name=item_name) %}
{% endif %}

{% block content %}
    {% if rev_id == None %}
        <h1>{{ title }}</h1>
        <div class="moin-form-delete">
            {{ gen.form.open(form, method="post", action=url_for('frontend.destroy_item', item_name=fqname.fullname)) }}
                {{ forms.render_errors(form) }}

                {% if subitem_names %}
                    <dl class="moin-delete-box">
                        {{ forms.render(form['destroy_subitems']) }}
                    </dl>
                    {{ forms.list_subitems(subitem_names, action) }}
                {% endif %}
                <dl class="moin-delete-comment">
                    {{ forms.render(form['comment']) }}
                </dl>
                {{ forms.render_submit(form) }}
            {{ gen.form.close() }}
        </div>
    {% else %}
        <h1>{{ _("DESTROY {item_name} REVISION NUMBER {rev_number}").format(item_name=utils.item_moniker(item.meta, [fqname]), rev_number=item.meta.rev_number) }}</h1>
        <div class="moin-form">
            {{ gen.form.open(form, method="post", action=url_for('frontend.destroy_item', item_name=fqname.fullname, rev=rev_id)) }}
                {{ forms.render_errors(form) }}
                <dl>
                    {{ forms.render(form['comment']) }}
                </dl>
                {{ forms.render_submit(form) }}
            {{ gen.form.close() }}
        </div>
    {% endif %}

    {% if rev_id %}
        <h2> {{ _("Meta data of item revision to be destroyed:",) }} </h2>
    {% else %}
        <h2> {{ _("Meta data of item to be destroyed:",) }} </h2>
    {% endif %}
    {{ utils.meta_info(item.meta) }}
    {% if data_rendered %}
        {% if rev_id %}
            <h2> {{ _("Content of item revision to be destroyed:") }} </h2>
        {% else %}
            <h2> {{ _("Content of item to be destroyed:") }} </h2>
        {% endif %}
        <div id="moin-content-data">
            {{ data_rendered | safe }}
        </div>
    {% endif %}
{% endblock %}
