1.6 KiB · text History 25c4237
{# Lookup results. The map plots every [data-candidate]; clicking one fills
   #place-form. Swapped in as a whole, so the root keeps the target's id. #}
<div id="candidates" class="space-y-2" {% if fit %}data-fit{% endif %}>
  {% if failed %}
    <div class="alert alert-warning text-sm py-2">
      <i class="fas fa-triangle-exclamation"></i>
      <span>The map service didn't answer. You can still click to drop a pin and type the name.</span>
    </div>
  {% elif candidates | length == 0 %}
    <p class="text-sm opacity-70">Nothing found. Click the map to drop a pin and type the name yourself.</p>
  {% endif %}
  {% if candidates %}
  <ul class="max-h-72 overflow-y-auto divide-y divide-base-300 border border-base-300 rounded-box">
    {% for c in candidates %}
    <li class="flex items-center gap-2 px-1">
      <button type="button" class="btn btn-ghost btn-sm h-auto min-h-0 py-1.5 flex-1 justify-start text-left font-normal"
              data-candidate='{{ c.json | tojson }}'>
        <span class="block">
          <span class="font-semibold">{{ c.place.name }}</span>
          <span class="block text-xs opacity-70">
            {{ [c.place.kind, c.place.cuisine, c.place.address] | select | join(" · ") }}
            {%- if c.place.distance_m is not none %} · {{ c.place.distance_m }} m{% endif %}
          </span>
        </span>
      </button>
      {% if c.existing_id %}
        <a href="/restaurants/{{ c.existing_id }}" class="badge badge-outline badge-sm shrink-0">already added</a>
      {% endif %}
    </li>
    {% endfor %}
  </ul>
  {% endif %}
</div>