Changes to the library scanning function
Release Inventarsystem / release-docker (push) Successful in 3m11s
Release Inventarsystem / release-docker (push) Successful in 3m11s
This commit is contained in:
@@ -1425,7 +1425,10 @@
|
||||
updatePhysicalScannerModal(result.message || 'Scan-Aktion fehlgeschlagen.', 'error');
|
||||
} else if (result.action === 'borrowed') {
|
||||
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');
|
||||
} else if (result.action === 'returned') {
|
||||
setScanStatus(`Zurückgegeben: ${result.item_name}`, 'ok');
|
||||
@@ -1491,7 +1494,10 @@
|
||||
|
||||
if (result.action === 'borrowed') {
|
||||
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');
|
||||
} else if (result.action === 'returned') {
|
||||
setScanStatus(`Zurückgegeben: ${result.item_name}`, 'ok');
|
||||
@@ -1657,21 +1663,51 @@
|
||||
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
|
||||
const helper = 'Sie können fortfahren. Dies ist nur eine kleine Benachrichtigung.';
|
||||
const el = document.createElement('div');
|
||||
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">×</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 = '×';
|
||||
el.appendChild(closeButton);
|
||||
document.body.appendChild(el);
|
||||
// close handler
|
||||
el.querySelector('.close-x').addEventListener('click', () => {
|
||||
closeButton.addEventListener('click', () => {
|
||||
if (el && el.parentNode) el.parentNode.removeChild(el);
|
||||
});
|
||||
// auto remove after 3 seconds
|
||||
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) {
|
||||
activeStudentCardId = (cardId || '').trim().toUpperCase();
|
||||
const input = document.getElementById('activeStudentCard');
|
||||
|
||||
Reference in New Issue
Block a user