qol and scan fixes

This commit is contained in:
Shiro-Nek0
2026-02-26 23:29:45 -03:00
parent 43b2a9e2d5
commit 0f9966d224
2 changed files with 39 additions and 9 deletions

View File

@@ -23,6 +23,7 @@ docker run -d \
-v $(pwd)/sekipos/db:/app/db \ -v $(pwd)/sekipos/db:/app/db \
-v $(pwd)/sekipos/static/cache:/app/static/cache \ -v $(pwd)/sekipos/static/cache:/app/static/cache \
--name sekipos-server \ --name sekipos-server \
--restart unless-stopped \
sekipos:latest sekipos:latest
``` ```

View File

@@ -345,8 +345,14 @@
</div> </div>
<!-- Search --> <!-- Search -->
<input type="text" id="searchInput" class="form-control mb-3" onkeyup="searchTable()" <div class="position-relative mb-3">
<input type="text" id="searchInput" class="form-control pe-5" onkeyup="searchTable()"
placeholder="Filtrar productos..."> placeholder="Filtrar productos...">
<button class="btn btn-link position-absolute end-0 top-50 translate-middle-y text-muted"
onclick="clearSearch()" id="clearSearchBtn" style="display: none; text-decoration: none;">
<i class="bi bi-x-lg"></i>
</button>
</div>
<!-- Table --> <!-- Table -->
<div class="table-responsive"> <div class="table-responsive">
@@ -513,17 +519,18 @@
} }
formatAll(); formatAll();
// Inside socket.on('new_scan')
socket.on('new_scan', d => { socket.on('new_scan', d => {
// Update the "Last Scanned" card
document.getElementById('display-name').innerText = d.name; document.getElementById('display-name').innerText = d.name;
document.getElementById('display-price').innerText = clp.format(d.price); document.getElementById('display-price').innerText = clp.format(d.price);
document.getElementById('display-barcode').innerText = d.barcode; document.getElementById('display-barcode').innerText = d.barcode;
document.getElementById('display-img').src = d.image || './static/placeholder.png'; document.getElementById('display-img').src = d.image || './static/placeholder.png';
let title = 'Editando: ' + d.name; let title = 'Editando: ' + d.name;
if (d.note) { if (d.note) title += ` (${d.note})`;
title += ` (${d.note})`; // This will show "Editando: Item (Imagen recuperada)"
}
// Update the actual form
updateForm(d.barcode, d.name, d.price, d.image, title); updateForm(d.barcode, d.name, d.price, d.image, title);
}); });
@@ -531,6 +538,14 @@
const prompt = document.getElementById('new-product-prompt'); const prompt = document.getElementById('new-product-prompt');
document.getElementById('new-barcode-display').innerText = d.barcode; document.getElementById('new-barcode-display').innerText = d.barcode;
prompt.classList.remove('d-none'); 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); updateForm(d.barcode, d.name || '', '', d.image || '', 'Crear: ' + d.barcode);
}); });
@@ -538,8 +553,9 @@
dismissPrompt(); dismissPrompt();
document.getElementById('form-barcode').value = b; document.getElementById('form-barcode').value = b;
document.getElementById('form-name').value = n; document.getElementById('form-name').value = n;
document.getElementById('form-price').value = p; // If p is undefined (from scan_error), set value to empty string
document.getElementById('form-image').value = i; document.getElementById('form-price').value = (p !== undefined && p !== null) ? p : '';
document.getElementById('form-image').value = i || '';
document.getElementById('form-title').innerText = t; document.getElementById('form-title').innerText = t;
} }
@@ -681,14 +697,27 @@
/* ── Search ── */ /* ── Search ── */
function searchTable() { 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 => { document.querySelectorAll('#inventoryTable tbody tr').forEach(tr => {
tr.style.display = tr.innerText.toUpperCase().includes(q) ? '' : 'none'; tr.style.display = tr.innerText.toUpperCase().includes(q) ? '' : 'none';
}); });
// Reset select-all when search changes
document.getElementById('select-all').checked = false; 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();
}
</script> </script>
</body> </body>