{% extends "admin/base_site.html" %}
{% load i18n static %}

{% block breadcrumbs %}
    {% include "admin/filer/breadcrumbs.html" %}
{% endblock %}

{% block extrastyle %}
    {{ block.super }}
    <link rel="stylesheet" type="text/css" href="{% static 'admin/css/forms.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'filer/css/admin_filer.css' %}">
{% endblock %}

{% block extrahead %}
    {{ block.super }}
    <script src="{% static 'admin/js/cancel.js' %}" async></script>
    <script src="{% static 'filer/js/addons/tooltip.js' %}"></script>
    <script src="{% static 'filer/js/addons/copy-move-files.js' %}"></script>
{% endblock %}

{% block content %}
    {% if perms_lacking %}
        <p>{% blocktrans %}Your account doesn't have permissions to move all of the selected files and/or folders.{% endblocktrans %}</p>
        <div class="text-right clearfix">
            <a href="#" class="button cancel-link">{% translate "Take me back" %}</a>
        </div>
    {% else %}
        {% if not destination_folders %}
            <p>{% blocktrans %}There are no destination folders available.{% endblocktrans %}</p>
            <div class="text-right clearfix submit-row">
                <a href="#" class="button cancel-link">{% translate "Take me back" %}</a>
            </div>
        {% else %}
            {% if not to_move %}
                <p>{% blocktrans %}There are no files and/or folders available to move.{% endblocktrans %}</p>
                <div class="text-right clearfix submit-row">
                    <a href="#" class="button cancel-link">{% translate "Take me back" %}</a>
                </div>
            {% else %}
                <p>{% blocktrans %}The following files and/or folders will be moved to a destination folder (retaining their tree structure):{% endblocktrans %}</p>
                <ul>{{ to_move|unordered_list }}</ul>
                <form action="" method="post">{% csrf_token %}
                    <div>
                        {% for f in files_queryset %}
                            <input type="hidden" name="{{ action_checkbox_name }}" value="file-{{ f.pk|safe }}">
                        {% endfor %}
                        {% for f in folders_queryset %}
                            <input type="hidden" name="{{ action_checkbox_name }}" value="folder-{{ f.pk|safe }}">
                        {% endfor %}
                        <input type="hidden" name="action" value="move_files_and_folders">
                        <input type="hidden" name="post" value="yes">
                        <p><label for="destination">{% blocktrans %}Destination folder:{% endblocktrans %}</label>
                        <select name="destination" id="destination">
                            {% for folder, name_and_enabled in destination_folders %}
                                <option value="{{ folder.pk|safe }}"{% if not name_and_enabled.1 %} disabled="disabled"{% endif %}>{{ name_and_enabled.0 }}</option>
                            {% endfor %}
                        </select></p>

                       <div class="text-right clearfix submit-row">
                            <a href="#" class="button cancel-link">{% translate "No, take me back" %}</a>
                            <input type="submit" value="{% translate 'Move' %}" class="default js-submit-copy-move">
                            <span class="js-disabled-btn-tooltip disabled-btn-tooltip js-filer-tooltip filer-tooltip-wrapper"
                                title="{% translate 'It is not allowed to move files into same folder' %}" tabindex="-1">
                                <a class="default navigator-button" disabled>{% translate 'Move' %}</a>
                            </span>
                        </div>
                    </div>
                </form>
            {% endif %}
        {% endif %}
    {% endif %}
{% endblock %}
