Remove manual save button and finalize automatic synchronization between owner table and map
Deploy Bürgerwind / deploy (push) Successful in 17s
Details
Deploy Bürgerwind / deploy (push) Successful in 17s
Details
This commit is contained in:
parent
42237cddcf
commit
c5469e7fa5
63
app.js
63
app.js
|
|
@ -1476,9 +1476,6 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
<td>
|
||||
<input type="text" class="notiz-input" data-owner="${name}" value="${notiz}" placeholder="Notiz..." style="width: 100%; font-size: 0.75rem; padding: 4px; border: 1px solid var(--border-color); border-radius: 4px; background: transparent; color: white;">
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn-secure" data-first="${data.first}" data-last="${data.last}" data-owner="${name}" style="padding: 4px 8px; font-size: 0.75rem; background: var(--primary-color); color: white; border: none; border-radius: 4px; cursor: pointer;">Speichern</button>
|
||||
</td>
|
||||
`;
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -236,7 +236,6 @@
|
|||
<th>Flächen</th>
|
||||
<th>Status</th>
|
||||
<th>Notiz</th>
|
||||
<th>Aktion</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
|
|
|
|||
Loading…
Reference in New Issue