diff --git a/app.js b/app.js index a91ffb3..6c03722 100644 --- a/app.js +++ b/app.js @@ -27,6 +27,18 @@ document.addEventListener('DOMContentLoaded', async () => { 'Kooperationspartner': { color: '#ffffff', desc: 'Anderes Vorhaben mit dem kooperiert wird.' } }; + // Mapping for old database values + const LEGACY_STATUS_MAP = { + 'declined': 'Ablehnung', + 'negative': 'Ablehnung', + 'external': 'Fremdplanung', + 'fremdplanung': 'Fremdplanung', + 'positive': 'Erwartet Positiv', + 'undecided': 'Unentschlossen', + 'gbr': 'In der Projektgesellschaft', + 'gesichert': 'Vertraglich gesichert' + }; + // Removed fetch for config to prevent CORS errors on file:// protocol console.log("Konfiguration geladen."); @@ -1250,36 +1262,38 @@ document.addEventListener('DOMContentLoaded', async () => { const lastName = (props.GNA || '').trim(); // Normalisierung des Namens für den Abgleich - const normalize = (s) => (s || '').toString().toLowerCase().replace(/[\s,.-]/g, '').trim(); + const normalize = (s) => (s || '').toString().toLowerCase().replace(/[^a-z0-9]/g, '').trim(); const ownerKey = normalize(firstName + lastName); // Suche in den geladenen Status-Einträgen - let status = ''; + let rawStatus = ''; let foundInState = false; - // Wir suchen im state.ownerStatuses (der aus /api/sicherung geladen wurde) + // Wir suchen im state.ownerStatuses for (let key in state.ownerStatuses) { if (normalize(key) === ownerKey) { - status = state.ownerStatuses[key].status; + rawStatus = state.ownerStatuses[key].status; foundInState = true; break; } } - // Fallback auf die Properties im GeoJSON selbst - if (!status) status = props.status || ''; + if (!rawStatus) rawStatus = props.status || ''; + + // Translate legacy values + const status = LEGACY_STATUS_MAP[rawStatus.toLowerCase()] || rawStatus; let fillColor = 'transparent'; let opacity = 0.1; if (status && STATUS_MAP[status]) { fillColor = STATUS_MAP[status].color; - opacity = 0.7; + opacity = 0.8; // High visibility } return { color: '#000', - weight: 1, + weight: 1.5, // Stronger border fillOpacity: opacity, fillColor: fillColor }; @@ -1289,20 +1303,22 @@ document.addEventListener('DOMContentLoaded', async () => { const props = feature.properties; const firstName = (props.VNA || '').trim(); const lastName = (props.GNA || '').trim(); - const normalize = (s) => (s || '').toString().toLowerCase().replace(/[\s,.-]/g, '').trim(); + const normalize = (s) => (s || '').toString().toLowerCase().replace(/[^a-z0-9]/g, '').trim(); const ownerKey = normalize(firstName + lastName); - let status = props.status || 'Kein Status'; + let rawStatus = props.status || 'Kein Status'; let notiz = props.notiz || ''; for (let key in state.ownerStatuses) { if (normalize(key) === ownerKey) { - status = state.ownerStatuses[key].status; + rawStatus = state.ownerStatuses[key].status; notiz = state.ownerStatuses[key].notiz; break; } } + const status = LEGACY_STATUS_MAP[rawStatus.toLowerCase()] || rawStatus; + let popup = `${layerName}

`; popup += `Eigentümer: ${firstName} ${lastName}
`; popup += `Status: ${status}
`;