From a243980c1bd3cc31d4ed69c4e2b998fac44cb952 Mon Sep 17 00:00:00 2001 From: Shawn Date: Mon, 25 May 2026 21:20:16 -0400 Subject: [PATCH] fix: inline edit now always looks up & shows asset info Three changes: 1. renderPrevCard: always render prevAsset/prevMachineInfo divs (not conditional on GPS coordinates) 2. loadPreviousPhotos: call lookupPrevAsset for ALL photos with machine_id, not just those with GPS coords 3. saveMachineIdInline: dynamically create asset info divs on the card if they don't exist yet (defensive fallback) Previously, manually entering a machine ID on a card without GPS would silently succeed but never show the asset name/location because the display elements only existed on GPS-equipped cards. --- static/index.html | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/static/index.html b/static/index.html index 3ae8265..938dc73 100644 --- a/static/index.html +++ b/static/index.html @@ -506,8 +506,10 @@ function loadPreviousPhotos() { div.innerHTML = data.photos.map(p => renderPrevCard(p)).join(''); // Init maps and asset lookups after rendering data.photos.forEach(p => { - if (p.gps_lat && p.gps_lng && p.machine_id) { + if (p.gps_lat && p.gps_lng) { initPrevMap(p); + } + if (p.machine_id) { lookupPrevAsset(p); } }); @@ -608,13 +610,11 @@ function renderPrevCard(p) { - ${hasCoords && p.machine_id ? `
-
-
-
-
` : hasCoords ? `
-
+ ${hasCoords ? `
+
` : ''} +
+
`; } @@ -675,9 +675,21 @@ function saveMachineIdInline(input, photoId, cancel) { badge.className = 'match-badge matched'; } } - // Update asset info - const assetEl = document.getElementById('prevAsset' + photoId); - const infoEl = document.getElementById('prevMachineInfo' + photoId); + // Update asset info — create elements if they don't exist yet + let assetEl = document.getElementById('prevAsset' + photoId); + let infoEl = document.getElementById('prevMachineInfo' + photoId); + if (!assetEl && card) { + assetEl = document.createElement('div'); + assetEl.id = 'prevAsset' + photoId; + assetEl.style.cssText = 'font-size:11px;margin-top:4px;color:var(--text2);'; + card.appendChild(assetEl); + } + if (!infoEl && card) { + infoEl = document.createElement('div'); + infoEl.id = 'prevMachineInfo' + photoId; + infoEl.style.cssText = 'margin-top:2px;'; + card.appendChild(infoEl); + } if (data.asset) { const a = data.asset; if (assetEl) {