Fix: Improve owner name mapping and display logic in Manage Owners
Deploy Bürgerwind / deploy (push) Successful in 17s
Details
Deploy Bürgerwind / deploy (push) Successful in 17s
Details
This commit is contained in:
parent
f8874a3e95
commit
f26d1f1710
36
app.js
36
app.js
|
|
@ -9,7 +9,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
turbines: [],
|
turbines: [],
|
||||||
activeVariant: 'A',
|
activeVariant: 'A',
|
||||||
bakedData: {}, // Cache for standalone persistence
|
bakedData: {}, // Cache for standalone persistence
|
||||||
ownerMapping: { firstName: 'VNA', lastName: 'GNA' }, // Default for ALKIS
|
ownerMapping: { firstName: 'vorname', lastName: 'nachname' }, // Default for ALKIS and modern Shapefiles
|
||||||
ownerStatuses: {}, // { "name vorname": { status: "...", notiz: "..." } }
|
ownerStatuses: {}, // { "name vorname": { status: "...", notiz: "..." } }
|
||||||
showAuxiliary: true
|
showAuxiliary: true
|
||||||
};
|
};
|
||||||
|
|
@ -1286,8 +1286,8 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
const layer = L.geoJSON(geojson, {
|
const layer = L.geoJSON(geojson, {
|
||||||
style: (feature) => {
|
style: (feature) => {
|
||||||
const props = feature.properties;
|
const props = feature.properties;
|
||||||
const firstName = (props.VNA || '').trim();
|
const firstName = (props.vorname || props.VNA || '').trim();
|
||||||
const lastName = (props.GNA || '').trim();
|
const lastName = (props.nachname || props.GNA || '').trim();
|
||||||
|
|
||||||
// Normalisierung des Namens für den Abgleich
|
// Normalisierung des Namens für den Abgleich
|
||||||
const normalize = (s) => (s || '').toString().toLowerCase().replace(/[^a-z0-9]/g, '').trim();
|
const normalize = (s) => (s || '').toString().toLowerCase().replace(/[^a-z0-9]/g, '').trim();
|
||||||
|
|
@ -1329,8 +1329,8 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
onEachFeature: (feature, layer) => {
|
onEachFeature: (feature, layer) => {
|
||||||
if (feature.properties) {
|
if (feature.properties) {
|
||||||
const props = feature.properties;
|
const props = feature.properties;
|
||||||
const firstName = (props.VNA || '').trim();
|
const firstName = (props.vorname || props.VNA || '').trim();
|
||||||
const lastName = (props.GNA || '').trim();
|
const lastName = (props.nachname || props.GNA || '').trim();
|
||||||
const normalize = (s) => (s || '').toString().toLowerCase().replace(/[^a-z0-9]/g, '').trim();
|
const normalize = (s) => (s || '').toString().toLowerCase().replace(/[^a-z0-9]/g, '').trim();
|
||||||
const ownerKey = normalize(firstName + lastName);
|
const ownerKey = normalize(firstName + lastName);
|
||||||
|
|
||||||
|
|
@ -1428,12 +1428,16 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const sortedKeys = Array.from(allKeys);
|
const sortedKeys = Array.from(allKeys);
|
||||||
const vnaMatch = sortedKeys.find(k => k.toUpperCase() === 'VNA');
|
const vnaMatch = sortedKeys.find(k => k.toUpperCase() === 'VNA' || k.toUpperCase() === 'VORNAME');
|
||||||
const gnaMatch = sortedKeys.find(k => k.toUpperCase() === 'GNA' || k.toUpperCase() === 'NBA');
|
const gnaMatch = sortedKeys.find(k => k.toUpperCase() === 'GNA' || k.toUpperCase() === 'NBA' || k.toUpperCase() === 'NACHNAME' || k.toUpperCase() === 'NAME');
|
||||||
|
|
||||||
if (vnaMatch && gnaMatch) {
|
if (vnaMatch && gnaMatch) {
|
||||||
state.ownerMapping = { firstName: vnaMatch, lastName: gnaMatch };
|
state.ownerMapping = { firstName: vnaMatch, lastName: gnaMatch };
|
||||||
console.log("Auto-Mapping erfolgreich:", state.ownerMapping);
|
console.log("Auto-Mapping erfolgreich:", state.ownerMapping);
|
||||||
|
} else if (gnaMatch) {
|
||||||
|
// If only last name/name is found, use it
|
||||||
|
state.ownerMapping = { firstName: '', lastName: gnaMatch };
|
||||||
|
console.log("Partial Auto-Mapping (Last Name only):", state.ownerMapping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1465,10 +1469,9 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
selectFirstName.innerHTML = optionsHtml;
|
selectFirstName.innerHTML = optionsHtml;
|
||||||
selectLastName.innerHTML = optionsHtml;
|
selectLastName.innerHTML = optionsHtml;
|
||||||
|
|
||||||
// Smart Defaults: Prefer VNA for First Name and NBA (or GNA/Name) for Last Name
|
// Smart Defaults
|
||||||
const vnaMatch = sortedKeys.find(k => k.toLowerCase() === 'vna');
|
const vnaMatch = sortedKeys.find(k => ['vorname', 'vna', 'first'].includes(k.toLowerCase()));
|
||||||
const nbaMatch = sortedKeys.find(k => k.toLowerCase() === 'nba');
|
const gnaMatch = sortedKeys.find(k => ['nachname', 'gna', 'nba', 'name', 'last'].includes(k.toLowerCase()));
|
||||||
const gnaMatch = sortedKeys.find(k => k.toLowerCase() === 'gna');
|
|
||||||
|
|
||||||
if (vnaMatch) selectFirstName.value = vnaMatch;
|
if (vnaMatch) selectFirstName.value = vnaMatch;
|
||||||
else {
|
else {
|
||||||
|
|
@ -1476,8 +1479,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
if (vMatch) selectFirstName.value = vMatch;
|
if (vMatch) selectFirstName.value = vMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbaMatch) selectLastName.value = nbaMatch;
|
if (gnaMatch) selectLastName.value = gnaMatch;
|
||||||
else if (gnaMatch) selectLastName.value = gnaMatch;
|
|
||||||
else {
|
else {
|
||||||
const nMatch = sortedKeys.find(k => k.toLowerCase().startsWith('n'));
|
const nMatch = sortedKeys.find(k => k.toLowerCase().startsWith('n'));
|
||||||
if (nMatch) selectLastName.value = nMatch;
|
if (nMatch) selectLastName.value = nMatch;
|
||||||
|
|
@ -1553,9 +1555,13 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
const notiz = typeof stored === 'object' ? (stored.notiz || '') : '';
|
const notiz = typeof stored === 'object' ? (stored.notiz || '') : '';
|
||||||
|
|
||||||
const row = document.createElement('tr');
|
const row = document.createElement('tr');
|
||||||
|
// If last name is missing but first name has content, show first name in bold
|
||||||
|
const displayLast = data.last || data.first || 'Unbekannt';
|
||||||
|
const displayFirst = data.last ? data.first : '';
|
||||||
|
|
||||||
row.innerHTML = `
|
row.innerHTML = `
|
||||||
<td><b>${data.last}</b></td>
|
<td><b>${displayLast}</b></td>
|
||||||
<td>${data.first}</td>
|
<td>${displayFirst}</td>
|
||||||
<td style="font-size: 0.75rem; opacity: 0.8;">${data.address}</td>
|
<td style="font-size: 0.75rem; opacity: 0.8;">${data.address}</td>
|
||||||
<td>${data.count} Flurstücke</td>
|
<td>${data.count} Flurstücke</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
||||||
|
|
@ -220,8 +220,8 @@ app.get('/api/layers/alkis', async (req, res) => {
|
||||||
'geometry', ST_AsGeoJSON(ST_Transform(geom, 4326))::jsonb,
|
'geometry', ST_AsGeoJSON(ST_Transform(geom, 4326))::jsonb,
|
||||||
'properties', jsonb_build_object(
|
'properties', jsonb_build_object(
|
||||||
'id', id,
|
'id', id,
|
||||||
'VNA', "VNA",
|
'vorname', "VNA",
|
||||||
'GNA', "GNA",
|
'nachname', "GNA",
|
||||||
'FSK', "FSK",
|
'FSK', "FSK",
|
||||||
'PLZ', "PLZ",
|
'PLZ', "PLZ",
|
||||||
'ORP', "ORP",
|
'ORP', "ORP",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue