Actualiser assets/js/app.js
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
This commit is contained in:
+21
-4
@@ -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 = {
|
||||
<button class="modal-close" onclick="closeModal()">✕</button>
|
||||
</div>
|
||||
<form class="form" onsubmit="submitEditInventory(event, ${id}, ${item.product_id})">
|
||||
<div class="form-group">
|
||||
<label>${t('edit.label_name')}</label>
|
||||
<input type="text" id="edit-inv-name" class="form-input" value="${escapeHtml(item.name || '')}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>${t('product.category_label')}</label>
|
||||
<select id="edit-inv-category" class="form-input" onchange="onEditInvCategoryChange()">
|
||||
@@ -7817,6 +7822,15 @@ window._editingProduct = {
|
||||
${itemSubcatOptions}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>🏷 Tags</label>
|
||||
<div id="edit-inv-tags-picker" class="rl-tags-picker">
|
||||
${RECIPE_TAGS.map(tag => {
|
||||
const selected = itemTagsSelected.includes(tag.key);
|
||||
return `<button type="button" class="btn btn-small ${selected ? 'btn-primary' : 'btn-secondary'} inv-tag-chip" data-tag="${tag.key}" onclick="this.classList.toggle('btn-primary');this.classList.toggle('btn-secondary')">${tag.icon} ${escapeHtml(tag.label)}</button>`;
|
||||
}).join('')}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>${t('product.barcode_label')}</label>
|
||||
<div class="expiry-input-row">
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user