p-q and limitations to processing only 200 items
This commit is contained in:
@@ -107,25 +107,19 @@
|
||||
return processedRow;
|
||||
});
|
||||
|
||||
// Initially select rows based on validity and "Already Printed" status
|
||||
selectedRows = new Set(
|
||||
processedData
|
||||
.filter((row) => {
|
||||
if (!row._isValid) return false;
|
||||
// Initially select rows based on validity and "Already Printed" status, up to 200
|
||||
const rowsToConsider = processedData.filter((row) => {
|
||||
if (!row._isValid) return false;
|
||||
const alreadyPrinted = row.alreadyPrinted;
|
||||
if (alreadyPrinted) {
|
||||
const value = String(alreadyPrinted).toLowerCase().trim();
|
||||
return !(value === 'true' || value === 'yes' || value === '1' || value === 'x');
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
// Check "Already Printed" column value
|
||||
const alreadyPrinted = row.alreadyPrinted;
|
||||
if (alreadyPrinted) {
|
||||
const value = String(alreadyPrinted).toLowerCase().trim();
|
||||
// If the value is "true", "yes", "1", or any truthy value, don't select
|
||||
return !(value === 'true' || value === 'yes' || value === '1' || value === 'x');
|
||||
}
|
||||
|
||||
// If empty or falsy, select the row
|
||||
return true;
|
||||
})
|
||||
.map((row) => row._rowIndex)
|
||||
);
|
||||
const initialSelection = rowsToConsider.slice(0, 200).map((row) => row._rowIndex);
|
||||
selectedRows = new Set(initialSelection);
|
||||
|
||||
updateSelectAllState();
|
||||
} finally {
|
||||
@@ -137,6 +131,10 @@
|
||||
if (selectedRows.has(rowIndex)) {
|
||||
selectedRows.delete(rowIndex);
|
||||
} else {
|
||||
if (selectedRows.size >= 200) {
|
||||
alert('You can only select a maximum of 200 rows at a time.');
|
||||
return;
|
||||
}
|
||||
selectedRows.add(rowIndex);
|
||||
}
|
||||
selectedRows = new Set(selectedRows); // Trigger reactivity
|
||||
@@ -145,19 +143,28 @@
|
||||
|
||||
function toggleSelectAll() {
|
||||
if (selectAll) {
|
||||
// Deselect all visible valid rows that aren't already printed
|
||||
// Deselect all visible valid rows
|
||||
filteredData.forEach((row) => {
|
||||
if (row._isValid && !isRowAlreadyPrinted(row)) {
|
||||
if (row._isValid) {
|
||||
selectedRows.delete(row._rowIndex);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Select all visible valid rows that aren't already printed
|
||||
filteredData.forEach((row) => {
|
||||
if (row._isValid && !isRowAlreadyPrinted(row)) {
|
||||
selectedRows.add(row._rowIndex);
|
||||
}
|
||||
});
|
||||
// Select all visible valid rows that aren't already printed, up to the limit
|
||||
const rowsToSelect = filteredData.filter(
|
||||
(row) => row._isValid && !isRowAlreadyPrinted(row) && !selectedRows.has(row._rowIndex)
|
||||
);
|
||||
|
||||
const availableSlots = 200 - selectedRows.size;
|
||||
if (rowsToSelect.length > availableSlots) {
|
||||
alert(
|
||||
`You can only select up to 200 rows. Only the first ${availableSlots} available rows will be selected.`
|
||||
);
|
||||
}
|
||||
|
||||
for (let i = 0; i < Math.min(rowsToSelect.length, availableSlots); i++) {
|
||||
selectedRows.add(rowsToSelect[i]._rowIndex);
|
||||
}
|
||||
}
|
||||
selectedRows = new Set(selectedRows);
|
||||
updateSelectAllState();
|
||||
|
||||
Reference in New Issue
Block a user