lokesh341 commited on
Commit
7fa6b81
·
verified ·
1 Parent(s): 32a7972

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +39 -57
templates/menu.html CHANGED
@@ -454,17 +454,10 @@
454
  <p id="modal-price" class="text-muted text-center"></p>
455
  <p id="modal-description" class="text-secondary"></p>
456
 
457
- <div id="first-row">
458
- <div class="row">
459
- <div class="col-6">
460
- <h6>Type</h6>
461
- <div id="type-options"></div>
462
- </div>
463
- <div class="col-6">
464
- <h6>Spice Level</h6>
465
- <div id="spice-level-options"></div>
466
- </div>
467
- </div>
468
  </div>
469
 
470
  <div id="modal-addons" class="modal-addons mt-4">
@@ -507,17 +500,15 @@
507
 
508
  document.getElementById('quantityInput').value = 1;
509
 
510
- const typeOptions = document.getElementById('type-options');
511
- const spiceLevelOptions = document.getElementById('spice-level-options');
512
- const firstRow = document.getElementById('first-row');
513
 
514
- typeOptions.innerHTML = '';
515
- spiceLevelOptions.innerHTML = '';
516
 
517
  if (section.toLowerCase() === 'starters') {
518
- firstRow.style.display = 'block';
519
  } else {
520
- firstRow.style.display = 'none';
521
  }
522
 
523
  fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
@@ -533,40 +524,35 @@
533
 
534
  if (section.toLowerCase() === 'starters') {
535
  data.addons.forEach(addon => {
536
- if (addon.name.toLowerCase() === "type") {
537
- addon.options.forEach(option => {
538
- const optionId = `addon-type-${option}`;
539
- const optionHTML = `
540
- <div class="form-check">
541
- <input type="checkbox" class="form-check-input" id="${optionId}" value="${option}" data-name="${option}" data-group="Type">
542
- <label class="form-check-label" for="${optionId}">
543
- ${option}
544
- </label>
545
- </div>
546
- `;
547
- typeOptions.innerHTML += optionHTML;
548
- });
549
- }
550
- if (addon.name.toLowerCase() === "spice level") {
551
  addon.options.forEach(option => {
552
- const optionId = `addon-spice-level-${option}`;
553
  const optionHTML = `
554
  <div class="form-check">
555
- <input type="checkbox" class="form-check-input" id="${optionId}" value="${option}" data-name="${option}" data-group="Spice Level">
556
  <label class="form-check-label" for="${optionId}">
557
  ${option}
558
  </label>
559
  </div>
560
  `;
561
- spiceLevelOptions.innerHTML += optionHTML;
562
  });
563
  }
564
  });
565
  }
566
 
 
 
 
 
 
 
 
 
 
 
567
  data.addons.forEach(addon => {
568
- if (section.toLowerCase() === 'starters' &&
569
- (addon.name.toLowerCase() === "type" || addon.name.toLowerCase() === "spice level")) {
570
  return;
571
  }
572
 
@@ -593,17 +579,20 @@
593
  optionsContainer.appendChild(listItem);
594
  });
595
  sectionDiv.appendChild(optionsContainer);
596
- addonsList.appendChild(sectionDiv);
597
  });
598
 
599
- if (section.toLowerCase() !== 'starters') {
600
- const spiceLevelSection = Array.from(addonsList.children).find(section =>
601
- section.getAttribute('data-addon-name') === "Spice Level"
602
- );
603
- if (spiceLevelSection) {
604
- addonsList.prepend(spiceLevelSection);
605
  }
606
- }
 
 
 
 
 
 
607
  })
608
  .catch(err => {
609
  console.error('Error fetching add-ons:', err);
@@ -686,21 +675,14 @@
686
  price: parseFloat(addon.getAttribute('data-price') || 0)
687
  }));
688
 
689
- // Include Type and Spice Level for Starters
690
  if (section.toLowerCase() === 'starters') {
691
- const typeOptions = Array.from(
692
- document.querySelectorAll('#type-options input[type="checkbox"]:checked')
693
- ).map(option => ({
694
- name: option.getAttribute('data-name') || 'Default Type',
695
- price: 0
696
- }));
697
- const spiceLevelOptions = Array.from(
698
- document.querySelectorAll('#spice-level-options input[type="checkbox"]:checked')
699
  ).map(option => ({
700
- name: option.getAttribute('data-name') || 'Default Spice Level',
701
  price: 0
702
  }));
703
- selectedAddOns = [...selectedAddOns, ...typeOptions, ...spiceLevelOptions];
704
  }
705
 
706
  const quantity = parseInt(document.getElementById('quantityInput').value) || 1;
 
454
  <p id="modal-price" class="text-muted text-center"></p>
455
  <p id="modal-description" class="text-secondary"></p>
456
 
457
+ <!-- Choose Preparation Style (for Starters only) -->
458
+ <div id="prep-style-section" class="mt-4" style="display: none;">
459
+ <h6>Choose Preparation Style</h6>
460
+ <div id="prep-style-options" class="addon-section"></div>
 
 
 
 
 
 
 
461
  </div>
462
 
463
  <div id="modal-addons" class="modal-addons mt-4">
 
500
 
501
  document.getElementById('quantityInput').value = 1;
502
 
503
+ const prepStyleSection = document.getElementById('prep-style-section');
504
+ const prepStyleOptions = document.getElementById('prep-style-options');
 
505
 
506
+ prepStyleOptions.innerHTML = '';
 
507
 
508
  if (section.toLowerCase() === 'starters') {
509
+ prepStyleSection.style.display = 'block';
510
  } else {
511
+ prepStyleSection.style.display = 'none';
512
  }
513
 
514
  fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
 
524
 
525
  if (section.toLowerCase() === 'starters') {
526
  data.addons.forEach(addon => {
527
+ if (addon.name.toLowerCase() === "choose preparation style") {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
  addon.options.forEach(option => {
529
+ const optionId = `prep-style-${option}`;
530
  const optionHTML = `
531
  <div class="form-check">
532
+ <input type="checkbox" class="form-check-input" id="${optionId}" value="${option}" data-name="${option}" data-group="Choose Preparation Style">
533
  <label class="form-check-label" for="${optionId}">
534
  ${option}
535
  </label>
536
  </div>
537
  `;
538
+ prepStyleOptions.innerHTML += optionHTML;
539
  });
540
  }
541
  });
542
  }
543
 
544
+ const desiredOrder = [
545
+ "Spice Level",
546
+ "Choose Preparation Style",
547
+ "Select Dip/Sauce",
548
+ "Extra Add-ons",
549
+ "Make it a Combo",
550
+ "Type"
551
+ ];
552
+
553
+ const sections = {};
554
  data.addons.forEach(addon => {
555
+ if (section.toLowerCase() === 'starters' && addon.name.toLowerCase() === "choose preparation style") {
 
556
  return;
557
  }
558
 
 
579
  optionsContainer.appendChild(listItem);
580
  });
581
  sectionDiv.appendChild(optionsContainer);
582
+ sections[addon.name] = sectionDiv;
583
  });
584
 
585
+ desiredOrder.forEach(sectionName => {
586
+ if (sections[sectionName]) {
587
+ addonsList.appendChild(sections[sectionName]);
 
 
 
588
  }
589
+ });
590
+
591
+ Object.keys(sections).forEach(sectionName => {
592
+ if (!desiredOrder.includes(sectionName)) {
593
+ addonsList.appendChild(sections[sectionName]);
594
+ }
595
+ });
596
  })
597
  .catch(err => {
598
  console.error('Error fetching add-ons:', err);
 
675
  price: parseFloat(addon.getAttribute('data-price') || 0)
676
  }));
677
 
 
678
  if (section.toLowerCase() === 'starters') {
679
+ const prepStyleOptions = Array.from(
680
+ document.querySelectorAll('#prep-style-options input[type="checkbox"]:checked')
 
 
 
 
 
 
681
  ).map(option => ({
682
+ name: option.getAttribute('data-name') || 'Default Preparation Style',
683
  price: 0
684
  }));
685
+ selectedAddOns = [...selectedAddOns, ...prepStyleOptions];
686
  }
687
 
688
  const quantity = parseInt(document.getElementById('quantityInput').value) || 1;