Added row limiting
This commit is contained in:
@@ -18,6 +18,8 @@
|
|||||||
let sortColumn = $state<keyof RowData | null>(null);
|
let sortColumn = $state<keyof RowData | null>(null);
|
||||||
let sortDirection = $state<'asc' | 'desc'>('asc');
|
let sortDirection = $state<'asc' | 'desc'>('asc');
|
||||||
|
|
||||||
|
const ROW_LIMIT = 200;
|
||||||
|
|
||||||
// Fetch and process data from the Google Sheet
|
// Fetch and process data from the Google Sheet
|
||||||
async function fetchAndProcessData() {
|
async function fetchAndProcessData() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
@@ -70,9 +72,9 @@
|
|||||||
birthday: mapping.birthday !== -1 ? row[mapping.birthday] || '' : '',
|
birthday: mapping.birthday !== -1 ? row[mapping.birthday] || '' : '',
|
||||||
pictureUrl,
|
pictureUrl,
|
||||||
alreadyPrinted,
|
alreadyPrinted,
|
||||||
_rowIndex: index + 2, // Sheet rows are 1-based, plus header
|
_rowIndex: index + 2,
|
||||||
_valid: isValid,
|
_valid: isValid,
|
||||||
_checked: isValid && !alreadyPrinted
|
_checked: false
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.filter((row): row is RowData => row !== null);
|
.filter((row): row is RowData => row !== null);
|
||||||
@@ -97,7 +99,6 @@
|
|||||||
if (row && row._valid) {
|
if (row && row._valid) {
|
||||||
row._checked = !row._checked;
|
row._checked = !row._checked;
|
||||||
}
|
}
|
||||||
console.log("toggleRow", id, row?._checked);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to toggle all valid rows
|
// Function to toggle all valid rows
|
||||||
@@ -107,7 +108,11 @@
|
|||||||
|
|
||||||
rows.forEach((row) => {
|
rows.forEach((row) => {
|
||||||
if (row._valid && !row.alreadyPrinted) {
|
if (row._valid && !row.alreadyPrinted) {
|
||||||
row._checked = shouldCheck;
|
if (shouldCheck && selectedCount < ROW_LIMIT) {
|
||||||
|
row._checked = true;
|
||||||
|
} else {
|
||||||
|
row._checked = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -162,8 +167,10 @@
|
|||||||
<div>
|
<div>
|
||||||
<h2 class="mb-2 text-xl font-semibold text-gray-900">Filter and Select Rows</h2>
|
<h2 class="mb-2 text-xl font-semibold text-gray-900">Filter and Select Rows</h2>
|
||||||
<p class="text-sm text-gray-700">
|
<p class="text-sm text-gray-700">
|
||||||
Review your data and select which rows to include. Invalid or already printed rows are
|
Review your data and select which rows to include. Select a batch of max 200 items by using the top checkbox.
|
||||||
disabled.
|
</p>
|
||||||
|
<p class="text-sm text-gray-700">
|
||||||
|
Already printed or invalid data is marked in the status column.
|
||||||
</p>
|
</p>
|
||||||
{#if $selectedSheet?.id}
|
{#if $selectedSheet?.id}
|
||||||
<p class="mt-1 text-sm text-gray-500">
|
<p class="mt-1 text-sm text-gray-500">
|
||||||
@@ -174,7 +181,7 @@
|
|||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
class="text-blue-600 underline hover:text-blue-800"
|
class="text-blue-600 underline hover:text-blue-800"
|
||||||
>
|
>
|
||||||
Open Google Sheet
|
Open the spreadsheet
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -307,7 +314,7 @@
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
class="h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-200"
|
class="h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-200"
|
||||||
checked={row._checked}
|
checked={row._checked}
|
||||||
disabled={!row._valid}
|
disabled={!row._valid || (selectedCount >= ROW_LIMIT && !row._checked)}
|
||||||
onchange={() => toggleRow(row.id)}
|
onchange={() => toggleRow(row.id)}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
let hasSearched = $state(false);
|
let hasSearched = $state(false);
|
||||||
let recentSheets = $state<any[]>([]);
|
let recentSheets = $state<any[]>([]);
|
||||||
|
|
||||||
const RECENT_SHEETS_KEY = 'recent-sheets';
|
const RECENT_SHEETS_KEY = 'recentSheets';
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
ensureToken();
|
ensureToken();
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
initGoogleClients(() => {
|
initGoogleClients(() => {
|
||||||
// You can add any logic here to run after the client is initialized
|
|
||||||
console.log('Google API client initialized');
|
console.log('Google API client initialized');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user