per-row buttons locking, progress
This commit is contained in:
parent
5dedc779df
commit
eb21910ef3
@ -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 = '<i class="fas fa-spinner fa-spin"></i> 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,
|
||||
|
||||
@ -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 = '<i class="fas fa-spinner fa-spin"></i>';
|
||||
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 = '';
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user