feat: remove page reloads on scan, use DOM updates for speed

This commit is contained in:
Javier
2026-02-11 09:24:44 -06:00
parent deb74fd971
commit ea403934d3
2 changed files with 15 additions and 7 deletions

View File

@@ -307,8 +307,12 @@ function processSmartScan(barcode, confirm = false) {
feedbackArea.style.border = '1px solid #28a745';
feedbackText.style.color = '#28a745';
feedbackText.textContent = data.message;
if (data.message.includes('Saved')) setTimeout(() => location.reload(), 800);
} else {
if (data.detail_id && data.data) {
addScanToList(data.detail_id, data.data, data.data.duplicate_status);
}
setTimeout(() => feedbackArea.style.display = 'none', 1000);
}
else {
feedbackArea.style.background = 'rgba(220, 53, 69, 0.2)';
feedbackArea.style.border = '1px solid #dc3545';
feedbackText.style.color = '#dc3545';
@@ -357,8 +361,12 @@ function saveSmartScanData() {
.then(data => {
if (data.success) {
document.getElementById('fieldsModal').style.display = 'none';
// Optional: Small delay to let the user see it worked
setTimeout(() => location.reload(), 300);
if (data.detail_id && data.data) {
addScanToList(data.detail_id, data.data, data.data.duplicate_status);
}
currentDupKeyValue = '';
smartInput.value = '';
smartInput.focus();
} else if (data.needs_input) {
alert("Error: Please fill in all required fields.");
} else {