fixed filter import

This commit is contained in:
Claudio 2026-03-18 16:07:25 +01:00
parent f300811341
commit 9c850e4ea6
2 changed files with 33 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -374,16 +374,32 @@ error_log("Loaded template: " . print_r($template, true));
} }
selectAllCheckbox.addEventListener('change', function() { selectAllCheckbox.addEventListener('change', function() {
checkboxes.forEach(checkbox => { const visibleRows = Array.from(document.querySelectorAll('.table tbody tr'))
checkbox.checked = this.checked; .filter(row => row.style.display !== 'none');
visibleRows.forEach(row => {
const checkbox = row.querySelector('.row-checkbox');
if (checkbox) {
checkbox.checked = this.checked;
}
}); });
updateProceedButton(); updateProceedButton();
}); });
checkboxes.forEach(checkbox => { checkboxes.forEach(checkbox => {
checkbox.addEventListener('change', function() { checkbox.addEventListener('change', function() {
console.log('Checkbox changed, checked:', this.checked, 'excelrow:', this.dataset.excelrow); console.log('Checkbox changed, checked:', this.checked, 'excelrow:', this.dataset.excelrow);
selectAllCheckbox.checked = Array.from(checkboxes).every(cb => cb.checked);
const visibleCheckboxes = Array.from(document.querySelectorAll('.table tbody tr'))
.filter(row => row.style.display !== 'none')
.map(row => row.querySelector('.row-checkbox'))
.filter(cb => cb !== null);
selectAllCheckbox.checked =
visibleCheckboxes.length > 0 &&
visibleCheckboxes.every(cb => cb.checked);
updateProceedButton(); updateProceedButton();
}); });
}); });
@ -431,12 +447,11 @@ error_log("Loaded template: " . print_r($template, true));
function applyColumnFilters() { function applyColumnFilters() {
rows.forEach(row => { rows.forEach(row => {
// Le celle di data partono da index 1 (perché index 0 è checkbox)
let visible = true; let visible = true;
for (const [colIndexStr, filterValue] of Object.entries(activeFilters)) { for (const [colIndexStr, filterValue] of Object.entries(activeFilters)) {
const colIndex = parseInt(colIndexStr, 10); // 0..N-1 sulle colonne dati const colIndex = parseInt(colIndexStr, 10);
const cell = row.cells[colIndex + 1]; // +1 per saltare la colonna checkbox const cell = row.cells[colIndex + 1];
const cellText = (cell?.textContent || '').toLowerCase(); const cellText = (cell?.textContent || '').toLowerCase();
const searchText = (filterValue || '').toLowerCase().trim(); const searchText = (filterValue || '').toLowerCase().trim();
@ -449,6 +464,17 @@ error_log("Loaded template: " . print_r($template, true));
row.style.display = visible ? '' : 'none'; row.style.display = visible ? '' : 'none';
}); });
const visibleCheckboxes = Array.from(document.querySelectorAll('.table tbody tr'))
.filter(row => row.style.display !== 'none')
.map(row => row.querySelector('.row-checkbox'))
.filter(cb => cb !== null);
selectAllCheckbox.checked =
visibleCheckboxes.length > 0 &&
visibleCheckboxes.every(cb => cb.checked);
updateProceedButton();
} }
filterInputs.forEach(input => { filterInputs.forEach(input => {