DSatishchandra commited on
Commit
2705ba8
·
verified ·
1 Parent(s): 1ca9618

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +25 -4
templates/menu.html CHANGED
@@ -492,8 +492,6 @@ form.text-center.mb-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>
@@ -558,6 +556,7 @@ form.text-center.mb-4 {
558
  const title = document.createElement('h6');
559
  title.innerText = addon.name;
560
  sectionDiv.appendChild(title);
 
561
  // Create options list
562
  const optionsContainer = document.createElement('div');
563
  addon.options.forEach((option, index) => {
@@ -566,7 +565,7 @@ form.text-center.mb-4 {
566
  listItem.classList.add('form-check');
567
  listItem.innerHTML = `
568
  <input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
569
- data-name="${option}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
570
  <label class="form-check-label" for="${optionId}">
571
  ${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
572
  </label>
@@ -582,8 +581,30 @@ form.text-center.mb-4 {
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
589
  let items = document.querySelectorAll('.menu-card'); // Select all items
 
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>
 
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) => {
 
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-group="${addon.name}" 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>
 
581
  document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
582
  });
583
  }
584
+ // Generalized function to handle single/multi-select logic for all modals
585
+ document.addEventListener('click', function(event) {
586
+ if (event.target.classList.contains('addon-option')) {
587
+ handleAddonClick(event.target);
588
+ }
589
+ });
590
+
591
+ // Handle single-select/deselect logic for checkbox groups in all modals
592
+ function handleAddonClick(checkbox) {
593
+ const groupName = checkbox.getAttribute('data-group');
594
+ const isMultiSelectGroup = ["Extra Toppings", "Choose Raita/Sides"].includes(groupName);
595
+
596
+ // If it's not multi-select, uncheck all other checkboxes in the same group
597
+ if (!isMultiSelectGroup) {
598
+ const checkboxes = document.querySelectorAll(.addon-option[data-group="${groupName}"]);
599
+ checkboxes.forEach(otherCheckbox => {
600
+ if (otherCheckbox !== checkbox) {
601
+ otherCheckbox.checked = false;
602
+ }
603
+ });
604
+ }
605
+     }
606
 
607
+ function filterMenu() {
608
  let input = document.getElementById('searchBar').value.toLowerCase(); // Get the value from search bar
609
  let sections = document.querySelectorAll('h3'); // Select section headers
610
  let items = document.querySelectorAll('.menu-card'); // Select all items