From 346f69426f9c64ac9e9226f805f4633caa33d358 Mon Sep 17 00:00:00 2001 From: dadaloop82 Date: Thu, 9 Apr 2026 05:08:47 +0000 Subject: [PATCH] Fix: 'Modifica scheda prodotto' duplicato MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ogni chiamata a showProductAction() creava un nuovo div e lo appendeva con .after() senza rimuovere il precedente -> link moltiplicato. Fix: il div ha id='catalog-edit-link', viene riutilizzato se esiste; se il prodotto non è in inventario il link viene rimosso. --- assets/js/app.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 170878d..11050cc 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -2987,11 +2987,15 @@ function showProductAction() { MODIFICA
scadenza, luogo…
`; - // Secondary: catalog edit link below the buttons - const catalogLink = document.createElement('div'); - catalogLink.style.cssText = 'text-align:center;margin-top:6px'; + // Secondary: catalog edit link below the buttons (one instance only) + let catalogLink = document.getElementById('catalog-edit-link'); + if (!catalogLink) { + catalogLink = document.createElement('div'); + catalogLink.id = 'catalog-edit-link'; + catalogLink.style.cssText = 'text-align:center;margin-top:6px'; + btnsContainer.after(catalogLink); + } catalogLink.innerHTML = ``; - btnsContainer.after(catalogLink); } else { // Product NOT in inventory - show only AGGIUNGI statusBar.style.display = 'none'; @@ -3002,6 +3006,9 @@ function showProductAction() { AGGIUNGI
in dispensa/frigo
`; + // Remove catalog-edit link if left over from a previous product + const orphan = document.getElementById('catalog-edit-link'); + if (orphan) orphan.remove(); } });