wohnungen: preserve map across HTMX polls, add rejected section, drop €/m²

- #flats-map uses hx-preserve; marker data moved to <script type="application/json">
  sibling that diffs+updates instead of rebuilding Leaflet every poll (fixes
  whitescreen + tiles rendering outside the card)
- upsert_flat backfills lat/lng on existing rows missing coords (older flats
  scraped before the lat/lng migration now appear on the map once alert re-submits)
- collapsible "Abgelehnte Wohnungen" section at the bottom with Wiederherstellen
- remove €/m² column from the list

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
EiSiMo 2026-04-21 13:33:55 +02:00
parent 4fd0b50a43
commit 51b6b02b24
4 changed files with 155 additions and 45 deletions

View file

@ -96,12 +96,13 @@
</div>
</section>
<!-- Karte -->
<!-- Karte (Leaflet-Container bleibt über HTMX-Swaps hinweg erhalten) -->
<section class="view-map">
<div class="card p-3">
<div id="flats-map" data-flats='{{ map_points | tojson }}'></div>
<div id="flats-map" hx-preserve="true"></div>
</div>
</section>
<script id="flats-map-data" type="application/json">{{ map_points | tojson }}</script>
<!-- Liste -->
<section class="view-list card">
@ -124,7 +125,6 @@
{% if f.rooms %}{{ "%.1f"|format(f.rooms) }} Z{% endif %}
{% if f.size %} · {{ "%.0f"|format(f.size) }} m²{% endif %}
{% if f.total_rent %} · {{ "%.0f"|format(f.total_rent) }} €{% endif %}
{% if f.sqm_price %} ({{ "%.2f"|format(f.sqm_price) }} €/m²){% endif %}
{% if f.connectivity_morning_time %} · {{ "%.0f"|format(f.connectivity_morning_time) }} min morgens{% endif %}
{% if f.wbs %} · WBS: {{ f.wbs }}{% endif %}
· entdeckt <span data-rel-utc="{{ f.discovered_at|iso_utc }}" title="{{ f.discovered_at|de_dt }}"></span>
@ -170,4 +170,38 @@
</div>
</section>
{% if rejected_flats %}
<section class="card">
<details class="group">
<summary class="px-4 py-3 text-sm font-medium flex items-center justify-between cursor-pointer">
<span>Abgelehnte Wohnungen</span>
<span class="text-xs text-slate-500">{{ rejected_flats|length }}</span>
</summary>
<div class="divide-y divide-soft border-t border-soft">
{% for f in rejected_flats %}
<div class="px-4 py-3 flex flex-col md:flex-row md:items-center gap-3">
<div class="flex-1 min-w-0">
<a class="font-medium truncate" href="{{ f.link }}" target="_blank" rel="noopener noreferrer">
{{ f.address or f.link }}
</a>
<div class="text-xs text-slate-500 mt-0.5">
{% if f.rooms %}{{ "%.1f"|format(f.rooms) }} Z{% endif %}
{% if f.size %} · {{ "%.0f"|format(f.size) }} m²{% endif %}
{% if f.total_rent %} · {{ "%.0f"|format(f.total_rent) }} €{% endif %}
· abgelehnt <span data-rel-utc="{{ f.rejected_at|iso_utc }}" title="{{ f.rejected_at|de_dt }}"></span>
</div>
</div>
<form method="post" action="/actions/unreject"
hx-post="/actions/unreject" hx-target="#wohnungen-body" hx-swap="outerHTML">
<input type="hidden" name="csrf" value="{{ csrf }}">
<input type="hidden" name="flat_id" value="{{ f.id }}">
<button class="btn btn-ghost text-sm" type="submit">Wiederherstellen</button>
</form>
</div>
{% endfor %}
</div>
</details>
</section>
{% endif %}
</div>