fixed tested components

This commit is contained in:
Claudio 2026-03-18 16:11:03 +01:00
parent 9c850e4ea6
commit f4e0074a73
2 changed files with 54 additions and 22 deletions

File diff suppressed because one or more lines are too long

View File

@ -364,8 +364,15 @@ function fixedDefaultValue(array $f): string
}
@keyframes batch-pulse {
0%, 100% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
0%,
100% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
}
.batch-row-spinner {
@ -1191,7 +1198,7 @@ function fixedDefaultValue(array $f): string
<!-- commented only for admin roles -->
<?php if ((Auth::user()->hasRole('Admin'))) : ?>
<?php $isExported = (($row['status'] ?? '') === 'l'); ?>
<button type="button" class="export-lims-btn action-btn" data-row="<?= $index ?>" data-iddatadb="<?= $row['iddatadb'] ?>" title="<?= $isExported ? 'Già esportato' : 'Export to LIMS' ?>" style="background: <?= $isExported ? '#ccc' : '#eb0b0b' ?>; color: white; border: none; border-radius: 5px; cursor: <?= $isExported ? 'not-allowed' : 'pointer' ?>; <?= $isExported ? 'opacity: 0.5;' : '' ?>"<?= $isExported ? ' disabled' : '' ?>><i class="fas fa-upload"></i></button>
<button type="button" class="export-lims-btn action-btn" data-row="<?= $index ?>" data-iddatadb="<?= $row['iddatadb'] ?>" title="<?= $isExported ? 'Già esportato' : 'Export to LIMS' ?>" style="background: <?= $isExported ? '#ccc' : '#eb0b0b' ?>; color: white; border: none; border-radius: 5px; cursor: <?= $isExported ? 'not-allowed' : 'pointer' ?>; <?= $isExported ? 'opacity: 0.5;' : '' ?>" <?= $isExported ? ' disabled' : '' ?>><i class="fas fa-upload"></i></button>
<?php endif; ?>
<button type="button" class="save-btn action-btn" data-row="<?= $index ?>" title="Save" style="background: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;"><i class="fas fa-save"></i></button>
@ -1229,7 +1236,7 @@ function fixedDefaultValue(array $f): string
<?= htmlspecialchars($row['status'] === 'i' ? 'Imported' : ($row['status'] === 'P' ? 'In Progress' : 'To LIMS')) ?>
</span>
<?php if (!empty($row['commessaweb'])): ?>
<span class="commessaweb-code" style="display:block; font-size:0.75em; color:#555; margin-top:2px;" title="CommessaWeb"><?= htmlspecialchars($row['commessaweb']) ?></span>
<span class="commessaweb-code" style="display:block; font-size:0.75em; color:#555; margin-top:2px;" title="CommessaWeb"><?= htmlspecialchars($row['commessaweb']) ?></span>
<?php endif; ?>
<input type="hidden" name="rows[<?= $index ?>][status]" value="<?= htmlspecialchars($row['status'] ?? 'i') ?>">
</div>
@ -1639,7 +1646,9 @@ function fixedDefaultValue(array $f): string
document.querySelector('.save-all-btn').addEventListener('click', (e) => {
e.preventDefault();
if (saveAllRunning || window.batchRunning) return;
const confirmModal = new bootstrap.Modal(document.getElementById('saveAllConfirmModal'), { keyboard: false });
const confirmModal = new bootstrap.Modal(document.getElementById('saveAllConfirmModal'), {
keyboard: false
});
confirmModal.show();
});
@ -1657,7 +1666,11 @@ function fixedDefaultValue(array $f): string
// Disable all row buttons
document.querySelectorAll('.grid-row[data-id]').forEach(r => r.classList.add('batch-disabled'));
const toggle = document.querySelector('.actions-dropdown .dropdown-toggle');
if (toggle) { toggle.disabled = true; toggle.style.opacity = '0.5'; toggle.style.pointerEvents = 'none'; }
if (toggle) {
toggle.disabled = true;
toggle.style.opacity = '0.5';
toggle.style.pointerEvents = 'none';
}
// Show status bar
const bar = document.getElementById('batchExportBar');
@ -1674,10 +1687,14 @@ function fixedDefaultValue(array $f): string
for (const row of rows) {
const saveBtn = row.querySelector('.save-btn');
if (!saveBtn) { continue; }
if (!saveBtn) {
continue;
}
const rowIndex = saveBtn.dataset.row;
const iddatadb = row.getAttribute('data-id');
if (!rowIndex || !iddatadb) { continue; }
if (!rowIndex || !iddatadb) {
continue;
}
processed++;
statusEl.textContent = `Salvataggio ${processed} / ${total} (id: ${iddatadb})...`;
@ -1687,7 +1704,10 @@ function fixedDefaultValue(array $f): string
row.classList.add('batch-exporting');
const btnCell = row.querySelector('.button-cell');
if (btnCell) {
btnCell.querySelectorAll('.action-btn').forEach(b => { b.dataset.prevDisplay = b.style.display; b.style.display = 'none'; });
btnCell.querySelectorAll('.action-btn').forEach(b => {
b.dataset.prevDisplay = b.style.display;
b.style.display = 'none';
});
const spinner = document.createElement('span');
spinner.className = 'batch-row-spinner';
spinner.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Saving...';
@ -1785,7 +1805,10 @@ function fixedDefaultValue(array $f): string
if (btnCell) {
const sp = btnCell.querySelector('.batch-row-spinner');
if (sp) sp.remove();
btnCell.querySelectorAll('.action-btn').forEach(b => { b.style.display = b.dataset.prevDisplay || ''; delete b.dataset.prevDisplay; });
btnCell.querySelectorAll('.action-btn').forEach(b => {
b.style.display = b.dataset.prevDisplay || '';
delete b.dataset.prevDisplay;
});
}
}
@ -1798,7 +1821,11 @@ function fixedDefaultValue(array $f): string
// Re-enable all row buttons
document.querySelectorAll('.grid-row[data-id]').forEach(r => r.classList.remove('batch-disabled'));
if (toggle) { toggle.disabled = false; toggle.style.opacity = ''; toggle.style.pointerEvents = ''; }
if (toggle) {
toggle.disabled = false;
toggle.style.opacity = '';
toggle.style.pointerEvents = '';
}
const resultEl = document.getElementById('saveAllResultMessage');
const resultLabel = document.getElementById('saveAllResultModalLabel');
@ -1809,7 +1836,9 @@ function fixedDefaultValue(array $f): string
resultLabel.textContent = 'Salvataggio con Errori';
resultEl.innerHTML = `<i class="fas fa-exclamation-triangle" style="color:#ffc107;"></i> Salvate <strong>${successCount}</strong> righe con successo.<br><br><strong>Errori:</strong><br>` + errorMessages.join('<br>');
}
new bootstrap.Modal(document.getElementById('saveAllResultModal'), { keyboard: false }).show();
new bootstrap.Modal(document.getElementById('saveAllResultModal'), {
keyboard: false
}).show();
});
window.addEventListener("beforeunload", function(e) {
@ -2473,7 +2502,9 @@ function fixedDefaultValue(array $f): string
$('.searchable-client').on('select2:select select2:clear', function(e) {
// Trigger native change on the real <select> element so
// addEventListener('change') handlers can detect modifications.
const nativeEvent = new Event('change', { bubbles: true });
const nativeEvent = new Event('change', {
bubbles: true
});
this.dispatchEvent(nativeEvent);
});
@ -2485,7 +2516,9 @@ function fixedDefaultValue(array $f): string
const clientSelect = row.querySelector('select[name$="[idclient]"]');
if (clientSelect) {
$(clientSelect).val(value).trigger('change.select2');
const event = new Event('change', { bubbles: true });
const event = new Event('change', {
bubbles: true
});
clientSelect.dispatchEvent(event);
}
});
@ -2499,7 +2532,9 @@ function fixedDefaultValue(array $f): string
const fornitoreSelect = row.querySelector('select[name$="[cliente_fornitore_id]"]');
if (fornitoreSelect) {
$(fornitoreSelect).val(value).trigger('change.select2');
const event = new Event('change', { bubbles: true });
const event = new Event('change', {
bubbles: true
});
fornitoreSelect.dispatchEvent(event);
}
});
@ -2523,10 +2558,7 @@ function fixedDefaultValue(array $f): string
.map(s => s.trim())
.filter(s => s.length > 0);
// (opzionale) dedup per evitare doppioni tipo "Cap | Cap"
const uniqueParts = [...new Set(parts)];
if (!uniqueParts.length) {
if (!parts.length) {
alert('⚠️ Inserisci prima una descrizione nel campo Tested Component.');
$input.focus();
return;
@ -2537,7 +2569,7 @@ function fixedDefaultValue(array $f): string
const errors = [];
// ✅ esegue una chiamata per ogni parte (compatibile con lattuale add_part_quick.php)
for (const p of uniqueParts) {
for (const p of parts) {
const formData = new FormData();
formData.append('iddatadb', iddatadb);
formData.append('part_description', p);
@ -3158,4 +3190,4 @@ function fixedDefaultValue(array $f): string
</body>
</html>
</html>