{# Define custom layout for creating and modifying a ticket; add supporting css and javascript. #}

{% extends theme("layout.html") %}

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

{% block head %}
    {{ super() }}
    <link media="all" rel="stylesheet" href="{{ url_for('static', filename='css/ticket.css') }}">
{% endblock %}

{% set exists = item.fqname and storage.get_item(**item.fqname.query) %}
{% block local_panel %}
    {% if user.valid and exists %}
        <div class="list-group">
            <div class="list-group-item moin-list-heading">
                {{ _("User Actions") }}
                <a class="moin-showhide moin-useractions" href="#" >
                    <i class="fa fa-lg fa-caret-right"></i>
                </a>
            </div>
            <div id="moin-user-actions" class="hidden">
                <a href="{{ url_for('frontend.quicklink_item', item_name=item.fqname) }}" class="list-group-item" rel="nofollow" title="Create or remove a navigation link to this item">
                    <i class="fa fa-link fa-fw"></i>
                    {%- if user.is_quicklinked_to([item.fqname]) %}
                        {{ _('Remove Link') }}
                    {%- else %}
                        {{ _('Add Link') }}
                    {%- endif %}
                </a>
            </div>
        </div>
    {% endif %}
{% endblock %}

{% block header_itemviews %}
    {{ ticket_macros.itemviews(exists) }}
{% endblock %}

{% block content %}
    <div class="moin-ticket-content">
        <h1>
            {% if closed %}
                <span class="moin-ticket-closed">{{ _("Closed:") }}</span>
            {% endif %}
            {% block title_text %}
            {% endblock %}
        </h1>
        <div class="moin-form" id="moin-ticket-form">
            {{ gen.form.open(form, method='post', enctype='multipart/form-data') }}
                {% block ticket_content %}
                {% endblock %}
            {{ gen.form.close() }}
        </div>
    </div>
{% endblock %}

{% block footer_itemviews %}
    {{ ticket_macros.itemviews(exists) }}
{% endblock %}

{% block body_scripts %}
    {{ super() }}
    <script src="{{ url_for('static', filename='js/search.js') }}"></script>
    <script src="{{ url_for('static', filename='js/tickets.js') }}"></script>
{% endblock %}
