fix: MODIFICA button now edits inventory instance (expiry/location/qty/vacuum)
The MODIFICA button on the action page was opening the catalog editor
(name/brand/category). Users expect it to edit the physical item in hand.
Changes:
- MODIFICA button → openInventoryEdit(): edits the inventory row directly.
If product is in one location → opens editActionInventoryItem directly.
If multiple locations → shows a location picker modal first.
- editActionInventoryItem modal already has: qty ±, unit, conf size, location
buttons, expiry date, vacuum toggle — all fields for the instance.
- Catalog editing (name/brand/category) moved to a small secondary link
'⚙️ Modifica scheda prodotto' shown discreetly below the action buttons.
- Removed redundant 'Tocca una riga per modificare' hint from status bar.
- Added .btn-link-small CSS class for the secondary catalog-edit link.
This commit is contained in:
@@ -2712,6 +2712,18 @@ body {
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-link-small {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 0.8rem;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 4px 8px;
|
||||||
|
border-radius: 6px;
|
||||||
|
text-decoration: underline;
|
||||||
|
text-underline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
/* ===== PRODUCT DETAILS CARD (Action Page) ===== */
|
/* ===== PRODUCT DETAILS CARD (Action Page) ===== */
|
||||||
.product-details-card {
|
.product-details-card {
|
||||||
background: var(--bg-card);
|
background: var(--bg-card);
|
||||||
|
|||||||
+48
-3
@@ -2884,7 +2884,6 @@ function showProductAction() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="inv-status-items">${invHtml}</div>
|
<div class="inv-status-items">${invHtml}</div>
|
||||||
<p style="font-size:0.75rem;color:var(--text-muted);text-align:center;margin:4px 0 0">Tocca una riga per modificare</p>
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
btnsContainer.className = 'action-buttons-4col';
|
btnsContainer.className = 'action-buttons-4col';
|
||||||
@@ -2901,11 +2900,16 @@ function showProductAction() {
|
|||||||
<span class="btn-icon">🗑️</span>
|
<span class="btn-icon">🗑️</span>
|
||||||
<span class="btn-text">BUTTA<br><small>butta il prodotto</small></span>
|
<span class="btn-text">BUTTA<br><small>butta il prodotto</small></span>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-huge btn-edit" onclick="editProductFromAction()">
|
<button class="btn btn-huge btn-edit" onclick="openInventoryEdit()">
|
||||||
<span class="btn-icon">✏️</span>
|
<span class="btn-icon">✏️</span>
|
||||||
<span class="btn-text">MODIFICA<br><small>modifica info</small></span>
|
<span class="btn-text">MODIFICA<br><small>scadenza, luogo…</small></span>
|
||||||
</button>
|
</button>
|
||||||
`;
|
`;
|
||||||
|
// Secondary: catalog edit link below the buttons
|
||||||
|
const catalogLink = document.createElement('div');
|
||||||
|
catalogLink.style.cssText = 'text-align:center;margin-top:6px';
|
||||||
|
catalogLink.innerHTML = `<button type="button" class="btn-link-small" onclick="editProductFromAction()">⚙️ Modifica scheda prodotto (nome, marca, categoria…)</button>`;
|
||||||
|
btnsContainer.after(catalogLink);
|
||||||
} else {
|
} else {
|
||||||
// Product NOT in inventory - show only AGGIUNGI
|
// Product NOT in inventory - show only AGGIUNGI
|
||||||
statusBar.style.display = 'none';
|
statusBar.style.display = 'none';
|
||||||
@@ -3002,6 +3006,47 @@ function editProductFromAction() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === EDIT INVENTORY ITEM FROM ACTION PAGE ===
|
// === EDIT INVENTORY ITEM FROM ACTION PAGE ===
|
||||||
|
// === OPEN INVENTORY EDIT — picks item or shows location picker ===
|
||||||
|
function openInventoryEdit() {
|
||||||
|
const items = _actionInventoryItems;
|
||||||
|
if (!items || items.length === 0) {
|
||||||
|
showToast('Nessuna voce di inventario trovata', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (items.length === 1) {
|
||||||
|
editActionInventoryItem(items[0].id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Multiple locations → let user pick which one to edit
|
||||||
|
const contentEl = document.getElementById('modal-content');
|
||||||
|
contentEl.innerHTML = `
|
||||||
|
<div class="modal-header">
|
||||||
|
<h3>✏️ Quale modifica?</h3>
|
||||||
|
<button class="modal-close" onclick="closeModal()">✕</button>
|
||||||
|
</div>
|
||||||
|
<p style="font-size:0.9rem;color:var(--text-muted);margin:0 0 12px">Scegli la posizione da modificare:</p>
|
||||||
|
<div style="display:flex;flex-direction:column;gap:8px">
|
||||||
|
${items.map(inv => {
|
||||||
|
const locInfo = LOCATIONS[inv.location] || { icon: '📦', label: inv.location };
|
||||||
|
const qtyStr = formatQuantity(inv.quantity, inv.unit, inv.default_quantity, inv.package_unit);
|
||||||
|
let expiryStr = '';
|
||||||
|
if (inv.expiry_date) {
|
||||||
|
const d = daysUntilExpiry(inv.expiry_date);
|
||||||
|
expiryStr = ` · ${d < 0 ? '⚠️ Scaduto' : '📅 ' + formatDate(inv.expiry_date)}`;
|
||||||
|
}
|
||||||
|
const vacuumStr = inv.vacuum_sealed ? ' 🫙' : '';
|
||||||
|
return `<button class="btn btn-secondary full-width" style="justify-content:flex-start;gap:10px;text-align:left"
|
||||||
|
onclick="editActionInventoryItem(${inv.id})">
|
||||||
|
<span style="font-size:1.3rem">${locInfo.icon}</span>
|
||||||
|
<span><strong>${locInfo.label}</strong>${vacuumStr}<br>
|
||||||
|
<small style="color:var(--text-muted)">${qtyStr}${expiryStr}</small></span>
|
||||||
|
</button>`;
|
||||||
|
}).join('')}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
document.getElementById('modal-overlay').style.display = 'flex';
|
||||||
|
}
|
||||||
|
|
||||||
function editActionInventoryItem(inventoryId) {
|
function editActionInventoryItem(inventoryId) {
|
||||||
const item = _actionInventoryItems.find(i => i.id === inventoryId);
|
const item = _actionInventoryItems.find(i => i.id === inventoryId);
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|||||||
@@ -1803,3 +1803,10 @@
|
|||||||
[2026-04-07 12:05:02] OK — 31 items cached
|
[2026-04-07 12:05:02] OK — 31 items cached
|
||||||
[2026-04-07 12:10:01] OK — 30 items cached
|
[2026-04-07 12:10:01] OK — 30 items cached
|
||||||
[2026-04-07 12:15:02] OK — 30 items cached
|
[2026-04-07 12:15:02] OK — 30 items cached
|
||||||
|
[2026-04-07 12:20:02] OK — 32 items cached
|
||||||
|
[2026-04-07 12:25:02] OK — 33 items cached
|
||||||
|
[2026-04-07 12:30:02] OK — 33 items cached
|
||||||
|
[2026-04-07 12:35:01] OK — 33 items cached
|
||||||
|
[2026-04-07 12:40:02] OK — 33 items cached
|
||||||
|
[2026-04-07 12:45:01] OK — 33 items cached
|
||||||
|
[2026-04-07 12:50:02] OK — 33 items cached
|
||||||
|
|||||||
Binary file not shown.
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user