Main Access Updates
This commit is contained in:
@@ -259,8 +259,9 @@
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="nav-links">
|
||||
<a href="/">← Back to Home</a>
|
||||
<a href="{{ url_for('home') }}">← Back to Home</a>
|
||||
<a href="/quiz/">Product Finder</a>
|
||||
<a href="{{ url_for('products.product_list') }}">Product Manager</a>
|
||||
</div>
|
||||
|
||||
<h1>Product Manager</h1>
|
||||
@@ -756,7 +757,47 @@
|
||||
}
|
||||
|
||||
// Initialize on page load
|
||||
document.addEventListener('DOMContentLoaded', loadProductAttributes);
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
await loadProductAttributes();
|
||||
|
||||
// Check if a product code was passed via URL parameter
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const productCode = urlParams.get('product');
|
||||
if (productCode) {
|
||||
await loadProductByCode(productCode);
|
||||
}
|
||||
});
|
||||
|
||||
// Load a product by its code
|
||||
async function loadProductByCode(productCode) {
|
||||
try {
|
||||
const response = await fetch(`/quiz/api/products/${encodeURIComponent(productCode)}`);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.status === 'success' && data.product) {
|
||||
// Populate the form with the product data
|
||||
const product = data.product;
|
||||
|
||||
// Fill in basic fields
|
||||
document.getElementById('location').value = product.location || '';
|
||||
document.getElementById('description').value = product.description || '';
|
||||
document.getElementById('productCode').value = product.productCode || '';
|
||||
document.getElementById('category').value = product.category || '';
|
||||
|
||||
// Set discontinued status
|
||||
document.getElementById('discontinued').checked = product.discontinued || false;
|
||||
|
||||
// Note: You may need to add more field mappings based on your form structure
|
||||
// This is a basic implementation to get started
|
||||
|
||||
console.log('Loaded product:', product);
|
||||
} else {
|
||||
console.error('Product not found:', productCode);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading product:', error);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user