diff --git a/assets/css/style.css b/assets/css/style.css index 2e5bc55..60e76f3 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -2732,6 +2732,27 @@ body { font-size: 0.95rem; } +.btn-edit-inline { + position: absolute; + top: 8px; + right: 8px; + background: rgba(255,255,255,0.9); + border: 1px solid #ddd; + border-radius: 50%; + width: 36px; + height: 36px; + font-size: 1rem; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + box-shadow: 0 1px 3px rgba(0,0,0,0.12); +} + +.product-preview-large { + position: relative; +} + /* ===== INVENTORY STATUS BAR ===== */ .inventory-status-bar { background: linear-gradient(135deg, #dbeafe 0%, #c7d2fe 100%); diff --git a/assets/js/app.js b/assets/js/app.js index f731886..2b4528c 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -2301,13 +2301,13 @@ function showProductAction() { ${currentProduct.weight_info ? `

⚖️ ${escapeHtml(currentProduct.weight_info)}

` : ''} ${currentProduct.barcode ? `

📊 ${currentProduct.barcode}

` : ''} + `; // Check if product needs editing (unknown name, missing info) const isUnknown = !currentProduct.name || /sconosciuto|unknown|^$/i.test(currentProduct.name.trim()) || currentProduct.name.trim().length < 2; - const needsEdit = isUnknown || !currentProduct.brand; // Edit product info section let editInfoEl = document.getElementById('action-edit-info'); @@ -2318,42 +2318,38 @@ function showProductAction() { preview.parentElement.insertBefore(editInfoEl, preview.nextSibling); } - if (needsEdit) { - const categoryOptions = Object.entries(CATEGORY_LABELS).map(([key, label]) => - `` - ).join(''); - - editInfoEl.innerHTML = ` -
-

${isUnknown ? '⚠️ Prodotto non riconosciuto' : '✏️ Completa le informazioni'}

-

${isUnknown ? 'Inserisci il nome e le informazioni del prodotto' : 'Puoi modificare o completare le info mancanti'}

-
-
- - -
-
- - -
-
- - -
- + // Always build the edit form, but only show it auto-opened for unknown products + const categoryOptions = Object.entries(CATEGORY_LABELS).map(([key, label]) => + `` + ).join(''); + + editInfoEl.innerHTML = ` +
+

${isUnknown ? '⚠️ Prodotto non riconosciuto' : '✏️ Modifica informazioni'}

+ ${isUnknown ? '

Inserisci il nome e le informazioni del prodotto

' : ''} +
+
+ +
+
+ + +
+
+ + +
+
- `; - editInfoEl.style.display = 'block'; - if (isUnknown) { - setTimeout(() => document.getElementById('edit-action-name')?.focus(), 100); - } - } else { - editInfoEl.style.display = 'none'; - editInfoEl.innerHTML = ''; +
+ `; + editInfoEl.style.display = isUnknown ? 'block' : 'none'; + if (isUnknown) { + setTimeout(() => document.getElementById('edit-action-name')?.focus(), 100); } // Show extra product info section below preview @@ -2634,6 +2630,15 @@ async function throwPartial() { } } +function toggleActionEdit() { + const el = document.getElementById('action-edit-info'); + if (!el) return; + el.style.display = el.style.display === 'none' ? 'block' : 'none'; + if (el.style.display === 'block') { + setTimeout(() => document.getElementById('edit-action-name')?.focus(), 100); + } +} + async function saveEditedProductInfo() { const name = (document.getElementById('edit-action-name')?.value || '').trim(); if (!name) { diff --git a/data/dispensa.db b/data/dispensa.db index 6d71cec..4461de6 100644 Binary files a/data/dispensa.db and b/data/dispensa.db differ diff --git a/index.html b/index.html index fab7b6d..c45489b 100644 --- a/index.html +++ b/index.html @@ -9,7 +9,7 @@ Dispensa Manager - + @@ -884,6 +884,6 @@
- +