From 2a155c084dbbab5cd6ae0a2b347a1931fce7c6e3 Mon Sep 17 00:00:00 2001 From: claude-dev Date: Wed, 4 Mar 2026 18:19:01 +0100 Subject: [PATCH] E-Mail-Benachrichtigungs-Toggles mit Backend verbinden Die Toggle-Switches im Lage-Modal (Anlegen/Bearbeiten) waren nicht mit den API-Endpunkten verbunden. Jetzt werden die Subscription- Einstellungen korrekt geladen, gespeichert und zurueckgesetzt. - api.js: getSubscription() und updateSubscription() hinzugefuegt - app.js: handleFormSubmit() speichert Subscription nach Create/Edit - app.js: handleEdit() laedt bestehende Subscription beim Oeffnen - app.js: openModal() setzt Checkboxen im Create-Modus zurueck --- src/static/js/api.js | 11 +++++++++++ src/static/js/app.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/static/js/api.js b/src/static/js/api.js index 13650fe..5ecec60 100644 --- a/src/static/js/api.js +++ b/src/static/js/api.js @@ -181,6 +181,17 @@ const API = { return this._request('PUT', '/notifications/mark-read', { notification_ids: ids }); }, + + + // Subscriptions (E-Mail-Benachrichtigungen) + getSubscription(incidentId) { + return this._request('GET', '/incidents/' + incidentId + '/subscription'); + }, + + updateSubscription(incidentId, data) { + return this._request('PUT', '/incidents/' + incidentId + '/subscription', data); + }, + // Feedback sendFeedback(data) { return this._request('POST', '/feedback', data); diff --git a/src/static/js/app.js b/src/static/js/app.js index ef319ac..6cb8528 100644 --- a/src/static/js/app.js +++ b/src/static/js/app.js @@ -1307,6 +1307,14 @@ const App = { // Edit-Modus: ID sichern bevor closeModal sie löscht const editId = this._editingIncidentId; await API.updateIncident(editId, data); + + // E-Mail-Subscription speichern + await API.updateSubscription(editId, { + notify_email_summary: document.getElementById('inc-notify-summary').checked, + notify_email_new_articles: document.getElementById('inc-notify-new-articles').checked, + notify_email_status_change: document.getElementById('inc-notify-status-change').checked, + }); + closeModal('modal-new'); await this.loadIncidents(); await this.loadIncidentDetail(editId); @@ -1314,6 +1322,14 @@ const App = { } else { // Create-Modus const incident = await API.createIncident(data); + + // E-Mail-Subscription speichern + await API.updateSubscription(incident.id, { + notify_email_summary: document.getElementById('inc-notify-summary').checked, + notify_email_new_articles: document.getElementById('inc-notify-new-articles').checked, + notify_email_status_change: document.getElementById('inc-notify-status-change').checked, + }); + closeModal('modal-new'); await this.loadIncidents(); @@ -1556,6 +1572,18 @@ const App = { document.getElementById('modal-new-title').textContent = 'Lage bearbeiten'; document.getElementById('modal-new-submit').textContent = 'Speichern'; + // E-Mail-Subscription laden + try { + const sub = await API.getSubscription(this.currentIncidentId); + document.getElementById('inc-notify-summary').checked = !!sub.notify_email_summary; + document.getElementById('inc-notify-new-articles').checked = !!sub.notify_email_new_articles; + document.getElementById('inc-notify-status-change').checked = !!sub.notify_email_status_change; + } catch (e) { + document.getElementById('inc-notify-summary').checked = false; + document.getElementById('inc-notify-new-articles').checked = false; + document.getElementById('inc-notify-status-change').checked = false; + } + openModal('modal-new'); }, @@ -2529,6 +2557,10 @@ function openModal(id) { document.getElementById('new-incident-form').reset(); document.getElementById('modal-new-title').textContent = 'Neue Lage anlegen'; document.getElementById('modal-new-submit').textContent = 'Lage anlegen'; + // E-Mail-Checkboxen zuruecksetzen + document.getElementById('inc-notify-summary').checked = false; + document.getElementById('inc-notify-new-articles').checked = false; + document.getElementById('inc-notify-status-change').checked = false; toggleTypeDefaults(); toggleRefreshInterval(); }