From ecf7ec53fd02e6c32a5af7e253e69b833a89d1dd Mon Sep 17 00:00:00 2001 From: morgane Date: Sat, 20 Jun 2026 08:59:36 +0000 Subject: [PATCH] Actualiser assets/js/app.js --- assets/js/app.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index f140cdc..a5c3821 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -2401,7 +2401,7 @@ function updateSubcategoryField(selectId, groupId, category, selectedValue = '') const list = SUBCATEGORIES_BY_CATEGORY[category]; select.innerHTML = getSubcategoryOptionsHtml(category, selectedValue); if (group) { - group.style.display = (list && list.length > 0) ? 'block' : 'none'; + group.style.display = 'block'; const mark = group.querySelector('.subcategory-required-mark'); if (mark) { mark.style.color = '#e74c3c'; @@ -7794,9 +7794,10 @@ window._editingProduct = { const itemCatForEdit = mapToLocalCategory(item.category, item.name, item.brand); const itemSubcatOptions = getSubcategoryOptionsHtml(itemCatForEdit, item.subcategory || ''); - const itemSubcatList = SUBCATEGORIES_BY_CATEGORY[itemCatForEdit]; - const itemSubcatVisible = (itemSubcatList && itemSubcatList.length > 0) ? 'block' : 'none'; + const itemSubcatVisible = 'block'; const itemSubcatRequired = REQUIRED_SUBCATEGORY_CATEGORIES.includes(itemCatForEdit); + let itemTagsSelected = []; + try { itemTagsSelected = JSON.parse(item.tags || '[]'); } catch (e) { itemTagsSelected = []; } // Rebuild modal content for editing (don't close and reopen - just replace content) document.getElementById('modal-content').innerHTML = ` @@ -7805,6 +7806,10 @@ window._editingProduct = {
+
+ + +
+
+ +
+ ${RECIPE_TAGS.map(tag => { + const selected = itemTagsSelected.includes(tag.key); + return ``; + }).join('')} +
+
@@ -7972,10 +7986,12 @@ async function submitEditInventory(e, id, productId) { const editedItem = currentInventory.find(i => i.id === id) || {}; const barcode = (document.getElementById('edit-inv-barcode')?.value || '').trim(); + const editedName = (document.getElementById('edit-inv-name')?.value || '').trim() || editedItem.name; + const selectedTags = Array.from(document.querySelectorAll('#edit-inv-tags-picker .inv-tag-chip.btn-primary')).map(b => b.dataset.tag); await api('product_save', {}, 'POST', { id: productId, barcode: barcode || null, - name: editedItem.name, + name: editedName, brand: editedItem.brand || '', category: category, subcategory: subcategory || null, @@ -7984,6 +8000,7 @@ async function submitEditInventory(e, id, productId) { default_quantity: editedItem.default_quantity || 1, package_unit: editedItem.package_unit || '', notes: editedItem.notes || '', + tags: selectedTags, }); await api('inventory_update', {}, 'POST', payload);