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
+12 -3
View File
@@ -98,9 +98,9 @@ body {
background: rgba(255,255,255,0.25);
border: 2px solid rgba(255,255,255,0.5);
color: white;
font-size: 1.5rem;
width: 48px;
height: 48px;
font-size: 1.8rem;
width: 52px;
height: 52px;
border-radius: 50%;
cursor: pointer;
display: flex;
@@ -109,6 +109,8 @@ body {
transition: all 0.2s;
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
animation: pulse-scan 2s ease-in-out infinite;
line-height: 1;
padding-bottom: 2px;
}
.header-scan-btn:active {
@@ -2123,10 +2125,17 @@ body {
.log-entry.log-in {
border-left: 3px solid var(--success);
background: rgba(40, 167, 69, 0.06);
}
.log-entry.log-out {
border-left: 3px solid var(--danger);
background: rgba(220, 53, 69, 0.06);
}
.log-entry.log-bring {
border-left: 3px solid var(--primary);
background: rgba(52, 120, 246, 0.06);
}
.log-icon {
+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>`;
});