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.
This commit is contained in:
+22
-10
@@ -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) {
|
||||
<button class="btn btn-xs" style="background:transparent;border:1px solid var(--red);color:var(--red);" onclick="deletePhoto(${p.id})">🗑️</button>
|
||||
<button class="btn btn-xs" style="background:transparent;border:1px solid var(--amber);color:var(--amber);" onclick="resetPhoto(${p.id})">🔄 Reset</button>
|
||||
</div>
|
||||
${hasCoords && p.machine_id ? `<div style="margin-top:6px;">
|
||||
<div id="prevMap${p.id}" class="mini-map" style="height:120px;border-radius:6px;background:var(--card2);"></div>
|
||||
<div id="prevAsset${p.id}" style="font-size:11px;margin-top:4px;color:var(--text2);"></div>
|
||||
<div id="prevMachineInfo${p.id}" style="margin-top:2px;"></div>
|
||||
</div>` : hasCoords ? `<div style="margin-top:6px;">
|
||||
<div id="prevMap${p.id}" class="mini-map" style="height:100px;border-radius:6px;background:var(--card2);"></div>
|
||||
${hasCoords ? `<div style="margin-top:6px;">
|
||||
<div id="prevMap${p.id}" class="mini-map" style="height:${p.machine_id ? 120 : 100}px;border-radius:6px;background:var(--card2);"></div>
|
||||
</div>` : ''}
|
||||
<div id="prevAsset${p.id}" class="prev-asset-info" style="font-size:11px;margin-top:4px;color:var(--text2);"></div>
|
||||
<div id="prevMachineInfo${p.id}" class="prev-asset-info" style="margin-top:2px;"></div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user