{% extends "manage/manage_base.html" %}
{% load i18n compress %}

{% block help_link %}user/management/shop/images.html{% endblock %}

{% block title %}{% trans "Manage images" %}{% endblock %}
{% block section %}manage-images{% endblock %}

{% block javascript %}
    {% compress js %}
        <script type="text/javascript" src="{{ STATIC_URL }}manage/js/images.js"></script>
    {% endcompress %}
{% endblock %}

{% block left-slot-wrapper %}{% endblock %}

{% block content %}
    <div class="site-actions">
    </div>

    <div id="manage-tabs">
        <ul>
            <li class="ui-tabs-nav-item"><a href="#images">{% trans 'Global images' %}</a></li>
        </ul>

        <div id="images">
            <h2>{% trans "Global images" %}</h2>

            {% include "lfs/catalog/categories/product/products_navigation.html" %}

            <div class="filter-wrapper">
                <form action="{% url 'lfs_manage_global_images' %}" method="get">
                    {% csrf_token %}
                    <input type="text" value="{{ query }}" name="q" /> <input class="filter-button" type="submit" value="{% trans "Filter" %}" />
                    <input type="hidden" value="{{ pagination.current_page }}" name="start" />
                </form>
            </div>

            <form action="{% url 'lfs_manage_delete_images' %}" method="POST">
                {% csrf_token %}

                {% if images %}
                    {% for image in images %}
                        <div class="image-form">
                            <label for="image-toggle-{{ image.pk }}" class="image-selector">
                                <input id="image-toggle-{{ image.pk }}" class="toggle-images" type="checkbox" name="images" value="{{ image.id }}" />
                            </label>
                            <div class="image">
                                <img src="{{ image.image.url_100x100 }}" />
                            </div>
                            <span class="image-title">{{ image.title }}</span>
                        </div>
                    {% endfor %}
                    <br clear="both" />
                    <input type="submit" value="{% trans 'Delete images' %}" />
                    <input type="button"
                           class="toggle-all"
                           value="{% trans "Toggle selection" %}"
                           data="images" />
                {% else %}
                    {% trans "There are no images yet." %}
                {% endif %}
            </form>
            <h2 class="heading-middle">{% trans 'Add images' %}</h2>

            <div id="content">
                <form id="file_upload" action="{% url 'lfs_manage_add_global_image' %}" method="POST" enctype="multipart/form-data">
                    {% csrf_token %}
                    <input class="button" type="file" name="file" multiple>
                </form>
                <table id="files" data="{% url 'lfs_manage_global_images' %}" msg='{% trans "Uploading images:" %}'></table>
            </div>
        </div>
    </div>
{% endblock %}
