From c5469e7fa5a64d1d15e3d331d410a96590726e78 Mon Sep 17 00:00:00 2001 From: Johannes Baumeister Date: Fri, 1 May 2026 10:14:42 +0200 Subject: [PATCH] Remove manual save button and finalize automatic synchronization between owner table and map --- app.js | 63 +++++++++++------------------------------------------- index.html | 1 - 2 files changed, 12 insertions(+), 52 deletions(-) diff --git a/app.js b/app.js index 7a7737d..8520e25 100644 --- a/app.js +++ b/app.js @@ -1476,9 +1476,6 @@ document.addEventListener('DOMContentLoaded', async () => { - - - `; ownerTableBody.appendChild(row); }); @@ -1500,10 +1497,11 @@ document.addEventListener('DOMContentLoaded', async () => { } refreshOwnerLayerStyle(); + updateLegend(); // Refresh legend too }; }); - // NEU: Auto-Save für Notiz-Feld bei Verlassen (Blur) + // Auto-Save für Notiz-Feld bei Verlassen (Blur) document.querySelectorAll('.notiz-input').forEach(input => { input.onblur = async (e) => { const name = e.target.dataset.owner; @@ -1517,36 +1515,23 @@ document.addEventListener('DOMContentLoaded', async () => { if (data) { await secureOwner(data.first, data.last, e.target, status, notiz); } + refreshOwnerLayerStyle(); }; - // Enter-Taste triggert ebenfalls Speichern input.onkeydown = (e) => { if (e.key === 'Enter') e.target.blur(); }; }); - - // Add event listeners to secure buttons - document.querySelectorAll('.btn-secure').forEach(btn => { - btn.onclick = async (e) => { - const first = e.target.dataset.first; - const last = e.target.dataset.last; - const name = e.target.dataset.owner; - const sel = document.querySelector(`.status-select[data-owner="${name}"]`); - const status = sel ? sel.value : 'Gesichert'; - const notizInput = document.querySelector(`.notiz-input[data-owner="${name}"]`); - const notiz = notizInput ? notizInput.value : ""; - - await secureOwner(first, last, e.target, status, notiz); - }; - }); } - async function secureOwner(vorname, nachname, element, status = 'Gesichert', notiz = '') { - const isButton = element.tagName === 'BUTTON'; - const originalText = isButton ? element.innerText : ""; - if (isButton) { - element.innerText = "Wait..."; - element.disabled = true; + async function secureOwner(vorname, nachname, element, status = 'none', notiz = '') { + const isSelect = element.tagName === 'SELECT'; + const isInput = element.tagName === 'INPUT'; + + // Visual feedback + if (isSelect || isInput) { + element.style.borderColor = '#2ecc71'; + setTimeout(() => element.style.borderColor = '', 1500); } const projekt_id = "BWSamern-Ohne"; @@ -1560,41 +1545,17 @@ document.addEventListener('DOMContentLoaded', async () => { const result = await response.json(); if (response.ok) { - if (isButton) { - element.style.background = '#2ecc71'; - element.innerText = "✓ Gespeichert"; - setTimeout(() => { - element.style.background = ''; - element.innerText = "Speichern"; - element.disabled = false; - }, 2000); - } - console.log(result.message); - const fullName = `${vorname || ''} ${nachname || ''}`.trim(); if (fullName) { state.ownerStatuses[fullName.toLowerCase()] = { status, notiz }; } - refreshOwnerLayerStyle(); - - const select = document.querySelector(`.status-select[data-owner="${fullName}"]`); - if (select) select.value = status; - } else { throw new Error(result.error || "Fehler"); } } catch (err) { console.error(err); - if (isButton) { - element.style.background = '#e74c3c'; - element.innerText = "Error"; - setTimeout(() => { - element.style.background = ''; - element.innerText = originalText; - element.disabled = false; - }, 2000); - } + element.style.borderColor = '#e74c3c'; } } diff --git a/index.html b/index.html index 9613964..2b8112b 100644 --- a/index.html +++ b/index.html @@ -236,7 +236,6 @@ Flächen Status Notiz - Aktion