feat(reception,udeci): v3.8.48 - forced scanner focus, spanish keyboard gun normalization, reception default dashboard, and udeci commission listings
This commit is contained in:
@@ -52,18 +52,23 @@
|
||||
|
||||
<!-- Entrada Manual o Pistola Óptica USB -->
|
||||
<div class="mt-4 pt-3 border-top">
|
||||
<label class="form-label small fw-bold text-uppercase text-muted">
|
||||
<i class="bi bi-upc-scan me-1 text-primary"></i> Pistola Óptica USB o Entrada Manual por DNI
|
||||
</label>
|
||||
<div class="d-flex align-items-center justify-content-between mb-1">
|
||||
<label class="form-label small fw-bold text-uppercase text-muted mb-0">
|
||||
<i class="bi bi-upc-scan me-1 text-primary"></i> Pistola Óptica USB o Entrada Manual
|
||||
</label>
|
||||
<span class="small text-success fw-semibold d-flex align-items-center gap-1" id="scannerFocusIndicator" title="El cursor está bloqueado en este campo para recibir el escaneo inmediato">
|
||||
<span class="scanner-active-dot"></span> Lector Listo
|
||||
</span>
|
||||
</div>
|
||||
<form id="manualScanForm" onsubmit="handleManualScan(event)">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control rounded-start-pill ps-3" id="scannerInput"
|
||||
<div class="input-group shadow-sm rounded-pill overflow-hidden border border-2 border-primary">
|
||||
<input type="text" class="form-control rounded-start-pill ps-3 border-0" id="scannerInput"
|
||||
placeholder="Escanea con la pistola o escribe el DNI..." autofocus autocomplete="off">
|
||||
<button class="btn btn-primary rounded-end-pill px-4 fw-semibold" type="submit">
|
||||
<button class="btn btn-primary rounded-end-pill px-4 fw-semibold border-0" type="submit">
|
||||
Validar
|
||||
</button>
|
||||
</div>
|
||||
<span class="small text-muted d-block mt-1">El lector óptico envía la lectura directamente a este campo con retorno de carro automático.</span>
|
||||
<span class="small text-muted d-block mt-1">El cursor se mantiene siempre activo aquí. La pistola óptica envía la lectura y valida automáticamente.</span>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -234,14 +239,46 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Mantener el cursor forzado permanentemente en el input de la pistola óptica
|
||||
function focusScannerInput() {
|
||||
const input = document.getElementById('scannerInput');
|
||||
if (!input) return;
|
||||
const active = document.activeElement;
|
||||
// Evitar robar el foco solo si el usuario está activamente en el selector de sedes
|
||||
if (active && active.id === 'buildingSelect') return;
|
||||
if (active !== input) {
|
||||
input.focus();
|
||||
}
|
||||
updateFocusIndicator(true);
|
||||
}
|
||||
|
||||
function updateFocusIndicator(isFocused) {
|
||||
const indicator = document.getElementById('scannerFocusIndicator');
|
||||
if (!indicator) return;
|
||||
if (isFocused) {
|
||||
indicator.className = 'small text-success fw-semibold d-flex align-items-center gap-1';
|
||||
indicator.innerHTML = '<span class="scanner-active-dot"></span> Lector Listo';
|
||||
} else {
|
||||
indicator.className = 'small text-warning fw-semibold d-flex align-items-center gap-1';
|
||||
indicator.innerHTML = '<i class="bi bi-exclamation-circle"></i> Haz clic para activar';
|
||||
}
|
||||
}
|
||||
|
||||
// Entrada manual o con pistola de código de barras
|
||||
function handleManualScan(e) {
|
||||
e.preventDefault();
|
||||
if (e) e.preventDefault();
|
||||
const input = document.getElementById('scannerInput');
|
||||
const val = input.value.trim();
|
||||
if (!val) return;
|
||||
if (!input) return;
|
||||
let val = input.value.trim();
|
||||
if (!val) {
|
||||
focusScannerInput();
|
||||
return;
|
||||
}
|
||||
// Normalización para teclados en español / latinoamericano donde la pistola traduce : a Ñ
|
||||
val = val.replace(/Ñ/g, ':').replace(/ñ/g, ':');
|
||||
verifyToken(val);
|
||||
input.value = '';
|
||||
setTimeout(focusScannerInput, 50);
|
||||
}
|
||||
|
||||
// Petición AJAX de verificación al Backend BFF
|
||||
@@ -268,6 +305,8 @@
|
||||
message: 'Error de conexión con el validador.',
|
||||
todays_classes: []
|
||||
});
|
||||
} finally {
|
||||
setTimeout(focusScannerInput, 150);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,5 +425,51 @@
|
||||
setTimeout(() => { osc.stop(); }, 120);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// Eventos globales para forzar el foco permanente en scannerInput
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
focusScannerInput();
|
||||
setInterval(focusScannerInput, 2000);
|
||||
|
||||
const input = document.getElementById('scannerInput');
|
||||
if (input) {
|
||||
input.addEventListener('focus', () => updateFocusIndicator(true));
|
||||
input.addEventListener('blur', () => {
|
||||
setTimeout(() => {
|
||||
const active = document.activeElement;
|
||||
if (active && active.id !== 'buildingSelect') {
|
||||
focusScannerInput();
|
||||
} else {
|
||||
updateFocusIndicator(false);
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('focus', focusScannerInput);
|
||||
|
||||
document.addEventListener('click', (e) => {
|
||||
// Si el usuario no hace clic sobre el selector de sedes o botones interactivos, regresar el cursor al input
|
||||
if (!e.target.closest('select, button, a, #reader')) {
|
||||
focusScannerInput();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.scanner-active-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background-color: #22c55e;
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
animation: pulse-dot 1.5s infinite ease-in-out;
|
||||
}
|
||||
@keyframes pulse-dot {
|
||||
0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
|
||||
70% { transform: scale(1.15); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
|
||||
100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user