From c6cc9c6658ed234d7c9dfec8238d7c5eb9971462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Kr=C4=8Dek?= Date: Wed, 6 Aug 2025 14:35:12 +0200 Subject: [PATCH] Fixed sheet local storage --- .github/copilot-instructions.md | 3 +- package-lock.json | 7 +- package.json | 2 +- src/lib/components/Wizard.svelte | 12 +- .../components/wizard/StepRowFilter.svelte | 848 ++++++------------ .../components/wizard/StepSheetSearch.svelte | 14 - .../wizard/subcomponents/Navigator.svelte | 2 - 7 files changed, 309 insertions(+), 579 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index e6b7d26..fa52359 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -14,4 +14,5 @@ - Remain consistent in styling and code structure. - Avoid unncessary iterations. If problems is mostly solved, stop. - Split big components into subcomponents. Always create smaller subcomponents for better context management later. -- Do not do what you're not being asked. Stick to scope of my request. \ No newline at end of file +- Do not do what you're not being asked. Stick to scope of my request. +- Do not edit stores.ts ! Unless is explicitly allow you to. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9086028..b54115c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,6 @@ "@types/gapi.client.drive-v3": "^0.0.5", "@types/gapi.client.sheets-v4": "^0.0.4", "@types/google.accounts": "^0.0.17", - "@types/uuid": "^10.0.0", "fontkit": "^2.0.4", "heic-convert": "^2.1.0", "idb": "^8.0.3", @@ -29,6 +28,7 @@ "@sveltejs/kit": "^2.22.0", "@sveltejs/vite-plugin-svelte": "^6.0.0", "@tailwindcss/vite": "^4.0.0", + "@types/uuid": "^10.0.0", "prettier": "^3.4.2", "prettier-plugin-svelte": "^3.3.3", "prettier-plugin-tailwindcss": "^0.6.11", @@ -631,6 +631,9 @@ }, "node_modules/@types/uuid": { "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ==", + "dev": true, "license": "MIT" }, "node_modules/@webgpu/types": { @@ -2019,6 +2022,8 @@ }, "node_modules/uuid": { "version": "11.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", + "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", "funding": [ "https://github.com/sponsors/broofa", "https://github.com/sponsors/ctavan" diff --git a/package.json b/package.json index 79932b1..55ea62f 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@sveltejs/kit": "^2.22.0", "@sveltejs/vite-plugin-svelte": "^6.0.0", "@tailwindcss/vite": "^4.0.0", + "@types/uuid": "^10.0.0", "prettier": "^3.4.2", "prettier-plugin-svelte": "^3.3.3", "prettier-plugin-tailwindcss": "^0.6.11", @@ -36,7 +37,6 @@ "@types/gapi.client.drive-v3": "^0.0.5", "@types/gapi.client.sheets-v4": "^0.0.4", "@types/google.accounts": "^0.0.17", - "@types/uuid": "^10.0.0", "fontkit": "^2.0.4", "heic-convert": "^2.1.0", "idb": "^8.0.3", diff --git a/src/lib/components/Wizard.svelte b/src/lib/components/Wizard.svelte index 3d941b8..663db09 100644 --- a/src/lib/components/Wizard.svelte +++ b/src/lib/components/Wizard.svelte @@ -5,17 +5,15 @@ import StepColumnMap from './wizard/StepColumnMap.svelte'; import StepRowFilter from './wizard/StepRowFilter.svelte'; import StepCardDetails from './wizard/StepCardDetails.svelte'; - import StepGallery from './wizard/StepGallery.svelte'; - import StepGenerate from './wizard/StepGenerate.svelte'; + // import StepGallery from './wizard/StepGallery.svelte'; + // import StepGenerate from './wizard/StepGenerate.svelte'; const steps = [ StepAuth, StepSheetSearch, StepColumnMap, StepRowFilter, - StepCardDetails, - StepGallery, - StepGenerate + StepCardDetails ]; const stepTitles = [ @@ -23,9 +21,7 @@ 'Select Sheet', 'Map Columns', 'Filter Rows', - 'Card Details', - 'Review Photos', - 'Generate PDFs' + 'Enter Card Details' ]; diff --git a/src/lib/components/wizard/StepRowFilter.svelte b/src/lib/components/wizard/StepRowFilter.svelte index 5ffcd8f..372bbc6 100644 --- a/src/lib/components/wizard/StepRowFilter.svelte +++ b/src/lib/components/wizard/StepRowFilter.svelte @@ -1,251 +1,118 @@ -
-
-

Filter and Select Rows

- -

- Review your data and select which rows you want to include in the card generation. Only rows - with all required fields will be available for selection. -

-
- - -
-
- -
- - -
- - -
- - -
+
+
+
+

Filter and Select Rows

+

+ Review your data and select which rows to include. Invalid or already printed rows are + disabled. +

+ {#if $selectedSheet?.id} +

+ Need to make changes? + + Open Google Sheet + +

+ {/if}
- - -
- Total rows: {processedData.length} - Valid rows: {processedData.filter((row) => row._isValid).length} - Printed: {processedData.filter((row) => isRowAlreadyPrinted(row)).length} - Filtered rows: {displayData.length} - Selected: {selectedValidCount} - -
- - - -
-
-
- - -
- {#if displayData.length === 0 && !isLoading} -
+ +
+ + {#if isLoading} +
+

Loading data from Google Sheet...

+

Please wait a moment.

+
+ {:else if error} +
+
+
+ + + +
+
+

An Error Occurred

+
+

{error}

+
+
- {:else} +
+ {:else if rows.length === 0} +
+

No Data Found

+

+ The selected sheet appears to be empty or could not be read. +

+
+ {:else} +
- - - - - {#each headers.filter((h) => h !== 'alreadyPrinted') as header} - - {/each} - - + + + + + + + - Status - - {#if isLoading} - - {#each Array(5) as _, index} - - - - - - {#each headers.filter((h) => h !== 'alreadyPrinted') as header} - - {/each} - - - - - {/each} - {:else} - - {#each displayData as row} - - - - - - {#each headers.filter((h) => h !== 'alreadyPrinted') as header} - - {/each} - - - - - {/each} - {/if} + {#each displayData as row (row.id)} + + + + + + + + + + + + {/each}
+ { - // Use event.preventDefault() to avoid default checkbox behavior - e.preventDefault(); - toggleSelectAll(); - }} class="h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" - disabled={isLoading} + onchange={toggleSelectAll} + checked={allValidRowsSelected} /> !isLoading && handleSort(header)} - > -
- {getFieldLabel(header)} - {#if sortColumn === header} - - {#if sortDirection === 'asc'} - - {:else} - - {/if} - - {/if} -
-
sortBy('_rowIndex')}># sortBy('name')}>Name sortBy('surname')}>Surname sortBy('nationality')}>Nationality sortBy('birthday')}>Birthday sortBy('pictureUrl')}>Picture URL sortBy('alreadyPrinted')}>Printed sortBy('_valid')}>Status
-
-
-
-
-
-
-
-
- {#if row._isValid} - { - // Use event.preventDefault() to avoid default checkbox behavior - e.preventDefault(); - toggleRowSelection(row._rowIndex); - }} - class="h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" - /> - {:else} -
- {/if} -
- {row[header] || ''} - -
- {#if row._isValid} - - Valid - - {:else} - - Missing data - - {/if} - - {#if isRowAlreadyPrinted(row)} - - Already Printed - - {/if} -
-
+ toggleRow(row.id)} + /> + {row._rowIndex}{row.name}{row.surname}{row.nationality}{row.birthday} + link + + {#if row.alreadyPrinted} + Yes + {:else} + No + {/if} + + {#if row._valid} + Valid + {:else} + Invalid + {/if} +
- {/if} -
- - - {#if selectedValidCount > 0} -
-
- - - - - {selectedValidCount} - {selectedValidCount === 1 ? 'row' : 'rows'} selected for card generation - -
{/if} - - +
+ 0} + currentStep={currentStep} + onForward={handleContinue} + textBack="Back to Column Mapping" + textForwardEnabled="Continue ({selectedCount} selected)" + textForwardDisabled="Select at least one valid row" + /> +
diff --git a/src/lib/components/wizard/StepSheetSearch.svelte b/src/lib/components/wizard/StepSheetSearch.svelte index 9592c54..eaa0f87 100644 --- a/src/lib/components/wizard/StepSheetSearch.svelte +++ b/src/lib/components/wizard/StepSheetSearch.svelte @@ -50,19 +50,6 @@ } } - function saveRecentSheet(sheet) { - // Remove duplicates - recentSheets = recentSheets.filter(s => s.id !== sheet.id); - recentSheets.unshift(sheet); - - // Limit to 5 recent sheets - if (recentSheets.length > 5) { - recentSheets.pop(); - } - - localStorage.setItem(RECENT_SHEETS_KEY, JSON.stringify(recentSheets)); - } - function handleSelectSheet(sheet) { const sheetData: SheetInfoType = { id: sheet.id, @@ -270,6 +257,5 @@ textBack="Back to Auth" textForwardDisabled="Select a sheet" textForwardEnabled="Continue" - onForward={() => saveRecentSheet($selectedSheet)} />
diff --git a/src/lib/components/wizard/subcomponents/Navigator.svelte b/src/lib/components/wizard/subcomponents/Navigator.svelte index 05fbf38..42cf5f8 100644 --- a/src/lib/components/wizard/subcomponents/Navigator.svelte +++ b/src/lib/components/wizard/subcomponents/Navigator.svelte @@ -1,6 +1,4 @@