From 0f9966d224adf9ba8c748db2868fb1e2ea8e9e32 Mon Sep 17 00:00:00 2001 From: Shiro-Nek0 Date: Thu, 26 Feb 2026 23:29:45 -0300 Subject: [PATCH] qol and scan fixes --- README.md | 1 + templates/index.html | 47 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 33cc160..8562dc8 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ docker run -d \ -v $(pwd)/sekipos/db:/app/db \ -v $(pwd)/sekipos/static/cache:/app/static/cache \ --name sekipos-server \ + --restart unless-stopped \ sekipos:latest ``` diff --git a/templates/index.html b/templates/index.html index 37c8968..8e32b1c 100644 --- a/templates/index.html +++ b/templates/index.html @@ -345,8 +345,14 @@ - +
+ + +
@@ -513,17 +519,18 @@ } formatAll(); + // Inside socket.on('new_scan') socket.on('new_scan', d => { + // Update the "Last Scanned" card document.getElementById('display-name').innerText = d.name; document.getElementById('display-price').innerText = clp.format(d.price); document.getElementById('display-barcode').innerText = d.barcode; document.getElementById('display-img').src = d.image || './static/placeholder.png'; let title = 'Editando: ' + d.name; - if (d.note) { - title += ` (${d.note})`; // This will show "Editando: Item (Imagen recuperada)" - } + if (d.note) title += ` (${d.note})`; + // Update the actual form updateForm(d.barcode, d.name, d.price, d.image, title); }); @@ -531,6 +538,14 @@ const prompt = document.getElementById('new-product-prompt'); document.getElementById('new-barcode-display').innerText = d.barcode; prompt.classList.remove('d-none'); + + // Update the "Last Scanned" card so it doesn't show old data + document.getElementById('display-name').innerText = d.name || "Producto Nuevo"; + document.getElementById('display-price').innerText = clp.format(0); + document.getElementById('display-barcode').innerText = d.barcode; + document.getElementById('display-img').src = d.image || './static/placeholder.png'; + + // Clear the price and set the name in the form updateForm(d.barcode, d.name || '', '', d.image || '', 'Crear: ' + d.barcode); }); @@ -538,8 +553,9 @@ dismissPrompt(); document.getElementById('form-barcode').value = b; document.getElementById('form-name').value = n; - document.getElementById('form-price').value = p; - document.getElementById('form-image').value = i; + // If p is undefined (from scan_error), set value to empty string + document.getElementById('form-price').value = (p !== undefined && p !== null) ? p : ''; + document.getElementById('form-image').value = i || ''; document.getElementById('form-title').innerText = t; } @@ -681,14 +697,27 @@ /* ── Search ── */ function searchTable() { - const q = document.getElementById('searchInput').value.toUpperCase(); + const input = document.getElementById('searchInput'); + const q = input.value.toUpperCase(); + const clearBtn = document.getElementById('clearSearchBtn'); + + // Show/hide clear button based on input + clearBtn.style.display = q.length > 0 ? 'block' : 'none'; + document.querySelectorAll('#inventoryTable tbody tr').forEach(tr => { tr.style.display = tr.innerText.toUpperCase().includes(q) ? '' : 'none'; }); - // Reset select-all when search changes + document.getElementById('select-all').checked = false; } + function clearSearch() { + const input = document.getElementById('searchInput'); + input.value = ''; + searchTable(); // Re-run search to show all rows + input.focus(); + } +