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:
+32
-2
@@ -1817,6 +1817,11 @@ const CATEGORY_LABELS = {
|
|||||||
'altro': `📦 ${t('categories.altro')}`
|
'altro': `📦 ${t('categories.altro')}`
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const SUBCATEGORY_LABELS = {
|
||||||
|
'vin': '🍷 Vin', 'biere': '🍺 Bière', 'spiritueux': '🥃 Spiritueux',
|
||||||
|
'soda': '🥤 Soda', 'jus': '🧃 Jus', 'eau': '💧 Eau', 'autre': '📦 Autre'
|
||||||
|
};
|
||||||
|
|
||||||
// Detect best unit/quantity from Open Food Facts quantity_info string
|
// Detect best unit/quantity from Open Food Facts quantity_info string
|
||||||
// Returns the actual package weight/volume as default (e.g. 700g → unit:'g', quantity:700)
|
// Returns the actual package weight/volume as default (e.g. 700g → unit:'g', quantity:700)
|
||||||
function detectUnitAndQuantity(quantityInfo) {
|
function detectUnitAndQuantity(quantityInfo) {
|
||||||
@@ -6671,6 +6676,9 @@ function renderInventoryItem(item) {
|
|||||||
const catIcon = CATEGORY_ICONS[catKey] || '📦';
|
const catIcon = CATEGORY_ICONS[catKey] || '📦';
|
||||||
const catLabel = t('categories.' + catKey) || catKey;
|
const catLabel = t('categories.' + catKey) || catKey;
|
||||||
const catBadge = `<span class="inv-badge badge-category" data-cat="${catKey}" data-itemname="${escapeHtml(item.name)}">${catIcon} ${catLabel}</span>`;
|
const catBadge = `<span class="inv-badge badge-category" data-cat="${catKey}" data-itemname="${escapeHtml(item.name)}">${catIcon} ${catLabel}</span>`;
|
||||||
|
const subBadge = (catKey === 'bevande' && item.subcategory && SUBCATEGORY_LABELS[item.subcategory])
|
||||||
|
? `<span class="inv-badge badge-subcategory">${SUBCATEGORY_LABELS[item.subcategory]}</span>`
|
||||||
|
: '';
|
||||||
const locInfo = LOCATIONS[item.location] || { icon: '📦', label: item.location };
|
const locInfo = LOCATIONS[item.location] || { icon: '📦', label: item.location };
|
||||||
const days = daysUntilExpiry(item.expiry_date);
|
const days = daysUntilExpiry(item.expiry_date);
|
||||||
const isExpired = days < 0;
|
const isExpired = days < 0;
|
||||||
@@ -6702,6 +6710,7 @@ function renderInventoryItem(item) {
|
|||||||
<div class="inv-meta">
|
<div class="inv-meta">
|
||||||
<span class="inv-badge badge-location">${locInfo.icon} ${locInfo.label}</span>
|
<span class="inv-badge badge-location">${locInfo.icon} ${locInfo.label}</span>
|
||||||
${catBadge}
|
${catBadge}
|
||||||
|
${subBadge}
|
||||||
${expiryBadge}
|
${expiryBadge}
|
||||||
${openedBadge}
|
${openedBadge}
|
||||||
${vacuumBadge}
|
${vacuumBadge}
|
||||||
@@ -6776,6 +6785,8 @@ function filterInventory() {
|
|||||||
if ((CATEGORY_LABELS[itemCat] || '').toLowerCase().includes(q)) return true;
|
if ((CATEGORY_LABELS[itemCat] || '').toLowerCase().includes(q)) return true;
|
||||||
// Match by inferred category: "biscotti" → queryCat="snack" → all snack items
|
// Match by inferred category: "biscotti" → queryCat="snack" → all snack items
|
||||||
if (queryCat !== 'altro' && itemCat === queryCat) return true;
|
if (queryCat !== 'altro' && itemCat === queryCat) return true;
|
||||||
|
if (i.subcategory && i.subcategory.toLowerCase().includes(q)) return true;
|
||||||
|
if (i.subcategory && (SUBCATEGORY_LABELS[i.subcategory] || '').toLowerCase().includes(q)) return true;
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
renderInventory(filtered);
|
renderInventory(filtered);
|
||||||
@@ -8495,6 +8506,12 @@ function autoDetectCategory() {
|
|||||||
|
|
||||||
function onCategoryChange(fromAutoDetect = false) {
|
function onCategoryChange(fromAutoDetect = false) {
|
||||||
const cat = document.getElementById('pf-category').value;
|
const cat = document.getElementById('pf-category').value;
|
||||||
|
const subGroup = document.getElementById('pf-subcategory-group');
|
||||||
|
if (subGroup) subGroup.style.display = (cat === 'bevande') ? 'block' : 'none';
|
||||||
|
if (cat !== 'bevande') {
|
||||||
|
const subSel = document.getElementById('pf-subcategory');
|
||||||
|
if (subSel) subSel.value = '';
|
||||||
|
}
|
||||||
const unitSelect = document.getElementById('pf-unit');
|
const unitSelect = document.getElementById('pf-unit');
|
||||||
const qtyInput = document.getElementById('pf-defqty');
|
const qtyInput = document.getElementById('pf-defqty');
|
||||||
|
|
||||||
@@ -8655,14 +8672,21 @@ async function scanBarcodeForForm() {
|
|||||||
|
|
||||||
async function submitProduct(e) {
|
async function submitProduct(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
const pfCategory = document.getElementById('pf-category').value;
|
||||||
|
const pfSubcategory = document.getElementById('pf-subcategory')?.value || '';
|
||||||
|
if (pfCategory === 'bevande' && !pfSubcategory) {
|
||||||
|
showToast('Merci de préciser le type de boisson', 'error');
|
||||||
|
document.getElementById('pf-subcategory').focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
showLoading(true);
|
showLoading(true);
|
||||||
|
|
||||||
const pfUnit = document.getElementById('pf-unit').value;
|
const pfUnit = document.getElementById('pf-unit').value;
|
||||||
const productData = {
|
const productData = {
|
||||||
id: document.getElementById('pf-id').value || null,
|
id: document.getElementById('pf-id').value || null,
|
||||||
name: document.getElementById('pf-name').value,
|
name: document.getElementById('pf-name').value,
|
||||||
brand: document.getElementById('pf-brand').value,
|
brand: document.getElementById('pf-brand').value,
|
||||||
category: document.getElementById('pf-category').value,
|
category: pfCategory,
|
||||||
|
subcategory: pfCategory === 'bevande' ? pfSubcategory : null,
|
||||||
unit: pfUnit,
|
unit: pfUnit,
|
||||||
default_quantity: pfUnit === 'conf' ? (parseFloat(document.getElementById('pf-conf-size')?.value) || 1) : (parseFloat(document.getElementById('pf-defqty').value) || 1),
|
default_quantity: pfUnit === 'conf' ? (parseFloat(document.getElementById('pf-conf-size')?.value) || 1) : (parseFloat(document.getElementById('pf-defqty').value) || 1),
|
||||||
package_unit: pfUnit === 'conf' ? (document.getElementById('pf-conf-unit')?.value || '') : '',
|
package_unit: pfUnit === 'conf' ? (document.getElementById('pf-conf-unit')?.value || '') : '',
|
||||||
@@ -9051,6 +9075,12 @@ function editProductFromAction() {
|
|||||||
}
|
}
|
||||||
document.getElementById('pf-category').disabled = false;
|
document.getElementById('pf-category').disabled = false;
|
||||||
|
|
||||||
|
// Set subcategory (boisson uniquement)
|
||||||
|
const editSubGroup = document.getElementById('pf-subcategory-group');
|
||||||
|
if (editSubGroup) editSubGroup.style.display = (cat === 'bevande') ? 'block' : 'none';
|
||||||
|
const editSubSel = document.getElementById('pf-subcategory');
|
||||||
|
if (editSubSel) editSubSel.value = (cat === 'bevande') ? (currentProduct.subcategory || '') : '';
|
||||||
|
|
||||||
document.getElementById('pf-defqty').dataset.manuallySet = 'true';
|
document.getElementById('pf-defqty').dataset.manuallySet = 'true';
|
||||||
|
|
||||||
// Image preview - not shown in edit mode
|
// Image preview - not shown in edit mode
|
||||||
|
|||||||
Reference in New Issue
Block a user