Critical stability fix: handled null status values in database, fixed layer order (DB layer on top), and cleaned up redundant initialization logic
Deploy Bürgerwind / deploy (push) Successful in 16s
Details
Deploy Bürgerwind / deploy (push) Successful in 16s
Details
This commit is contained in:
parent
f4403b055f
commit
dd6e875e2c
30
app.js
30
app.js
|
|
@ -1280,8 +1280,8 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
|
||||
if (!rawStatus) rawStatus = props.status || '';
|
||||
|
||||
// Translate legacy values
|
||||
const status = LEGACY_STATUS_MAP[rawStatus.toLowerCase()] || rawStatus;
|
||||
// Translate legacy values safely
|
||||
const status = (rawStatus && LEGACY_STATUS_MAP[rawStatus.toLowerCase()]) ? LEGACY_STATUS_MAP[rawStatus.toLowerCase()] : (rawStatus || 'none');
|
||||
|
||||
let fillColor = 'transparent';
|
||||
let opacity = 0.1;
|
||||
|
|
@ -1317,7 +1317,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
}
|
||||
}
|
||||
|
||||
const status = LEGACY_STATUS_MAP[rawStatus.toLowerCase()] || rawStatus;
|
||||
const status = (rawStatus && LEGACY_STATUS_MAP[rawStatus.toLowerCase()]) ? LEGACY_STATUS_MAP[rawStatus.toLowerCase()] : (rawStatus || 'Kein Status');
|
||||
|
||||
let popup = `<b>${layerName}</b><br><hr style="margin: 5px 0; border: 0; border-top: 1px solid #444;">`;
|
||||
popup += `<b>Eigentümer:</b> ${firstName} ${lastName}<br>`;
|
||||
|
|
@ -1337,7 +1337,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
overlays[layerName] = layer;
|
||||
state.map.addLayer(layer);
|
||||
layerControl.addOverlay(layer, layerName);
|
||||
layer.bringToBack();
|
||||
layer.bringToFront(); // Ensure it's on top of local shapefiles
|
||||
}
|
||||
|
||||
// Manual Import & Bundling
|
||||
|
|
@ -1691,27 +1691,32 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
}
|
||||
}
|
||||
|
||||
// Initialize Dynamic Layers and then load data
|
||||
initDynamicLayers().then(async () => {
|
||||
// Erst Status laden, dann WEAs
|
||||
// Erst Status laden
|
||||
await loadOwnerStatusesFromDB();
|
||||
|
||||
// Nach dem Laden der Status: Prüfen ob wir den Layer automatisch mappen können
|
||||
// Dann WEAs laden
|
||||
await loadTurbinesFromDB();
|
||||
|
||||
// Automatisches Mapping für den Eigentümer-Layer prüfen
|
||||
const ownerLayerName = Object.keys(overlays).find(k => k.toLowerCase().includes('eigentümer'));
|
||||
if (ownerLayerName && overlays[ownerLayerName]) {
|
||||
const layer = overlays[ownerLayerName];
|
||||
const firstFeature = layer.getLayers()[0]?.feature;
|
||||
const layers = layer.getLayers();
|
||||
if (layers.length > 0) {
|
||||
const firstFeature = layers[0].feature;
|
||||
if (firstFeature && firstFeature.properties) {
|
||||
const props = firstFeature.properties;
|
||||
const vna = Object.keys(props).find(k => k.toUpperCase() === 'VNA');
|
||||
const gna = Object.keys(props).find(k => k.toUpperCase() === 'GNA' || k.toUpperCase() === 'NBA');
|
||||
if (vna && gna) {
|
||||
state.ownerMapping = { firstName: vna, lastName: gna };
|
||||
refreshOwnerLayerStyle(); // Jetzt werden die Farben sichtbar!
|
||||
refreshOwnerLayerStyle();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loadTurbinesFromDB();
|
||||
});
|
||||
|
||||
// Project Persistence
|
||||
|
|
@ -1834,11 +1839,6 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
}
|
||||
}
|
||||
|
||||
// Load from DB after layers are initialized
|
||||
initDynamicLayers().then(() => {
|
||||
loadTurbinesFromDB();
|
||||
});
|
||||
|
||||
btnLoad.addEventListener('click', () => projectInput.click());
|
||||
|
||||
projectInput.addEventListener('change', (e) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue