{% extends "mapentity/base_site.html" %}
{% load i18n static leaflet_tags mapentity_tags %}

{% block title %}{{ objectsname }} | {{ block.super }}{% endblock title %}


{% block container %}
<div id="container" class="container-fluid list-container">

  <div class="row">
    <!-- List Panel -->
    <div class="col-12 col-md-6 d-flex" id="panelleft">

      <!-- Modules Panel -->
      <div id="entitylist">
        <ul class="nav flex-column">
          {% for entity in allowed_entities %}
          {% if entity.menu %}
          <li class="nav-item">
            <a class="nav-link {% if entity.modelname == modelname %}active{% endif %}"
                href="{% url entity.url_list %}" title="{{ entity.label }}">
              <span class="sr-only">{{ entity.label }}</span>
              <img src="{% static entity.icon %}" alt="{{ entity.modelname|truncatechars:3|title }}" />
            </a>
          </li>
          {% endif %}
          {% endfor %}
        </ul>
      </div>

      <div id="list-panel">

        <div class="btn-toolbar">
          <h1 class="list-title">{{ objectsname }}</h1>
          {% smart_include "preactions" %}

          {% block mainactions %}
          <div class="btn-group mr-2">
            {% if can_add %}
            <a class="btn btn-success" href="{{ model.get_add_url }}">
              <i class="bi bi-plus"></i> <span class="d-none d-sm-inline">{{ create_label }}</span></a>
            {% else %}
            <span class="btn disabled" href="#">
              <i class="bi bi-plus"></i> <span class="d-none d-sm-inline">{{ create_label }}</span></span>
            {% endif %}
          </div>
          {% endblock mainactions %}

          {% smart_include "listactions" %}
          {% include "mapentity/_mapentity_list_filter.html" %}
        </div>

        {% block mainlist %}
        <table id="objects-list" class="table table-striped table-bordered">
          <thead>
          <tr>
              {% block list-fields %}
                  {% for field in columns %}
                      <th data-data="{{ field }}" {% if field in unorderable_columns %} data-orderable="false" data-searchable="false"{% elif field not in searchable_columns %}
                          data-searchable="false"{% endif %}>
                          {{ model|verbose:field }}
                      </th>
                  {% endfor %}
              {% endblock %}
          </tr>
          </thead>
          <tbody>
          </tbody>
        </table>

        <div id="list-download-toolbar" class="btn-toolbar" role="toolbar" aria-label="">
          <div class="btn-group {% if not can_export %}disabled{% endif %}">
            <button class="btn btn-light btn-sm" name="csv" title="{% trans 'CSV' %}">
                <img src="{% static 'paperclip/fileicons/csv.png' %}" alt="">
            </button>
            <button class="btn btn-light btn-sm" name="shp" title="{% trans 'Shapefile' %}">
                <img src="{% static 'paperclip/fileicons/shp.png' %}" alt="">
            </button>
            <button class="btn btn-light btn-sm" name="gpx" title="{% trans 'GPX' %}">
                <img src="{% static 'paperclip/fileicons/gpx.png' %}" alt="">
            </button>
          </div>
            <div class="input-group" name="search-group">
                <div class="input-group-prepend">
                    <div class="input-group-text" id="btnGroupAddon">
                        <i class="bi bi-search"></i>
                    </div>
                </div>
                <input id="object-list-search" type="text" class="form-control" placeholder="{% trans "Search" %}" aria-label="Input group example" aria-describedby="btnGroupAddon">
            </div>
        </div>
        {% endblock mainlist %}
      </div>
    </div>

    <!-- Map Panel -->
    <div class="col-12 col-md-6" id="panelright">
      <div class="map-panel">
        {% block mainmap %}
        <div id="maphead">
          {% smart_include "maphead" %}
        </div>
        <div id="mainmap"></div>
        {% endblock mainmap %}
      </div>
    </div>
  </div>
</div>
{% endblock container %}


{% block extrabody %}
{{ block.super }}

{% leaflet_map "mainmap" fitextent=False creatediv=False %}
{% endblock extrabody %}
