{% extends "upload/layer_upload_base.html" %}
{% load i18n %}
{% load staticfiles %}

{% block title %} {% trans "Replace Layer"  %} - {{ block.super }}  {% endblock %}

{% block body_class %}data data-list upload{% endblock %}

{% block extra_head %}{{ block.super }}{% endblock %}

{% block head %}

{{ block.super }}
{% endblock %}

{% block body %}
  <div class="block">
    <div class="span8">
      <h2 class="page-title">{% trans "Replace Layer: " %}{{ layer.title }}</h2>

        {% if incomplete %}
        <section class="widget" id="incomplete-download-list">
          <h2>{% trans "Incomplete Uploads" %}</h2>
          <p>{% trans "You have the following incomplete uploads" %}:</p>
          {% for u in incomplete %}
          <div class="clearfix uip" id="incomplete-{{ u.import_id }}">
            <div class="pull-left">{{ u.name }}, {% trans "last updated on" %} {{ u.date }}</div>
            <div class="upload_actions pull-right">
              <a class="btn btn-mini" href="#" id="resume-{{ u.import_id }}">{% trans "Resume" %}</a>
              <a class="btn btn-mini" href="#" id="delete-{{ u.import_id }}"><i class="icon-trash"></i> {% trans "Delete" %}</a>
            </div>
          </div>
          {% endfor %}
        </section>
        <div id="confirm-delete" class="hide alert alert-warn" style="padding:10px; margin: 10px 0;">
          {% trans "Are you sure you want to delete this upload?" %}
          <div style="margin: 5px 0">
            <a href="#y" class="btn btn-danger">{% trans "Delete" %}</a>
            <a href="#n" class="btn">{% trans "Cancel" %}</a>
          </div>
          <a href="#yy" style="font-weight:normal">{% trans "Delete, and don't ask me again." %}</a>
        </div>
        {% endif %}

        {% block additional_info %}{% endblock %}
        
        {% if errors %}
        <div id="errors">
          {% for error in errors %}
          <div>{{ error }}</div>
          {% endfor %}
        </div>
        {% endif %}

        <section id="drop-zone">
          <h2><i class="icon-upload-alt"></i><br />{% trans "Drop files here" %}</h2>
        </section>

        <p>{% trans " or select them one by one:" %}</p>

        <form id="file-uploader" method="post" enctype="multipart/form-data">
          <input class="btn" id="file-input" type="file" multiple>
        </form>

        <section class="widget">
          <ul id="global-errors"></ul>
          <h2>{% trans "Files to be uploaded" %}</h2>
          <div id="file-queue"></div>
        </section>

        <section>
          <a href="#" id="upload-button" class="btn pull-right">{% trans "Upload Files" %}</a>
          <a href="#" id="clear-button" class="pull-right">{% trans "Clear" %}</a>
        </section>

        </div>
    </div>
{% endblock %}

{% block sidebar %}

<h3>{% trans "Permissions"  %}</h3>
<div>
  <form id="permission_form">
        {% include "_permissions.html" %}
  </form>
</div>
{% endblock %}

{% block extra_script %}

<script data-main="{% static 'geonode/js/upload/main' %}"
  src="{% static 'lib/js/require.js' %}">
</script>

<script type="text/javascript">
{% autoescape off %}

  csrf_token =  "{{ csrf_token }}",
  form_target = "{% url "layer_replace" layer.typename %}",
  geogit_enabled = {{ GEOGIT_ENABLED|lower  }},
  time_enabled = {{ TIME_ENABLED|lower  }},
  userLookup = "{% url "geonode.views.ajax_lookup" %}"

{% endautoescape %}

</script>
{% with "none" as layer %}
{% include "_permissions_form_js.html" %}
{% endwith %}
{% endblock extra_script %}
