{% extends "qommon/forms/widgets/map.html" %}
{% load qommon l10n %}

{% comment %}
map field, optional, with template-nearby-list in "css extra classes".
{% endcomment %}

{% block widget-title %}
{% endblock %}

{% block widget-content %}
{% if form %}
<input type="hidden" name="{{widget.name}}$latlng">
<div id="map-{{widget.name}}" class="qommon-map"
  data-readonly="true"
  {% for key, value in widget.map_attributes.items %}{{key}}="{{value}}" {% endfor %}
  {% localize off %}
  data-init-lat="{{ form_var_carte_lat }}"
  data-init-lng="{{ form_var_carte_lon }}"
  {% endlocalize %}
></div>

<h3>Si votre signalement ne figure pas dans la liste ci-dessous, continuez</h3>
<div id="nearby-list">
{% with distance=form_option_distance|default:100|add:50 %}
{% with demands=form.objects.pending|distance_filter:distance %}
  {% for formdata in demands %}
      <div data-id="{{formdata.number}}" style="display: none"
           {% localize off %}
           data-geoloc-lat="{{formdata.geoloc.base.lat}}"
           data-geoloc-lon="{{formdata.geoloc.base.lon}}"
           {% endlocalize %}
           ><a name="nearby-{{forloop.counter}}"></a>
              <span class="marker-counter">{{forloop.counter}}</span>
              <span class="type-probleme">{{ formdata.var.type_probleme }},
                {% if formdata.var.numero %}{{ formdata.var.numero }} {% endif %}{{ formdata.var.voie }}</span>
              </span>
              <span class="message">{{ formdata.var.message }}</span>
              <span class="datetime">Signalé le {{ formdata.receipt_date }}</span>
              <a class="plus1 pk-button" href="#"
                 data-plus1-url="{{formdata.api_url}}hooks/plus1/">+1</a>
      </div>
  {% endfor %}
{% endwith %}
{% endwith %}
</div>
{% else %} {# no form, this is the admin preview #}
<div class="infonotice">Signalements à proximité, prévisualisation impossible.</div>
{% endif %}
{% endblock %}
