From 778c0d16205ba30aee7669bc7ff44cd1dc59d9d0 Mon Sep 17 00:00:00 2001 From: Ben Miller Date: Sat, 3 Jan 2026 11:44:49 -0700 Subject: [PATCH] Fix Media Manager UI bugs and add SKU migration logic - Fix syntax errors and logic in MediaManager.html - Fix SpreadsheetApp mocking in mediaHandlers.test.ts - Add SKU logic migration plan and backfill script - Update Product.ts and global.ts exports - Update newSku.ts and add newSku.test.ts - Ensure all tests pass (71/71) --- docs/SKU logic migration plan.md | 67 +++++++++ src/MediaManager.html | 231 +++++++++++++++++++++++++++++-- src/Product.ts | 7 +- src/backfill_sku.ts | 156 +++++++++++++++++++++ src/global.ts | 6 +- src/mediaHandlers.test.ts | 163 ++++++++++++++++++++-- src/mediaHandlers.ts | 102 +++++++++++++- src/newSku.test.ts | 134 ++++++++++++++++++ src/newSku.ts | 127 +++++++++++------ src/productTemplate.ts | 3 +- src/sheetUtils.ts | 3 + src/shopifyApi.ts | 10 +- 12 files changed, 926 insertions(+), 83 deletions(-) create mode 100644 docs/SKU logic migration plan.md create mode 100644 src/backfill_sku.ts create mode 100644 src/newSku.test.ts diff --git a/docs/SKU logic migration plan.md b/docs/SKU logic migration plan.md new file mode 100644 index 0000000..965f8b0 --- /dev/null +++ b/docs/SKU logic migration plan.md @@ -0,0 +1,67 @@ +# SKU logic migration plan + +2026-01-03 + +## Summary + +The goal of this migration is to reduce the number of touchpoints required to create a new SKU. User should only have to define `product_type` and `product_style` once, and then a new SKU should be created automatically when needed. + +## High Level Migration Steps + +1. FREEZE CHANGES to the spreadsheet while this migration is in progress +2. Remove `sku_prefix` column from `product_inventory` sheet. This will disable the existing automation by removing one of the needed inputs that is controlled by an instant ARRAYFORMULA. +3. Update column names in `product_inventory` and `values` sheets to match new SKU logic +4. Update `newSku.ts` to use new SKU logic +5. Update `MediaManager.ts` to use new SKU logic + +## Detailed Migration Steps + +## `product_inventory` sheet + +* [x] Remove `sku_prefix` column +* [x] Change `type` to `product_style` +* [x] Move `product_style` column to the right of `product_type` +* [x] Remove `function` column +* [x] Remove `#` column +* [x] Remove `style` column + * This column is not currently used in any active way, and is confusingly named. It should be removed. + +## `values` sheet + +* [x] Add `sku_prefix` column +* [x] `type_sku_code` -> `sku_suffix` column +* [x] Remove `function` and `function_sku_code` columns +* [x] `type` -> `product_style` + +## `product_types` sheet + +* [x] Remove `function` column +* [x] Change `type` to `product_style` + +## `Product` class + +* [x] Rename `type` -> `product_style` (to match the plan). +* [x] Remove `function` property. +* [x] Remove the existing `style: string[]` property (Line 24). + +## newSku.ts + +* [x] Move manual trigger to `sku` column +* [ ] Add safety check to ensure that existing `sku` values are not overwritten. If the product already has a `sku` in Shopify, use it. Only check if `sku` is empty and `shopify_id` is defined. +* [x] Start using `product_type` -> `sku_prefix` lookup + `product_style` -> `sku_suffix` lookup for SKU code + +## Media Manager + +* [ ] If `product_type` and `product_style` are defined, but `sku` is not, request a new SKU after confirming values are correct +* [ ] If either `product_type` or `product_style` are undefined, prompt the user to define them, then request a new SKU + +## Cleanup + +* Scrub code for columns that have been removed + * [x] `function` column + * [x] `function_sku_code` column + * [x] `type_sku_code` column + * [x] `#` column + * [x] `style` column +* [x] Scrub code for logic that has been removed +* [x] Backfill diff --git a/src/MediaManager.html b/src/MediaManager.html index 8e920a2..cc056b4 100644 --- a/src/MediaManager.html +++ b/src/MediaManager.html @@ -723,6 +723,78 @@ + + + + + +