Changes to the library scanning function
Release Inventarsystem / release-docker (push) Successful in 3m11s

This commit is contained in:
2026-09-10 19:42:32 +02:00
parent 09efedad69
commit 6a3a5d6373
+41 -5
View File
@@ -1425,7 +1425,10 @@
updatePhysicalScannerModal(result.message || 'Scan-Aktion fehlgeschlagen.', 'error'); updatePhysicalScannerModal(result.message || 'Scan-Aktion fehlgeschlagen.', 'error');
} else if (result.action === 'borrowed') { } else if (result.action === 'borrowed') {
setScanStatus(`Ausgeliehen: ${result.item_name}`, 'ok'); setScanStatus(`Ausgeliehen: ${result.item_name}`, 'ok');
showSmallConfirm(`Ausgeliehen: ${result.item_name}`, 'ok'); showSmallConfirm(`Ausgeliehen: ${result.item_name}`, 'ok', {
actionLabel: 'Mit nächstem Ausweis starten',
onAction: startNextStudentCardScan
});
updatePhysicalScannerModal('Ausleihe erfolgreich. Bereit für den nächsten Mediencode.', 'ok'); updatePhysicalScannerModal('Ausleihe erfolgreich. Bereit für den nächsten Mediencode.', 'ok');
} else if (result.action === 'returned') { } else if (result.action === 'returned') {
setScanStatus(`Zurückgegeben: ${result.item_name}`, 'ok'); setScanStatus(`Zurückgegeben: ${result.item_name}`, 'ok');
@@ -1491,7 +1494,10 @@
if (result.action === 'borrowed') { if (result.action === 'borrowed') {
setScanStatus(`Ausgeliehen: ${result.item_name}`, 'ok'); setScanStatus(`Ausgeliehen: ${result.item_name}`, 'ok');
showSmallConfirm(`Ausgeliehen: ${result.item_name}`, 'ok'); showSmallConfirm(`Ausgeliehen: ${result.item_name}`, 'ok', {
actionLabel: 'Mit nächstem Ausweis starten',
onAction: startNextStudentCardScan
});
updatePhysicalScannerModal('Ausleihe erfolgreich. Bereit für den nächsten Mediencode.', 'ok'); updatePhysicalScannerModal('Ausleihe erfolgreich. Bereit für den nächsten Mediencode.', 'ok');
} else if (result.action === 'returned') { } else if (result.action === 'returned') {
setScanStatus(`Zurückgegeben: ${result.item_name}`, 'ok'); setScanStatus(`Zurückgegeben: ${result.item_name}`, 'ok');
@@ -1657,21 +1663,51 @@
if (kind) el.classList.add(kind); if (kind) el.classList.add(kind);
} }
function showSmallConfirm(message, kind='ok') { function showSmallConfirm(message, kind='ok', action = null) {
// Append the small helper text in German // Append the small helper text in German
const helper = 'Sie können fortfahren. Dies ist nur eine kleine Benachrichtigung.'; const helper = 'Sie können fortfahren. Dies ist nur eine kleine Benachrichtigung.';
const el = document.createElement('div'); const el = document.createElement('div');
el.className = `small-popup ${kind === 'error' ? 'error' : 'ok'}`; el.className = `small-popup ${kind === 'error' ? 'error' : 'ok'}`;
el.innerHTML = `<div>${escapeHtml(String(message || ''))}</div><div style="opacity:0.9; margin-left:8px; font-size:0.85em;">${helper}</div><div class="close-x">&times;</div>`; el.innerHTML = `<div>${escapeHtml(String(message || ''))}</div><div style="opacity:0.9; margin-left:8px; font-size:0.85em;">${helper}</div>`;
if (action && typeof action.onAction === 'function') {
const actionButton = document.createElement('button');
actionButton.type = 'button';
actionButton.textContent = action.actionLabel || 'Weiter';
actionButton.style.marginLeft = '8px';
actionButton.style.padding = '6px 10px';
actionButton.style.cursor = 'pointer';
actionButton.addEventListener('click', () => {
if (el.parentNode) el.parentNode.removeChild(el);
action.onAction();
});
el.appendChild(actionButton);
}
const closeButton = document.createElement('div');
closeButton.className = 'close-x';
closeButton.innerHTML = '&times;';
el.appendChild(closeButton);
document.body.appendChild(el); document.body.appendChild(el);
// close handler // close handler
el.querySelector('.close-x').addEventListener('click', () => { closeButton.addEventListener('click', () => {
if (el && el.parentNode) el.parentNode.removeChild(el); if (el && el.parentNode) el.parentNode.removeChild(el);
}); });
// auto remove after 3 seconds // auto remove after 3 seconds
setTimeout(() => { try { if (el && el.parentNode) el.parentNode.removeChild(el); } catch(e){} }, 3000); setTimeout(() => { try { if (el && el.parentNode) el.parentNode.removeChild(el); } catch(e){} }, 3000);
} }
async function startNextStudentCardScan() {
setActiveStudentCard('');
setScanStatus('Bereit für den nächsten Ausweis.', 'warn');
updatePhysicalScannerModal('Bereit für den nächsten Ausweis.', 'warn');
const mode = document.getElementById('scanModeSelect')?.value;
if (!physicalScannerModalOpen && (mode === 'quick_toggle' || mode === 'continuous') && !scannerRunning) {
await startScanner();
}
}
function setActiveStudentCard(cardId) { function setActiveStudentCard(cardId) {
activeStudentCardId = (cardId || '').trim().toUpperCase(); activeStudentCardId = (cardId || '').trim().toUpperCase();
const input = document.getElementById('activeStudentCard'); const input = document.getElementById('activeStudentCard');