diff --git a/public/userarea/export_to_lims.js b/public/userarea/export_to_lims.js
index 023c580..cf28fad 100644
--- a/public/userarea/export_to_lims.js
+++ b/public/userarea/export_to_lims.js
@@ -330,8 +330,16 @@ document.addEventListener("DOMContentLoaded", () => {
// Validate first
clearValidationErrors();
+ // Show validating state on the row
+ setRowExporting(gridRow, true);
+ const spinner = gridRow.querySelector(".batch-row-spinner");
+ if (spinner) spinner.innerHTML = ' Validating...';
+
validateRows([{ iddatadb: parseInt(iddatadb), index: parseInt(rowIndex) }])
.then((validationData) => {
+ setRowExporting(gridRow, false);
+ gridRow.classList.remove("batch-disabled");
+
if (!validationData.success) {
showExportResult({ success: false, message: validationData.message || "Errore di validazione" });
return;
@@ -348,6 +356,9 @@ document.addEventListener("DOMContentLoaded", () => {
showConfirmAndExport(iddatadb, btn);
})
.catch((error) => {
+ setRowExporting(gridRow, false);
+ gridRow.classList.remove("batch-disabled");
+
console.error("Validation error:", error);
showExportResult({ success: false, message: "Errore di validazione: " + error.message });
});
@@ -379,13 +390,29 @@ document.addEventListener("DOMContentLoaded", () => {
console.log(`Confirmed export for iddatadb: ${iddatadb}`);
confirmModal.hide();
+ const gridRow = btn.closest(".grid-row");
+ setRowExporting(gridRow, true);
+
try {
- const gridRow = btn.closest(".grid-row");
const data = await sendExport(iddatadb, gridRow);
console.log("Export response:", data);
+
+ // Stop spinner, fully restore row
+ setRowExporting(gridRow, false);
+ gridRow.classList.remove("batch-disabled");
+
+ if (!data.success) {
+ showRowError(gridRow, iddatadb, data.message || "Errore sconosciuto");
+ }
showExportResult(data);
} catch (error) {
console.error("Export error:", error);
+
+ // Stop spinner, fully restore row so user can retry
+ setRowExporting(gridRow, false);
+ gridRow.classList.remove("batch-disabled");
+
+ showRowError(gridRow, iddatadb, error.message);
showExportResult({
success: false,
message: error.message,
diff --git a/public/userarea/import_edit2.php b/public/userarea/import_edit2.php
index ac7dffc..cb6d978 100644
--- a/public/userarea/import_edit2.php
+++ b/public/userarea/import_edit2.php
@@ -1550,6 +1550,14 @@ function fixedDefaultValue(array $f): string
const rowIndex = btn.dataset.row;
const row = btn.closest('.grid-row');
const iddatadb = row.getAttribute('data-id');
+
+ // Show spinner on save button
+ const origHtml = btn.innerHTML;
+ btn.innerHTML = '';
+ btn.disabled = true;
+ row.style.opacity = '0.6';
+ row.style.pointerEvents = 'none';
+
const formData = new FormData();
const inputs = row.querySelectorAll(`input[name^="rows[${rowIndex}][details]"], select[name^="rows[${rowIndex}][details]"]`);
@@ -1638,6 +1646,12 @@ function fixedDefaultValue(array $f): string
})
.catch(error => {
alert('Errore durante il salvataggio: ' + error.message);
+ })
+ .finally(() => {
+ btn.innerHTML = origHtml;
+ btn.disabled = false;
+ row.style.opacity = '';
+ row.style.pointerEvents = '';
});
});
});