From 8b1da568205caea462eb6474fe0592c12c53ab21 Mon Sep 17 00:00:00 2001 From: Ben Miller Date: Wed, 31 Dec 2025 10:29:45 -0700 Subject: [PATCH] feat: implement manual media matching in Media Manager - Added selection logic to MediaState to track Drive-only and Shopify-only items - Refined UI to include a link button () in media card action overlays - Reordered action buttons to: Preview, Link, Delete - Replaced JS confirm with a visual side-by-side matching modal for linking - Added adaptive 'Link Selected' button to the gallery header - Fixed TypeError by restoring the quick-links element --- src/MediaManager.html | 135 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 126 insertions(+), 9 deletions(-) diff --git a/src/MediaManager.html b/src/MediaManager.html index d8122a3..9c35ba0 100644 --- a/src/MediaManager.html +++ b/src/MediaManager.html @@ -502,6 +502,26 @@ opacity: 0.7; filter: grayscale(0.5); } + + /* Selection Styles */ + .media-item.selected { + border: 3px solid var(--primary); + box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2); + } + + .icon-btn.active { + background-color: var(--primary); + color: white; + } + + .btn-link { + background-color: var(--primary); + color: white; + } + + .btn-link:hover { + background-color: var(--primary-hover); + } @@ -527,10 +547,14 @@
-
+

Gallery (0)

+
'; + } + var actionBtn = item._deleted ? '' : ''; - div.innerHTML = + div.innerHTML += badge + videoBadgeIcon + centerIcon + '
' + '' + + linkSelectionBtn + actionBtn + '
'; @@ -1385,6 +1475,29 @@ .getMediaManagerInitialState(sku, title); }, + linkSelectedMedia() { + var selectedItems = state.items.filter(function (i) { return state.selectedIds.has(i.id); }); + var driveItem = selectedItems.find(function (i) { return i.source === 'drive_only'; }); + var shopifyItem = selectedItems.find(function (i) { return i.source === 'shopify_only'; }); + + if (!driveItem || !shopifyItem) { + alert("Please select exactly one Drive item and one Shopify item."); + return; + } + + // Prepare a single match for the modal + this.matches = [{ + drive: driveItem, + shopify: shopifyItem + }]; + this.currentMatchIndex = 0; + + // Custom text for manual link + document.getElementById('match-modal-title').innerText = "Confirm Manual Link"; + document.getElementById('match-modal-text').innerText = "Are you sure you want to link these two items?"; + + this.startMatching(); + }, saveChanges() { ui.toggleSave(false); @@ -1730,6 +1843,10 @@ this.currentMatchIndex = 0; ui.logStatus('info', 'Found ' + newMatches.length + ' potential matches. Starting matching wizard...', 'info'); + // Default text for automatic matching + document.getElementById('match-modal-title').innerText = "Link Media?"; + document.getElementById('match-modal-text').innerText = "We found a matching file in Shopify. Should these be linked?"; + // Preload Images newMatches.forEach(function (m) { if (m.drive && m.drive.thumbnail) new Image().src = m.drive.thumbnail;