fix: 4 miglioramenti - scan→usa, icona camera, log colori, log Bring!

1. Bug scan→usa: ora auto-seleziona la posizione corretta (frigo/dispensa/freezer)
   dove il prodotto è effettivamente presente, non più sempre 'dispensa'
2. Icona telecamera header: più grande (1.8rem/52px) e più centrata nel cerchio
3. Log: icone/colori differenziati -  verde aggiunte,  rosso uscite,
   🛒 blu Bring! - sfondo tintato per ogni tipo
4. Operazioni Bring! loggate come transazioni tipo 'bring' nel diario
This commit is contained in:
dadaloop82
2026-03-10 18:25:32 +00:00
parent 2abcec6fe5
commit 78e0fddf04
3 changed files with 45 additions and 9 deletions
+27 -6
View File
@@ -1821,6 +1821,16 @@ async function loadUseInventoryInfo() {
const loc = LOCATIONS[i.location] || { icon: '📦', label: i.location };
return `${loc.icon} ${loc.label}: ${i.quantity} ${i.unit}`;
}).join(' · ');
// Auto-select the first available location
const firstLoc = items[0].location;
document.getElementById('use-location').value = firstLoc;
document.querySelectorAll('#page-use .loc-btn').forEach(b => {
b.classList.remove('active');
if (b.getAttribute('onclick') && b.getAttribute('onclick').includes("'" + firstLoc + "'")) {
b.classList.add('active');
}
});
} else {
infoEl.innerHTML = '⚠️ Prodotto non presente nell\'inventario.';
}
@@ -2656,20 +2666,31 @@ async function loadLog(more = false) {
lastDate = dateStr;
}
const isIn = t.type === 'in';
const icon = isIn ? '📥' : '📤';
const typeLabel = isIn ? 'Aggiunto' : 'Usato';
const colorClass = isIn ? 'log-in' : 'log-out';
let icon, typeLabel, colorClass;
if (t.type === 'bring') {
icon = '🛒';
typeLabel = 'Aggiunto a Bring!';
colorClass = 'log-bring';
} else if (t.type === 'in') {
icon = '';
typeLabel = 'Aggiunto';
colorClass = 'log-in';
} else {
icon = '';
typeLabel = 'Usato';
colorClass = 'log-out';
}
const brand = t.brand ? ` <em>(${t.brand})</em>` : '';
const loc = t.location || '';
const locLabels = { 'frigo': '🧊 Frigo', 'freezer': '❄️ Freezer', 'dispensa': '🗄️ Dispensa' };
const locStr = locLabels[loc] || ('📍 ' + loc);
const locStr = t.type === 'bring' ? '' : (locLabels[loc] || ('📍 ' + loc));
const notes = t.notes ? ` · ${t.notes}` : '';
html += `<div class="log-entry ${colorClass}">`;
html += `<span class="log-icon">${icon}</span>`;
html += `<div class="log-info">`;
html += `<div class="log-product"><strong>${t.name}</strong>${brand}</div>`;
html += `<div class="log-detail">${typeLabel} ${t.quantity} ${t.unit || ''} · ${locStr} · ${timeStr}</div>`;
html += `<div class="log-detail">${typeLabel} ${t.type !== 'bring' ? t.quantity + ' ' + (t.unit || '') + ' · ' : ''}${locStr}${notes} · ${timeStr}</div>`;
html += `</div>`;
html += `</div>`;
});