diff --git a/public/index.html b/public/index.html
index 98a89d1..916377a 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1552,6 +1552,35 @@
+
+
+
+
VO bearbeiten
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/public/script.js b/public/script.js
index b9c9d2a..b78f8fd 100644
--- a/public/script.js
+++ b/public/script.js
@@ -4083,7 +4083,11 @@ async function loadVosAdmin() {
${escapeHtml(v.bezeichnung || '')} |
${v.aktiv ? 'Ja' : 'Nein'} |
-
+
|
`;
@@ -4091,8 +4095,11 @@ async function loadVosAdmin() {
btn.addEventListener('click', () => {
const action = btn.dataset.voAction;
const id = parseInt(btn.dataset.id, 10);
- if (action === 'edit') editVo(id, btn.dataset.nummer, btn.dataset.bezeichnung, btn.dataset.aktiv === '1');
- else if (action === 'delete') deleteVo(id, btn.dataset.label);
+ if (action === 'edit') {
+ editVo(id, btn.dataset.nummer, btn.dataset.bezeichnung, btn.dataset.aktiv === '1', btn.dataset.anbieterName);
+ } else if (action === 'delete') {
+ deleteVo(id, btn.dataset.label);
+ }
});
});
tbody.appendChild(tr);
@@ -4124,17 +4131,35 @@ async function addVo() {
} catch (e) { /* already shown */ }
}
-async function editVo(id, nummer, bezeichnung, aktiv) {
- const newNummer = prompt('VO-Nummer:', nummer);
- if (newNummer === null) return;
- const newBezeichnung = prompt('Bezeichnung (leer = keine):', bezeichnung || '');
- if (newBezeichnung === null) return;
+function editVo(id, nummer, bezeichnung, aktiv, anbieterName) {
+ document.getElementById('voEditId').value = id;
+ document.getElementById('voEditAnbieter').value = anbieterName || '';
+ document.getElementById('voEditNummer').value = nummer || '';
+ document.getElementById('voEditBezeichnung').value = bezeichnung || '';
+ document.getElementById('voEditAktiv').checked = !!aktiv;
+ document.getElementById('voEditModal').style.display = 'block';
+}
+
+function closeVoEditModal() {
+ document.getElementById('voEditModal').style.display = 'none';
+}
+
+async function saveVoFromModal() {
+ const id = document.getElementById('voEditId').value;
+ const nummer = document.getElementById('voEditNummer').value.trim();
+ const bezeichnung = document.getElementById('voEditBezeichnung').value.trim();
+ const aktiv = document.getElementById('voEditAktiv').checked;
+ if (!nummer) {
+ showMessage('VO-Nummer darf nicht leer sein', 'error');
+ return;
+ }
try {
await apiRequest(`/api/vos/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ nummer: newNummer.trim(), bezeichnung: newBezeichnung.trim() || null }),
+ body: JSON.stringify({ nummer, bezeichnung: bezeichnung || null, aktiv }),
});
+ closeVoEditModal();
showMessage('VO aktualisiert');
loadVosAdmin();
} catch (e) { /* already shown */ }