From 7945087a6cb87842a99a95c1be80737a631e8bd5 Mon Sep 17 00:00:00 2001 From: rene Date: Thu, 4 Jun 2026 17:25:40 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20Routen-Bewertungen=20(Kommentare)=20ware?= =?UTF-8?q?n=20f=C3=BCr=20niemanden=20sichtbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UI.ratingStars lud die Bewertungen via API, speicherte/renderte das ratings-Array aber nie — nur Durchschnitt+Anzahl. Jetzt wird die Liste aller Bewertungen mit Kommentar (Name + Sterne + Text) angezeigt; nach dem Speichern neu geladen. Backend war korrekt. SW v1168 --- VERSION | 2 +- backend/static/index.html | 24 ++++++++++++------------ backend/static/js/app.js | 2 +- backend/static/js/ui.js | 27 +++++++++++++++++++++++---- backend/static/landing.html | 2 +- backend/static/sw.js | 2 +- 6 files changed, 39 insertions(+), 20 deletions(-) diff --git a/VERSION b/VERSION index 805f574..1c1c657 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1167 \ No newline at end of file +1168 \ No newline at end of file diff --git a/backend/static/index.html b/backend/static/index.html index 4ab7285..924cf5d 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -86,14 +86,14 @@ Ban Yaro - + - - - - - + + + + + @@ -617,11 +617,11 @@ - - - - - + + + + + @@ -631,7 +631,7 @@ - + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 5515a3a..3dd65cf 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '1167'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '1168'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator) window.APP_VERSION = APP_VERSION; diff --git a/backend/static/js/ui.js b/backend/static/js/ui.js index 4b014c2..cf4d1d8 100644 --- a/backend/static/js/ui.js +++ b/backend/static/js/ui.js @@ -1251,6 +1251,7 @@ const UI = (() => { let _myKommentar = ''; let _hoverStar = 0; let _widgetOpen = false; + let _ratings = []; // alle Bewertungen (mit Kommentar) für die Liste function _starHTML(filled, half = false, idx = 0) { const cls = filled ? 'rating-star rating-star--filled' : (half ? 'rating-star rating-star--half' : 'rating-star rating-star--empty'); @@ -1289,6 +1290,24 @@ const UI = (() => { `; } + function _renderRatingsList() { + const items = _ratings.filter(r => r.kommentar && r.kommentar.trim()); + if (!items.length) return ''; + return ` +
+ ${items.map(r => ` +
+
+ ${escape(r.user_name || 'Anonym')} + ${'★'.repeat(r.stars)}${'★'.repeat(Math.max(0, 5 - r.stars))} +
+
${escape(r.kommentar)}
+
+ `).join('')} +
+ `; + } + function _render() { const avgLabel = _anzahl > 0 ? `${_avgStars.toFixed(1)} (${_anzahl} Bewertung${_anzahl !== 1 ? 'en' : ''})` @@ -1307,6 +1326,7 @@ const UI = (() => { ${rateHint} ${_widgetOpen ? _renderWidget() : ''} + ${_renderRatingsList()} `; // Events @@ -1365,13 +1385,11 @@ const UI = (() => { if (saveBtn) { saveBtn.disabled = true; saveBtn.textContent = '…'; } const komm = document.getElementById(`rw-komm-${containerId}`)?.value?.trim() || null; try { - const res = await API.ratings.rate(targetType, targetId, _myStars, komm); - _avgStars = res.bewertung; - _anzahl = res.anz_bewertungen; + await API.ratings.rate(targetType, targetId, _myStars, komm); _myKommentar = komm || ''; _widgetOpen = false; _hoverStar = 0; - _render(); + await _load(); // frische Liste + Durchschnitt inkl. eigener Bewertung toast.success('Bewertung gespeichert!'); } catch (err) { toast.error(err?.message || 'Fehler beim Speichern.'); @@ -1388,6 +1406,7 @@ const UI = (() => { ]); _avgStars = overview.bewertung || 0; _anzahl = overview.anz_bewertungen || 0; + _ratings = Array.isArray(overview.ratings) ? overview.ratings : []; _myStars = mine.stars || null; _myKommentar = mine.kommentar || ''; } catch (e) { diff --git a/backend/static/landing.html b/backend/static/landing.html index fb597b4..cf8aba3 100644 --- a/backend/static/landing.html +++ b/backend/static/landing.html @@ -4,7 +4,7 @@ - + Ban Yaro — Die Hunde-App für Deutschland, Österreich & Schweiz diff --git a/backend/static/sw.js b/backend/static/sw.js index 245c359..003c599 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -4,7 +4,7 @@ ============================================================ */ // ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab -const VER = '1167'; +const VER = '1168'; const CACHE_VERSION = `by-v${VER}`; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten