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:
+20
-10
@@ -9064,9 +9064,9 @@ function onPfUnitChange() {
|
||||
if (confRow) confRow.style.display = unit === 'conf' ? 'block' : 'none';
|
||||
}
|
||||
|
||||
function _updateBarcodeHint() {
|
||||
const hint = document.getElementById('pf-barcode-hint');
|
||||
const val = (document.getElementById('pf-barcode')?.value || '').trim();
|
||||
function _updateBarcodeHint(inputId = 'pf-barcode', hintId = 'pf-barcode-hint') {
|
||||
const hint = document.getElementById(hintId);
|
||||
const val = (document.getElementById(inputId)?.value || '').trim();
|
||||
if (hint) hint.style.display = val ? 'none' : 'block';
|
||||
}
|
||||
|
||||
@@ -9074,7 +9074,7 @@ function _updateBarcodeHint() {
|
||||
* Open a temporary camera modal to scan a barcode and fill the pf-barcode field.
|
||||
* Uses BarcodeDetector if available, otherwise shows manual-input fallback.
|
||||
*/
|
||||
async function scanBarcodeForForm() {
|
||||
async function scanBarcodeForForm(targetId = 'pf-barcode', hintId = 'pf-barcode-hint') {
|
||||
const overlayEl = document.getElementById('modal-overlay');
|
||||
const contentEl = document.getElementById('modal-content');
|
||||
|
||||
@@ -9107,15 +9107,15 @@ async function scanBarcodeForForm() {
|
||||
const raw=(this.value||'').replace(/\\D/g,''); this.value=raw;
|
||||
if((raw.length===13||raw.length===8)&&validateEANChecksum(raw)){
|
||||
stopStream();
|
||||
document.getElementById('pf-barcode').value=raw;
|
||||
_updateBarcodeHint();
|
||||
document.getElementById('${targetId}').value=raw;
|
||||
_updateBarcodeHint('${targetId}', '${hintId}');
|
||||
document.getElementById('modal-overlay').style.display='none';
|
||||
if(navigator.vibrate)navigator.vibrate(80);
|
||||
}
|
||||
">
|
||||
<button class="btn btn-primary" style="margin-top:8px;width:100%" onclick="
|
||||
const v = (document.getElementById('pf-bc-manual').value||'').replace(/\\D/g,'');
|
||||
if(v){ stopStream(); document.getElementById('pf-barcode').value=v; _updateBarcodeHint(); document.getElementById('modal-overlay').style.display='none'; }
|
||||
if(v){ stopStream(); document.getElementById('${targetId}').value=v; _updateBarcodeHint('${targetId}', '${hintId}'); document.getElementById('modal-overlay').style.display='none'; }
|
||||
">${t('scanner.barcode_use_btn')}</button>
|
||||
</div>
|
||||
`;
|
||||
@@ -9153,8 +9153,8 @@ async function scanBarcodeForForm() {
|
||||
stopStream();
|
||||
overlayEl.style.display = 'none';
|
||||
overlayEl.onclick = null;
|
||||
document.getElementById('pf-barcode').value = code;
|
||||
_updateBarcodeHint();
|
||||
document.getElementById(targetId).value = code;
|
||||
_updateBarcodeHint(targetId, hintId);
|
||||
if (navigator.vibrate) navigator.vibrate(80);
|
||||
showToast(t('scan.barcode_acquired', { code }), 'success');
|
||||
return;
|
||||
@@ -9335,6 +9335,14 @@ function showProductAction() {
|
||||
<label>${t('product.brand_label')}</label>
|
||||
<input type="text" id="edit-action-brand" class="form-input" value="${escapeHtml(currentProduct.brand || '')}" placeholder="Es: Barilla, Mulino Bianco...">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>${t('product.barcode_label')}</label>
|
||||
<div class="expiry-input-row">
|
||||
<input type="text" id="edit-action-barcode" class="form-input" value="${escapeHtml(currentProduct.barcode || '')}" placeholder="${escapeHtml(t('product.barcode_placeholder') || '')}" inputmode="numeric">
|
||||
<button type="button" class="btn btn-accent btn-scan-expiry" onclick="scanBarcodeForForm('edit-action-barcode', 'edit-action-barcode-hint')" title="${t('scanner.title_barcode')}">📷</button>
|
||||
</div>
|
||||
<p class="form-hint" id="edit-action-barcode-hint" style="display:none">${t('product.barcode_hint')}</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>${t('product.category_label')}</label>
|
||||
<select id="edit-action-category" class="form-input" onchange="onEditActionCategoryChange()">
|
||||
@@ -9926,11 +9934,12 @@ async function saveEditedProductInfo() {
|
||||
return;
|
||||
}
|
||||
const notes = (document.getElementById('edit-action-notes')?.value || '').trim();
|
||||
const barcode = (document.getElementById('edit-action-barcode')?.value || '').trim();
|
||||
showLoading(true);
|
||||
try {
|
||||
const result = await api('product_save', {}, 'POST', {
|
||||
id: currentProduct.id,
|
||||
barcode: currentProduct.barcode || null,
|
||||
barcode: barcode || null,
|
||||
name: name,
|
||||
brand: brand,
|
||||
category: effectiveCategory,
|
||||
@@ -9946,6 +9955,7 @@ async function saveEditedProductInfo() {
|
||||
currentProduct.name = name;
|
||||
currentProduct.brand = brand;
|
||||
currentProduct.notes = notes;
|
||||
currentProduct.barcode = barcode || null;
|
||||
if (category) currentProduct.category = category;
|
||||
currentProduct.subcategory = subcategory || null;
|
||||
showToast(t('toast.product_updated'), 'success');
|
||||
|
||||
Reference in New Issue
Block a user