Spaces:
Sleeping
Sleeping
Update templates/menu.html
Browse files- templates/menu.html +115 -101
templates/menu.html
CHANGED
@@ -470,119 +470,133 @@ form.text-center.mb-4 {
|
|
470 |
</a>
|
471 |
</div>
|
472 |
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
</div>
|
481 |
-
<div class="
|
482 |
-
|
483 |
-
<
|
484 |
-
<!-- Item Name -->
|
485 |
-
<h5 id="modal-name" class="fw-bold text-center"></h5>
|
486 |
-
<!-- Item Price -->
|
487 |
-
<p id="modal-price" class="text-muted text-center"></p>
|
488 |
-
<!-- Item Description -->
|
489 |
-
<p id="modal-description" class="text-secondary"></p>
|
490 |
-
<!-- Add-ons -->
|
491 |
-
<div id="modal-addons" class="modal-addons mt-4">
|
492 |
-
<h6>Customization Options</h6>
|
493 |
-
<div id="addons-list" class="addons-container">Loading customization options...</div>
|
494 |
-
</div>
|
495 |
-
|
496 |
-
|
497 |
-
<div class="mt-4">
|
498 |
-
<h6>Custom Request</h6>
|
499 |
-
<textarea id="modal-instructions" class="form-control" placeholder="Enter any special instructions here..."></textarea>
|
500 |
-
</div>
|
501 |
-
<span id="modal-section" data-section="" data-category="" style="display: none;"></span>
|
502 |
-
|
503 |
</div>
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
<!-- Add to Cart Button -->
|
514 |
-
<button type="button" class="btn btn-primary" onclick="addToCartFromModal()">Add to Cart</button>
|
515 |
-
</div>
|
516 |
-
|
517 |
-
|
518 |
</div>
|
|
|
|
|
519 |
</div>
|
520 |
</div>
|
521 |
</div>
|
|
|
522 |
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
// Set the default quantity to 1
|
539 |
-
document.getElementById('quantityInput').value = 1;
|
540 |
-
|
541 |
-
// Fetch customization options based on the section
|
542 |
-
fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
|
543 |
-
.then(response => response.json())
|
544 |
-
.then(data => {
|
545 |
-
const addonsList = document.getElementById('addons-list');
|
546 |
-
addonsList.innerHTML = ''; // Clear previous content
|
547 |
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
578 |
});
|
579 |
-
|
580 |
-
|
581 |
-
console.error('Error fetching add-ons:', err);
|
582 |
-
document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
|
583 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
584 |
}
|
|
|
585 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
586 |
function filterMenu() {
|
587 |
let input = document.getElementById('searchBar').value.toLowerCase(); // Get the value from search bar
|
588 |
let sections = document.querySelectorAll('h3'); // Select section headers
|
|
|
470 |
</a>
|
471 |
</div>
|
472 |
|
473 |
+
<!-- Modal for Item Details -->
|
474 |
+
<div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
|
475 |
+
<div class="modal-dialog modal-dialog-centered">
|
476 |
+
<div class="modal-content">
|
477 |
+
<div class="modal-header">
|
478 |
+
<h5 class="modal-title" id="itemModalLabel">Item Details</h5>
|
479 |
+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
480 |
+
</div>
|
481 |
+
<div class="modal-body">
|
482 |
+
<!-- Item Image -->
|
483 |
+
<img id="modal-img" class="img-fluid rounded mb-3 d-block mx-auto" alt="Item Image" style="max-height: 200px; object-fit: cover;">
|
484 |
+
<!-- Item Name -->
|
485 |
+
<h5 id="modal-name" class="fw-bold text-center"></h5>
|
486 |
+
<!-- Item Price -->
|
487 |
+
<p id="modal-price" class="text-muted text-center"></p>
|
488 |
+
<!-- Item Description -->
|
489 |
+
<p id="modal-description" class="text-secondary"></p>
|
490 |
+
<!-- Add-ons -->
|
491 |
+
<div id="modal-addons" class="modal-addons mt-4">
|
492 |
+
<h6>Customization Options</h6>
|
493 |
+
<div id="addons-list" class="addons-container">Loading customization options...</div>
|
494 |
</div>
|
495 |
+
<div class="mt-4">
|
496 |
+
<h6>Custom Request</h6>
|
497 |
+
<textarea id="modal-instructions" class="form-control" placeholder="Enter any special instructions here..."></textarea>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
498 |
</div>
|
499 |
+
<span id="modal-section" data-section="" data-category="" style="display: none;"></span>
|
500 |
+
</div>
|
501 |
+
<!-- Quantity Controls and Add to Cart Button -->
|
502 |
+
<div class="modal-footer d-flex align-items-center justify-content-between">
|
503 |
+
<!-- Quantity Controls -->
|
504 |
+
<div class="d-flex align-items-center gap-2">
|
505 |
+
<button type="button" class="btn btn-outline-secondary" id="decreaseQuantity">-</button>
|
506 |
+
<input type="text" class="form-control text-center" id="quantityInput" value="1" readonly style="width: 50px;"/>
|
507 |
+
<button type="button" class="btn btn-outline-secondary" id="increaseQuantity">+</button>
|
|
|
|
|
|
|
|
|
|
|
508 |
</div>
|
509 |
+
<!-- Add to Cart Button -->
|
510 |
+
<button type="button" class="btn btn-primary" onclick="addToCartFromModal()">Add to Cart</button>
|
511 |
</div>
|
512 |
</div>
|
513 |
</div>
|
514 |
+
</div>
|
515 |
|
516 |
+
<!-- JavaScript -->
|
517 |
+
<script>
|
518 |
+
// Show item details and fetch customization options
|
519 |
+
function showItemDetails(name, price, image, description, section, selectedCategory) {
|
520 |
+
document.getElementById('modal-name').innerText = name;
|
521 |
+
document.getElementById('modal-price').innerText = `$${price}`;
|
522 |
+
document.getElementById('modal-img').src = image || '/static/placeholder.jpg';
|
523 |
+
document.getElementById('modal-description').innerText = description || 'No description available.';
|
524 |
+
document.getElementById('addons-list').innerHTML = 'Loading customization options...';
|
525 |
+
document.getElementById('modal-instructions').value = '';
|
526 |
+
|
527 |
+
const modalSectionEl = document.getElementById('modal-section');
|
528 |
+
modalSectionEl.setAttribute('data-section', section);
|
529 |
+
modalSectionEl.setAttribute('data-category', selectedCategory);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
530 |
|
531 |
+
// Fetch customization options based on the section
|
532 |
+
fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
|
533 |
+
.then(response => response.json())
|
534 |
+
.then(data => {
|
535 |
+
const addonsList = document.getElementById('addons-list');
|
536 |
+
addonsList.innerHTML = ''; // Clear previous content
|
537 |
+
|
538 |
+
if (!data.success || !data.addons || data.addons.length === 0) {
|
539 |
+
addonsList.innerHTML = '<p>No customization options available.</p>';
|
540 |
+
return;
|
541 |
+
}
|
542 |
+
|
543 |
+
// Display customization options inside styled divs
|
544 |
+
data.addons.forEach(addon => {
|
545 |
+
const sectionDiv = document.createElement('div');
|
546 |
+
sectionDiv.classList.add('addon-section'); // Add styling class
|
547 |
+
|
548 |
+
// Add section title
|
549 |
+
const title = document.createElement('h6');
|
550 |
+
title.innerText = addon.name;
|
551 |
+
sectionDiv.appendChild(title);
|
552 |
+
|
553 |
+
// Create options list
|
554 |
+
const optionsContainer = document.createElement('div');
|
555 |
+
addon.options.forEach((option, index) => {
|
556 |
+
const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
|
557 |
+
const listItem = document.createElement('div');
|
558 |
+
listItem.classList.add('form-check');
|
559 |
+
listItem.innerHTML = `
|
560 |
+
<input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
|
561 |
+
data-name="${option}" data-group="${addon.name}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
|
562 |
+
<label class="form-check-label" for="${optionId}">
|
563 |
+
${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
|
564 |
+
</label>
|
565 |
+
`;
|
566 |
+
optionsContainer.appendChild(listItem);
|
567 |
});
|
568 |
+
sectionDiv.appendChild(optionsContainer);
|
569 |
+
addonsList.appendChild(sectionDiv);
|
|
|
|
|
570 |
});
|
571 |
+
})
|
572 |
+
.catch(err => {
|
573 |
+
console.error('Error fetching add-ons:', err);
|
574 |
+
document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
|
575 |
+
});
|
576 |
+
}
|
577 |
+
|
578 |
+
// Handle single-select/deselect logic for checkbox groups in all modals
|
579 |
+
document.addEventListener('click', function(event) {
|
580 |
+
if (event.target.classList.contains('addon-option')) {
|
581 |
+
handleAddonClick(event.target);
|
582 |
}
|
583 |
+
});
|
584 |
|
585 |
+
// Handle checkbox selection logic
|
586 |
+
function handleAddonClick(checkbox) {
|
587 |
+
const groupName = checkbox.getAttribute('data-group');
|
588 |
+
const isMultiSelectGroup = ["Extra Toppings", "Choose Raita/Sides","Select Dip/Sauce","Extra Add-ons","Make it a Combo"].includes(groupName);
|
589 |
+
|
590 |
+
// If it's not multi-select, uncheck all other checkboxes in the same group
|
591 |
+
if (!isMultiSelectGroup) {
|
592 |
+
const checkboxes = document.querySelectorAll(`.addon-option[data-group="${groupName}"]`);
|
593 |
+
checkboxes.forEach(otherCheckbox => {
|
594 |
+
if (otherCheckbox !== checkbox) {
|
595 |
+
otherCheckbox.checked = false;
|
596 |
+
}
|
597 |
+
});
|
598 |
+
}
|
599 |
+
}
|
600 |
function filterMenu() {
|
601 |
let input = document.getElementById('searchBar').value.toLowerCase(); // Get the value from search bar
|
602 |
let sections = document.querySelectorAll('h3'); // Select section headers
|