Aggiungi bottone MODIFICA nella pagina azione prodotto esistente
This commit is contained in:
+21
-3
@@ -2763,7 +2763,7 @@ body {
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== THROW AWAY BUTTONS ===== */
|
/* ===== ACTION BUTTONS GRID ===== */
|
||||||
.action-buttons-3col {
|
.action-buttons-3col {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
@@ -2771,13 +2771,22 @@ body {
|
|||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-buttons-3col .btn-huge {
|
.action-buttons-4col {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 10px;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-buttons-3col .btn-huge,
|
||||||
|
.action-buttons-4col .btn-huge {
|
||||||
min-height: 100px;
|
min-height: 100px;
|
||||||
padding: 18px 8px;
|
padding: 18px 8px;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-buttons-3col .btn-icon {
|
.action-buttons-3col .btn-icon,
|
||||||
|
.action-buttons-4col .btn-icon {
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2790,6 +2799,15 @@ body {
|
|||||||
background: #ea580c;
|
background: #ea580c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-edit {
|
||||||
|
background: #6366f1;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-edit:active {
|
||||||
|
background: #4f46e5;
|
||||||
|
}
|
||||||
|
|
||||||
/* ===== STRUCTURED QUANTITY IN INVENTORY ===== */
|
/* ===== STRUCTURED QUANTITY IN INVENTORY ===== */
|
||||||
.inv-qty-col {
|
.inv-qty-col {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
+51
-1
@@ -2348,7 +2348,7 @@ function showProductAction() {
|
|||||||
<div class="inv-status-items">${invHtml}</div>
|
<div class="inv-status-items">${invHtml}</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
btnsContainer.className = 'action-buttons-3col';
|
btnsContainer.className = 'action-buttons-4col';
|
||||||
btnsContainer.innerHTML = `
|
btnsContainer.innerHTML = `
|
||||||
<button class="btn btn-huge btn-success" onclick="showAddForm()">
|
<button class="btn btn-huge btn-success" onclick="showAddForm()">
|
||||||
<span class="btn-icon">📥</span>
|
<span class="btn-icon">📥</span>
|
||||||
@@ -2362,6 +2362,10 @@ function showProductAction() {
|
|||||||
<span class="btn-icon">🗑️</span>
|
<span class="btn-icon">🗑️</span>
|
||||||
<span class="btn-text">BUTTA<br><small>butta il prodotto</small></span>
|
<span class="btn-text">BUTTA<br><small>butta il prodotto</small></span>
|
||||||
</button>
|
</button>
|
||||||
|
<button class="btn btn-huge btn-edit" onclick="editProductFromAction()">
|
||||||
|
<span class="btn-icon">✏️</span>
|
||||||
|
<span class="btn-text">MODIFICA<br><small>modifica info</small></span>
|
||||||
|
</button>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
// Product NOT in inventory - show only AGGIUNGI
|
// Product NOT in inventory - show only AGGIUNGI
|
||||||
@@ -2389,6 +2393,52 @@ async function checkInventoryForProduct(productId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === EDIT PRODUCT FROM ACTION PAGE ===
|
||||||
|
function editProductFromAction() {
|
||||||
|
if (!currentProduct) return;
|
||||||
|
// Pre-fill the product form with current product data
|
||||||
|
document.getElementById('pf-id').value = currentProduct.id || '';
|
||||||
|
document.getElementById('pf-name').value = currentProduct.name || '';
|
||||||
|
document.getElementById('pf-brand').value = currentProduct.brand || '';
|
||||||
|
document.getElementById('pf-barcode').value = currentProduct.barcode || '';
|
||||||
|
document.getElementById('pf-image').value = currentProduct.image_url || '';
|
||||||
|
document.getElementById('pf-notes').value = currentProduct.notes || '';
|
||||||
|
document.getElementById('pf-unit').value = currentProduct.unit || 'pz';
|
||||||
|
document.getElementById('pf-defqty').value = currentProduct.default_quantity || 1;
|
||||||
|
document.getElementById('product-form-title').textContent = 'Modifica Prodotto';
|
||||||
|
|
||||||
|
// Restore datalist for editing (was removed for new products)
|
||||||
|
document.getElementById('pf-name').setAttribute('list', 'common-products');
|
||||||
|
document.getElementById('pf-brand').setAttribute('list', 'common-brands');
|
||||||
|
|
||||||
|
// Set category
|
||||||
|
const cat = mapToLocalCategory(currentProduct.category, currentProduct.name);
|
||||||
|
document.getElementById('pf-category').value = cat;
|
||||||
|
document.getElementById('pf-category').dataset.manuallySet = 'true';
|
||||||
|
document.getElementById('pf-defqty').dataset.manuallySet = 'true';
|
||||||
|
|
||||||
|
// Image preview
|
||||||
|
const preview = document.getElementById('pf-image-preview');
|
||||||
|
if (currentProduct.image_url) {
|
||||||
|
preview.src = currentProduct.image_url;
|
||||||
|
preview.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
preview.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conf size row
|
||||||
|
const pfConfRow = document.getElementById('pf-conf-size-row');
|
||||||
|
if (currentProduct.unit === 'conf' && pfConfRow) {
|
||||||
|
pfConfRow.style.display = 'block';
|
||||||
|
document.getElementById('pf-conf-size').value = currentProduct.default_quantity || '';
|
||||||
|
document.getElementById('pf-conf-unit').value = currentProduct.package_unit || 'g';
|
||||||
|
} else if (pfConfRow) {
|
||||||
|
pfConfRow.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
showPage('product-form');
|
||||||
|
}
|
||||||
|
|
||||||
// === THROW AWAY FORM ===
|
// === THROW AWAY FORM ===
|
||||||
function showThrowForm() {
|
function showThrowForm() {
|
||||||
// Open a modal to ask how much to throw away
|
// Open a modal to ask how much to throw away
|
||||||
|
|||||||
+2
-2
@@ -9,7 +9,7 @@
|
|||||||
<title>Dispensa Manager</title>
|
<title>Dispensa Manager</title>
|
||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="manifest.json">
|
||||||
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🏠</text></svg>">
|
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🏠</text></svg>">
|
||||||
<link rel="stylesheet" href="assets/css/style.css?v=20260313c">
|
<link rel="stylesheet" href="assets/css/style.css?v=20260313d">
|
||||||
<!-- QuaggaJS for barcode scanning -->
|
<!-- QuaggaJS for barcode scanning -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/@ericblade/quagga2@1.8.4/dist/quagga.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/@ericblade/quagga2@1.8.4/dist/quagga.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
@@ -874,6 +874,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="assets/js/app.js?v=20260313c"></script>
|
<script src="assets/js/app.js?v=20260313d"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user