Replace VO edit prompt() with a proper modal dialog
The browser's native prompt() chain was awkward and made it impossible to clear the bezeichnung in a single, predictable flow. The new modal mirrors the user-management dialog: it shows the provider read-only, lets you edit nummer and bezeichnung, and exposes the aktiv flag explicitly. Empty bezeichnung now correctly clears the field. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
f2ab23f261
commit
97ff779bcf
2 files changed
+63
-9
No files matched your search
+34
-9
@@ -4083,7 +4083,11 @@ async function loadVosAdmin() {
|
||||
<td>${escapeHtml(v.bezeichnung || '')}</td>
|
||||
<td>${v.aktiv ? '<span style="color:#27ae60;">Ja</span>' : '<span style="color:#c0392b;">Nein</span>'}</td>
|
||||
<td>
|
||||
<button data-vo-action="edit" data-id="${v.id}" data-nummer="${escapeHtml(v.nummer)}" data-bezeichnung="${escapeHtml(v.bezeichnung || '')}" data-aktiv="${v.aktiv}" class="btn-success" style="margin-right:5px;">Bearbeiten</button>
|
||||
<button data-vo-action="edit" data-id="${v.id}"
|
||||
data-anbieter-name="${escapeHtml(v.anbieter_name)}"
|
||||
data-nummer="${escapeHtml(v.nummer)}"
|
||||
data-bezeichnung="${escapeHtml(v.bezeichnung || '')}"
|
||||
data-aktiv="${v.aktiv}" class="btn-success" style="margin-right:5px;">Bearbeiten</button>
|
||||
<button data-vo-action="delete" data-id="${v.id}" data-label="${escapeHtml(v.nummer + (v.bezeichnung ? ' (' + v.bezeichnung + ')' : ''))}" class="btn-danger">Löschen</button>
|
||||
</td>
|
||||
`;
|
||||
@@ -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 */ }
|
||||
|
||||
Reference in new issue
Block a user