Aggiunto campo per inserire codice a barre manualmente
- Nuovo campo numerico nella pagina scansione per digitare il barcode - Supporto tasto Invio per ricerca rapida - Validazione: solo numeri, 4-14 cifre - Riusa lo stesso flusso della scansione automatica (onBarcodeDetected)
This commit is contained in:
@@ -727,6 +727,28 @@ body {
|
|||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.barcode-manual-entry {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.barcode-input-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.barcode-input-row .form-input {
|
||||||
|
flex: 1;
|
||||||
|
margin: 0;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.barcode-input-row .btn {
|
||||||
|
white-space: nowrap;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.scan-hint {
|
.scan-hint {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
|
|||||||
@@ -743,6 +743,23 @@ async function onBarcodeDetected(barcode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function submitManualBarcode() {
|
||||||
|
const input = document.getElementById('manual-barcode-input');
|
||||||
|
const barcode = (input.value || '').trim();
|
||||||
|
if (!barcode) {
|
||||||
|
showToast('Inserisci un codice a barre', 'error');
|
||||||
|
input.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!/^\d{4,14}$/.test(barcode)) {
|
||||||
|
showToast('Il codice a barre deve contenere solo numeri (4-14 cifre)', 'error');
|
||||||
|
input.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
stopScanner();
|
||||||
|
onBarcodeDetected(barcode);
|
||||||
|
}
|
||||||
|
|
||||||
function startManualEntry(barcode = '') {
|
function startManualEntry(barcode = '') {
|
||||||
stopScanner();
|
stopScanner();
|
||||||
// Reset form
|
// Reset form
|
||||||
|
|||||||
+7
-1
@@ -113,6 +113,12 @@
|
|||||||
<canvas id="scanner-canvas" style="display:none"></canvas>
|
<canvas id="scanner-canvas" style="display:none"></canvas>
|
||||||
</div>
|
</div>
|
||||||
<div class="scan-result" id="scan-result" style="display:none"></div>
|
<div class="scan-result" id="scan-result" style="display:none"></div>
|
||||||
|
<div class="barcode-manual-entry">
|
||||||
|
<div class="barcode-input-row">
|
||||||
|
<input type="text" id="manual-barcode-input" class="form-input" placeholder="Inserisci codice a barre..." inputmode="numeric" pattern="[0-9]*" onkeydown="if(event.key==='Enter')submitManualBarcode()">
|
||||||
|
<button class="btn btn-primary" onclick="submitManualBarcode()">🔍 Cerca</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="scan-actions">
|
<div class="scan-actions">
|
||||||
<button class="btn btn-large btn-secondary" onclick="startManualEntry()">
|
<button class="btn btn-large btn-secondary" onclick="startManualEntry()">
|
||||||
✏️ Inserimento Manuale
|
✏️ Inserimento Manuale
|
||||||
@@ -121,7 +127,7 @@
|
|||||||
🤖 Identifica con AI
|
🤖 Identifica con AI
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<p class="scan-hint">Inquadra il codice a barre del prodotto oppure usa i pulsanti sotto</p>
|
<p class="scan-hint">Inquadra il codice a barre del prodotto oppure inseriscilo manualmente</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user