Make expired/expiring items clickable for edit/delete

- Tap on any expired or expiring item opens the detail modal
- From the modal: edit quantity/location/expiry, delete, or use
- Same behavior as regular inventory items
- Added showAlertItemDetail() function (loads inventory then shows modal)
- Visual feedback on tap (scale + highlight)
This commit is contained in:
dadaloop82
2026-03-10 12:27:53 +00:00
parent cc9fd2cbed
commit c6c000bbc2
3 changed files with 21 additions and 3 deletions
+10 -2
View File
@@ -382,7 +382,7 @@ async function loadDashboard() {
else if (days <= 30) { badgeText = `${days}g`; badgeClass = 'expiring-soon'; }
else { const m = Math.round(days/30); badgeText = m <= 1 ? `${days}g` : `~${m} mesi`; badgeClass = 'expiring-later'; }
return `
<div class="alert-item">
<div class="alert-item alert-item-clickable" onclick="showAlertItemDetail(${item.id}, ${item.product_id})">
<div class="alert-item-info">
<span class="alert-item-name">${escapeHtml(item.name)}</span>
${item.brand ? `<span class="alert-item-brand">${escapeHtml(item.brand)}</span>` : ''}
@@ -407,7 +407,7 @@ async function loadDashboard() {
else daysText = `Da ${days}g`;
const safety = getExpiredSafety(item, days);
return `
<div class="alert-item expired-item">
<div class="alert-item expired-item alert-item-clickable" onclick="showAlertItemDetail(${item.id}, ${item.product_id})">
<div class="alert-item-info">
<span class="alert-item-name">${escapeHtml(item.name)}</span>
${item.brand ? `<span class="alert-item-brand">${escapeHtml(item.brand)}</span>` : ''}
@@ -513,6 +513,14 @@ function dashItemTap(inventoryId, productId) {
});
}
function showAlertItemDetail(inventoryId, productId) {
// Load full inventory so modal works (same pattern as dashItemTap)
api('inventory_list').then(data => {
currentInventory = data.inventory || [];
showItemDetail(inventoryId, productId);
});
}
function formatQuantity(qty, unit) {
if (!qty && qty !== 0) return '';
const n = parseFloat(qty);