Subbu1304 commited on
Commit
9f871cf
·
verified ·
1 Parent(s): 1fbf032

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +125 -163
templates/menu.html CHANGED
@@ -686,48 +686,7 @@ form-check-input addon-option{
686
  </div>
687
 
688
  <!-- Modal for Item Details -->
689
- <!-- <div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
690
- <div class="modal-dialog modal-dialog-centered">
691
- <div class="modal-content">
692
- <div class="modal-header">
693
- <h5 class="modal-title" id="itemModalLabel">Item Details</h5>
694
- <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
695
- </div>
696
- <div class="modal-body">
697
- <!-- Item Image -->
698
- <img id="modal-img" class="img-fluid rounded mb-3 d-block mx-auto" alt="Item Image" style="max-height: 200px; object-fit: cover;">
699
- <!-- Item Name -->
700
- <h5 id="modal-name" class="fw-bold text-center"></h5>
701
- <!-- Item Price -->
702
- <p id="modal-price" class="text-muted text-center"></p>
703
- <!-- Item Description -->
704
- <p id="modal-description" class="text-secondary"></p>
705
- <!-- Add-ons -->
706
- <div id="modal-addons" class="modal-addons mt-4">
707
- <h6>Customization Options</h6>
708
- <div id="addons-list" class="addons-container">Loading customization options...</div>
709
- </div>
710
- <div class="mt-4">
711
- <h6>Custom Request</h6>
712
- <textarea id="modal-instructions" class="form-control" placeholder="Enter any special instructions here..."></textarea>
713
- </div>
714
- <span id="modal-section" data-section="" data-category="" style="display: none;"></span>
715
- </div>
716
- <!-- Quantity Controls and Add to Cart Button -->
717
- <div class="modal-footer d-flex align-items-center justify-content-between">
718
- <!-- Quantity Controls -->
719
- <div class="d-flex align-items-center gap-2">
720
- <button type="button" class="btn btn-outline-secondary" id="decreaseQuantity">-</button>
721
- <input type="text" class="form-control text-center" id="quantityInput" value="1" readonly style="width: 50px;"/>
722
- <button type="button" class="btn btn-outline-secondary" id="increaseQuantity">+</button>
723
- </div>
724
- <!-- Add to Cart Button -->
725
- <button type="button" class="btn btn-primary" onclick="addToCartFromModal()">Add to Cart</button>
726
- </div>
727
- </div>
728
- </div>
729
- </div> -->
730
- <div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
731
  <div class="modal-dialog modal-dialog-centered">
732
  <div class="modal-content">
733
  <div class="modal-header">
@@ -770,135 +729,138 @@ form-check-input addon-option{
770
  </div>
771
 
772
 
 
773
  <!-- JavaScript -->
774
  <script>
775
- // Show item details and fetch customization options
776
- // function showItemDetails(name, price, image, description, section, selectedCategory) {
777
- // document.getElementById('modal-name').innerText = name;
778
- // document.getElementById('modal-price').innerText = `$${price}`;
779
- // document.getElementById('modal-img').src = image || '/static/placeholder.jpg';
780
- // document.getElementById('modal-description').innerText = description || 'No description available.';
781
- // document.getElementById('addons-list').innerHTML = 'Loading customization options...';
782
- // document.getElementById('modal-instructions').value = '';
783
-
784
- // const modalSectionEl = document.getElementById('modal-section');
785
- // modalSectionEl.setAttribute('data-section', section);
786
- // modalSectionEl.setAttribute('data-category', selectedCategory);
787
-
788
- // // Set the default quantity to 1
789
- // document.getElementById('quantityInput').value = 1;
 
 
790
 
791
- // // Fetch customization options based on the section
792
- // fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
793
- // .then(response => response.json())
794
- // .then(data => {
795
- // const addonsList = document.getElementById('addons-list');
796
- // addonsList.innerHTML = ''; // Clear previous content
797
-
798
- // if (!data.success || !data.addons || data.addons.length === 0) {
799
- // addonsList.innerHTML = '<p>No customization options available.</p>';
800
- // return;
801
- // }
802
 
803
- // // Display customization options inside styled divs
804
- // data.addons.forEach(addon => {
805
- // const sectionDiv = document.createElement('div');
806
- // sectionDiv.classList.add('addon-section'); // Add styling class
807
 
808
- // // Add section title
809
- // const title = document.createElement('h6');
810
- // title.innerText = addon.name;
811
- // sectionDiv.appendChild(title);
812
 
813
- // // Create options list
814
- // const optionsContainer = document.createElement('div');
815
- // addon.options.forEach((option, index) => {
816
- // const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
817
- // const listItem = document.createElement('div');
818
- // listItem.classList.add('form-check');
819
- // listItem.innerHTML = `
820
- // <input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
821
- // data-name="${option}" data-group="${addon.name}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
822
- // <label class="form-check-label" for="${optionId}">
823
- // ${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
824
- // </label>
825
- // `;
826
- // optionsContainer.appendChild(listItem);
827
- // });
828
- // sectionDiv.appendChild(optionsContainer);
829
- // addonsList.appendChild(sectionDiv);
830
- // });
831
- // })
832
- // .catch(err => {
833
- // console.error('Error fetching add-ons:', err);
834
- // document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
835
- // });
836
- // }
837
-
838
-
839
- function showItemDetails(name, price, image, description, section, selectedCategory) {
840
- // Set the modal details
841
- document.getElementById('modal-name').innerText = name || 'Unnamed Item';
842
- document.getElementById('modal-price').innerText = price ? `$${price}` : 'Price not available';
843
- document.getElementById('modal-img').src = image || '/static/placeholder.jpg'; // Placeholder image if no image is available
844
- document.getElementById('modal-description').innerText = description || 'No description available.';
845
- document.getElementById('addons-list').innerHTML = 'Loading customization options...';
846
- document.getElementById('modal-instructions').value = ''; // Clear any previous custom request
847
-
848
- // Set hidden data attributes for section and category
849
- const modalSectionEl = document.getElementById('modal-section');
850
- modalSectionEl.setAttribute('data-section', section || 'default-section');
851
- modalSectionEl.setAttribute('data-category', selectedCategory || 'default-category');
852
-
853
- // Set the default quantity to 1
854
- document.getElementById('quantityInput').value = 1;
855
-
856
- // Fetch customization options based on the section
857
- fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
858
- .then(response => response.json())
859
- .then(data => {
860
- const addonsList = document.getElementById('addons-list');
861
- addonsList.innerHTML = ''; // Clear previous content
862
-
863
- if (!data.success || !data.addons || data.addons.length === 0) {
864
- addonsList.innerHTML = '<p>No customization options available.</p>';
865
- return;
866
- }
867
-
868
- // Display customization options inside styled divs
869
- data.addons.forEach(addon => {
870
- const sectionDiv = document.createElement('div');
871
- sectionDiv.classList.add('addon-section'); // Add styling class
872
-
873
- // Add section title
874
- const title = document.createElement('h6');
875
- title.innerText = addon.name || 'Custom Add-ons';
876
- sectionDiv.appendChild(title);
877
-
878
- // Create options list
879
- const optionsContainer = document.createElement('div');
880
- addon.options.forEach((option, index) => {
881
- const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
882
- const listItem = document.createElement('div');
883
- listItem.classList.add('form-check');
884
- listItem.innerHTML = `
885
- <input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
886
- data-name="${option}" data-group="${addon.name}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
887
- <label class="form-check-label" for="${optionId}">
888
- ${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
889
- </label>
890
- `;
891
- optionsContainer.appendChild(listItem);
892
  });
893
- sectionDiv.appendChild(optionsContainer);
894
- addonsList.appendChild(sectionDiv);
 
 
895
  });
896
- })
897
- .catch(err => {
898
- console.error('Error fetching add-ons:', err);
899
- document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
900
- });
901
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
902
 
903
 
904
 
 
686
  </div>
687
 
688
  <!-- Modal for Item Details -->
689
+ <div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
690
  <div class="modal-dialog modal-dialog-centered">
691
  <div class="modal-content">
692
  <div class="modal-header">
 
729
  </div>
730
 
731
 
732
+
733
  <!-- JavaScript -->
734
  <script>
735
+
736
+
737
+ Show item details and fetch customization options
738
+ function showItemDetails(name, price, image, description, section, selectedCategory) {
739
+ document.getElementById('modal-name').innerText = name;
740
+ document.getElementById('modal-price').innerText = `$${price}`;
741
+ document.getElementById('modal-img').src = image || '/static/placeholder.jpg';
742
+ document.getElementById('modal-description').innerText = description || 'No description available.';
743
+ document.getElementById('addons-list').innerHTML = 'Loading customization options...';
744
+ document.getElementById('modal-instructions').value = '';
745
+
746
+ const modalSectionEl = document.getElementById('modal-section');
747
+ modalSectionEl.setAttribute('data-section', section);
748
+ modalSectionEl.setAttribute('data-category', selectedCategory);
749
+
750
+ // Set the default quantity to 1
751
+ document.getElementById('quantityInput').value = 1;
752
 
753
+ // Fetch customization options based on the section
754
+ fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
755
+ .then(response => response.json())
756
+ .then(data => {
757
+ const addonsList = document.getElementById('addons-list');
758
+ addonsList.innerHTML = ''; // Clear previous content
759
+
760
+ if (!data.success || !data.addons || data.addons.length === 0) {
761
+ addonsList.innerHTML = '<p>No customization options available.</p>';
762
+ return;
763
+ }
764
 
765
+ // Display customization options inside styled divs
766
+ data.addons.forEach(addon => {
767
+ const sectionDiv = document.createElement('div');
768
+ sectionDiv.classList.add('addon-section'); // Add styling class
769
 
770
+ // Add section title
771
+ const title = document.createElement('h6');
772
+ title.innerText = addon.name;
773
+ sectionDiv.appendChild(title);
774
 
775
+ // Create options list
776
+ const optionsContainer = document.createElement('div');
777
+ addon.options.forEach((option, index) => {
778
+ const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
779
+ const listItem = document.createElement('div');
780
+ listItem.classList.add('form-check');
781
+ listItem.innerHTML = `
782
+ <input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
783
+ data-name="${option}" data-group="${addon.name}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
784
+ <label class="form-check-label" for="${optionId}">
785
+ ${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
786
+ </label>
787
+ `;
788
+ optionsContainer.appendChild(listItem);
789
+ });
790
+ sectionDiv.appendChild(optionsContainer);
791
+ addonsList.appendChild(sectionDiv);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
792
  });
793
+ })
794
+ .catch(err => {
795
+ console.error('Error fetching add-ons:', err);
796
+ document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
797
  });
798
+ }
799
+
800
+
801
+ // function showItemDetails(name, price, image, description, section, selectedCategory) {
802
+ // // Set the modal details
803
+ // document.getElementById('modal-name').innerText = name || 'Unnamed Item';
804
+ // document.getElementById('modal-price').innerText = price ? `$${price}` : 'Price not available';
805
+ // document.getElementById('modal-img').src = image || '/static/placeholder.jpg'; // Placeholder image if no image is available
806
+ // document.getElementById('modal-description').innerText = description || 'No description available.';
807
+ // document.getElementById('addons-list').innerHTML = 'Loading customization options...';
808
+ // document.getElementById('modal-instructions').value = ''; // Clear any previous custom request
809
+
810
+ // // Set hidden data attributes for section and category
811
+ // const modalSectionEl = document.getElementById('modal-section');
812
+ // modalSectionEl.setAttribute('data-section', section || 'default-section');
813
+ // modalSectionEl.setAttribute('data-category', selectedCategory || 'default-category');
814
+
815
+ // // Set the default quantity to 1
816
+ // document.getElementById('quantityInput').value = 1;
817
+
818
+ // // Fetch customization options based on the section
819
+ // fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
820
+ // .then(response => response.json())
821
+ // .then(data => {
822
+ // const addonsList = document.getElementById('addons-list');
823
+ // addonsList.innerHTML = ''; // Clear previous content
824
+
825
+ // if (!data.success || !data.addons || data.addons.length === 0) {
826
+ // addonsList.innerHTML = '<p>No customization options available.</p>';
827
+ // return;
828
+ // }
829
+
830
+ // // Display customization options inside styled divs
831
+ // data.addons.forEach(addon => {
832
+ // const sectionDiv = document.createElement('div');
833
+ // sectionDiv.classList.add('addon-section'); // Add styling class
834
+
835
+ // // Add section title
836
+ // const title = document.createElement('h6');
837
+ // title.innerText = addon.name || 'Custom Add-ons';
838
+ // sectionDiv.appendChild(title);
839
+
840
+ // // Create options list
841
+ // const optionsContainer = document.createElement('div');
842
+ // addon.options.forEach((option, index) => {
843
+ // const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
844
+ // const listItem = document.createElement('div');
845
+ // listItem.classList.add('form-check');
846
+ // listItem.innerHTML = `
847
+ // <input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
848
+ // data-name="${option}" data-group="${addon.name}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
849
+ // <label class="form-check-label" for="${optionId}">
850
+ // ${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
851
+ // </label>
852
+ // `;
853
+ // optionsContainer.appendChild(listItem);
854
+ // });
855
+ // sectionDiv.appendChild(optionsContainer);
856
+ // addonsList.appendChild(sectionDiv);
857
+ // });
858
+ // })
859
+ // .catch(err => {
860
+ // console.error('Error fetching add-ons:', err);
861
+ // document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
862
+ // });
863
+ // }
864
 
865
 
866