Feature: KI-Berichte einzeln durchblättern (‹ Älter / Neuer ›), Navigation per Index (SW by-v809)
This commit is contained in:
parent
3acb7aa874
commit
b4879d615f
5 changed files with 39 additions and 24 deletions
|
|
@ -3,7 +3,7 @@
|
|||
Router, State-Management, Navigation, Initialisierung.
|
||||
============================================================ */
|
||||
|
||||
const APP_VER = '808'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VER = '809'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VERSION = '1.5.0'; // ← semantische Version, wird bei make release gesetzt
|
||||
const IS_STAGING = location.hostname === 'staging.banyaro.app';
|
||||
// Cache-Bust-Parameter nach Update-Reload sofort entfernen
|
||||
|
|
|
|||
|
|
@ -2346,19 +2346,34 @@ window.Page_health = (() => {
|
|||
${berichte.length > 1 ? `<div style="font-size:var(--text-xs);color:var(--c-accent,#c4843a);margin-top:var(--space-1)">${berichte.length} Berichte gespeichert — zum Öffnen tippen</div>` : ''}
|
||||
</div>`;
|
||||
el.querySelector('.health-ki-bericht-banner').addEventListener('click', () => {
|
||||
const listeHtml = berichte.map((b, i) => {
|
||||
const d = b.erstellt_at
|
||||
? new Date(b.erstellt_at).toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit', year: 'numeric' })
|
||||
: '';
|
||||
return `<div style="${i > 0 ? 'border-top:1px solid var(--c-border);padding-top:var(--space-3);margin-top:var(--space-3)' : ''}">
|
||||
${d ? `<div style="font-size:var(--text-xs);color:var(--c-text-muted);margin-bottom:var(--space-1)">${d}</div>` : ''}
|
||||
<div style="white-space:pre-wrap;line-height:1.7;font-size:var(--text-sm)">${_esc(b.bericht)}</div>
|
||||
</div>`;
|
||||
}).join('');
|
||||
UI.modal.open({
|
||||
title: `${UI.icon('star')} KI-Gesundheitsberichte`,
|
||||
body: listeHtml,
|
||||
});
|
||||
let idx = 0;
|
||||
const fmtDate = b => b.erstellt_at
|
||||
? new Date(b.erstellt_at).toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit', year: 'numeric' })
|
||||
: '';
|
||||
|
||||
function showBericht() {
|
||||
const b = berichte[idx];
|
||||
const nav = berichte.length > 1 ? `
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:12px">
|
||||
<button onclick="window._kiPrev()" style="padding:6px 16px;border-radius:999px;
|
||||
border:1.5px solid var(--c-border);background:var(--c-surface);cursor:pointer;
|
||||
font-size:var(--text-sm);${idx >= berichte.length-1 ? 'opacity:.3;pointer-events:none' : ''}">‹ Älter</button>
|
||||
<span style="font-size:var(--text-xs);color:var(--c-text-muted)">${idx+1} / ${berichte.length}</span>
|
||||
<button onclick="window._kiNext()" style="padding:6px 16px;border-radius:999px;
|
||||
border:1.5px solid var(--c-border);background:var(--c-surface);cursor:pointer;
|
||||
font-size:var(--text-sm);${idx <= 0 ? 'opacity:.3;pointer-events:none' : ''}">Neuer ›</button>
|
||||
</div>` : '';
|
||||
UI.modal.open({
|
||||
title: `${UI.icon('star')} KI-Gesundheitsberichte`,
|
||||
body: `${nav}
|
||||
<div style="font-size:var(--text-xs);color:var(--c-text-muted);text-align:center;margin-bottom:8px">${fmtDate(b)}</div>
|
||||
<div style="white-space:pre-wrap;line-height:1.7;font-size:var(--text-sm)">${_esc(b.bericht)}</div>`,
|
||||
});
|
||||
}
|
||||
|
||||
window._kiPrev = () => { if (idx < berichte.length - 1) { idx++; showBericht(); } };
|
||||
window._kiNext = () => { if (idx > 0) { idx--; showBericht(); } };
|
||||
showBericht();
|
||||
});
|
||||
} catch (_) {
|
||||
// Silently ignore — Berichte sind optional
|
||||
|
|
@ -2796,7 +2811,7 @@ window.Page_health = (() => {
|
|||
const res = await API.health.kiZusammenfassung(_appState.activeDog.id);
|
||||
const zusammenfassung = res.zusammenfassung ?? res;
|
||||
if (res.save_error) UI.toast.warning(`Speichern fehlgeschlagen: ${res.save_error}`);
|
||||
else if (res.saved_count !== undefined) UI.toast.info(`${res.saved_count} Bericht(e) gespeichert`);
|
||||
else if (res.saved_count !== undefined) UI.toast.info(`${res.saved_count} Bericht(e) in DB`, { duration: 8000 });
|
||||
UI.modal.open({
|
||||
title: `${UI.icon('star')} KI-Gesundheitsbericht`,
|
||||
body: `<div style="white-space:pre-wrap;line-height:1.7;font-size:var(--text-sm)">${_esc(zusammenfassung)}</div>`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue