{% extends "admin/base_site.html" %}
{% load i18n admin_urls admin_static admin_modify jet_tags common %}

{% block extrastyle %}
  {{ block.super }}
  <link rel="stylesheet" type="text/css" href="{% static 'assetmanager/admin/css/asset_list.css' %}" />
  <link rel="stylesheet" type="text/css" href="{% static 'assetmanager/admin/css/fontello/css/fontello.css' %}" />
{% endblock %}

{% block extrahead %}
  {{ block.super }}
  <script type="text/javascript" src="{% static "admin/js/jquery.js" %}"></script>
  <script type="text/javascript" src="{% static "admin/js/jquery.init.js" %}"></script>
  <script type="text/javascript" src="{% static "assetmanager/admin/js/asset_list.js" %}"></script>
{% endblock %}

{% block coltype %}colM{% endblock %}

{% block bodyclass %}{{ block.super }} app-assetmanager model-file change-form{% endblock %}

{% block content %}
  <div id="content-main">
    <form action="" method="get">
      {{ form }}
      <input type="hidden" name="_popup" value="{{ is_popup }}"/>
      <input type="submit" value="Search" />
    </form>
    {% if assets %}
    <div>{{ paginator.count }} total results</div>
    <ul class="flex-container row wrap">
      {% for asset in assets %}
        <li class="file" data-file-id="{{ asset.id }}" data-file-url="{{ asset.file.url }}" data-file-name="{{ asset.file.name }}" data-file-file-original-name="{{ asset.file_original_name }}" data-images-only="{{ images_only }}">
          {{ asset.preview|safe }}
        </li>
      {% endfor %}
    </ul>
    {% else %}
      <p>No files found.</p>
    {% endif %}
  </div>
  {% if assets %}
  <div class="pagination">
    <span class="step-links">
      {% if page_obj.has_previous %}
        <a href="?{% url_replace request 'page' page_obj.previous_page_number %}">previous</a>
      {% endif %}

      <span class="current">
            Page {{ page_obj.number }} of {{ paginator.num_pages }}
        </span>

      {% if page_obj.has_next %}
        <a href="?{% url_replace request 'page' page_obj.next_page_number %}">next</a>
      {% endif %}
    </span>
  </div>
  {% endif %}
{% endblock %}
