DSatishchandra commited on
Commit
b6e6f1f
·
verified ·
1 Parent(s): 938035c

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +119 -102
templates/menu.html CHANGED
@@ -470,120 +470,137 @@ form.text-center.mb-4 {
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
-
501
  </div>
502
- <!-- Quantity Controls and Add to Cart Button -->
503
- <div class="modal-footer d-flex align-items-center justify-content-between">
504
- <!-- Quantity Controls -->
505
- <div class="d-flex align-items-center gap-2">
506
- <button type="button" class="btn btn-outline-secondary" id="decreaseQuantity">-</button>
507
- <input type="text" class="form-control text-center" id="quantityInput" value="1" readonly style="width: 50px;"/>
508
- <button type="button" class="btn btn-outline-secondary" id="increaseQuantity">+</button>
509
- </div>
510
-
511
- <!-- Add to Cart Button -->
512
- <button type="button" class="btn btn-primary" onclick="addToCartFromModal()">Add to Cart</button>
513
- </div>
514
-
515
-
516
  </div>
 
 
517
  </div>
518
  </div>
519
  </div>
 
520
 
521
- <!-- JavaScript -->
522
- <script>
523
- function showItemDetails(name, price, image, description, section, selectedCategory) {
524
- document.getElementById('modal-name').innerText = name;
525
- document.getElementById('modal-price').innerText = `$${price}`;
526
- document.getElementById('modal-img').src = image || '/static/placeholder.jpg';
527
- document.getElementById('modal-description').innerText = description || 'No description available.';
528
- document.getElementById('addons-list').innerHTML = 'Loading customization options...';
529
- document.getElementById('modal-instructions').value = '';
530
-
531
- // Set section and category for reference
532
- const modalSectionEl = document.getElementById('modal-section');
533
- modalSectionEl.setAttribute('data-section', section);
534
- modalSectionEl.setAttribute('data-category', selectedCategory);
535
-
536
- // Set the default quantity to 1
537
- document.getElementById('quantityInput').value = 1;
538
-
539
- // Fetch customization options based on the section
540
- fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
541
- .then(response => response.json())
542
- .then(data => {
543
- const addonsList = document.getElementById('addons-list');
544
- addonsList.innerHTML = ''; // Clear previous content
545
 
546
- if (!data.success || !data.addons || data.addons.length === 0) {
547
- addonsList.innerHTML = '<p>No customization options available.</p>';
548
- return;
549
- }
550
- // Display customization options inside styled divs
551
- data.addons.forEach(addon => {
552
- const sectionDiv = document.createElement('div');
553
- sectionDiv.classList.add('addon-section'); // Add styling class
554
-
555
- // Add section title
556
- const title = document.createElement('h6');
557
- title.innerText = addon.name;
558
- sectionDiv.appendChild(title);
559
-
560
- // Create options list
561
- const optionsContainer = document.createElement('div');
562
- addon.options.forEach((option, index) => {
563
- const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
564
- const listItem = document.createElement('div');
565
- listItem.classList.add('form-check');
566
- listItem.innerHTML = `
567
- <input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
568
- data-name="${option}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
569
- <label class="form-check-label" for="${optionId}">
570
- ${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
571
- </label>
572
- `;
573
- optionsContainer.appendChild(listItem);
574
- });
575
- sectionDiv.appendChild(optionsContainer);
576
- addonsList.appendChild(sectionDiv);
 
 
 
 
 
577
  });
578
- })
579
- .catch(err => {
580
- console.error('Error fetching add-ons:', err);
581
- document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
582
  });
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
589
  let items = document.querySelectorAll('.menu-card'); // Select all items
 
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
+ // Set the default quantity to 1
532
+ document.getElementById('quantityInput').value = 1;
 
 
 
 
 
 
 
533
 
534
+ // Fetch customization options based on the section
535
+ fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
536
+ .then(response => response.json())
537
+ .then(data => {
538
+ const addonsList = document.getElementById('addons-list');
539
+ addonsList.innerHTML = ''; // Clear previous content
540
+
541
+ if (!data.success || !data.addons || data.addons.length === 0) {
542
+ addonsList.innerHTML = '<p>No customization options available.</p>';
543
+ return;
544
+ }
545
+
546
+ // Display customization options inside styled divs
547
+ data.addons.forEach(addon => {
548
+ const sectionDiv = document.createElement('div');
549
+ sectionDiv.classList.add('addon-section'); // Add styling class
550
+
551
+ // Add section title
552
+ const title = document.createElement('h6');
553
+ title.innerText = addon.name;
554
+ sectionDiv.appendChild(title);
555
+
556
+ // Create options list
557
+ const optionsContainer = document.createElement('div');
558
+ addon.options.forEach((option, index) => {
559
+ const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
560
+ const listItem = document.createElement('div');
561
+ listItem.classList.add('form-check');
562
+ listItem.innerHTML = `
563
+ <input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
564
+ data-name="${option}" data-group="${addon.name}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
565
+ <label class="form-check-label" for="${optionId}">
566
+ ${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
567
+ </label>
568
+ `;
569
+ optionsContainer.appendChild(listItem);
570
  });
571
+ sectionDiv.appendChild(optionsContainer);
572
+ addonsList.appendChild(sectionDiv);
 
 
573
  });
574
+ })
575
+ .catch(err => {
576
+ console.error('Error fetching add-ons:', err);
577
+ document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
578
+ });
579
+ }
580
 
581
+ // Handle single-select/deselect logic for checkbox groups in all modals
582
+ document.addEventListener('click', function(event) {
583
+ if (event.target.classList.contains('addon-option')) {
584
+ handleAddonClick(event.target);
585
+ }
586
+ });
587
 
588
+ // Handle checkbox selection logic
589
+ function handleAddonClick(checkbox) {
590
+ const groupName = checkbox.getAttribute('data-group');
591
+ const isMultiSelectGroup = ["Extra Toppings", "Choose Raita/Sides","Select Dip/Sauce","Extra Add-ons","Make it a Combo"].includes(groupName);
592
+
593
+ // If it's not multi-select, uncheck all other checkboxes in the same group
594
+ if (!isMultiSelectGroup) {
595
+ const checkboxes = document.querySelectorAll(`.addon-option[data-group="${groupName}"]`);
596
+ checkboxes.forEach(otherCheckbox => {
597
+ if (otherCheckbox !== checkbox) {
598
+ otherCheckbox.checked = false;
599
+ }
600
+ });
601
+ }
602
+ }
603
+ function filterMenu() {
604
  let input = document.getElementById('searchBar').value.toLowerCase(); // Get the value from search bar
605
  let sections = document.querySelectorAll('h3'); // Select section headers
606
  let items = document.querySelectorAll('.menu-card'); // Select all items