Update templates/search.html
Browse files- templates/search.html +18 -284
templates/search.html
CHANGED
@@ -114,7 +114,10 @@
|
|
114 |
.container {
|
115 |
max-width: 900px;
|
116 |
margin-top: 20px;
|
117 |
-
margin-bottom: 70px;
|
|
|
|
|
|
|
118 |
}
|
119 |
.menu-card {
|
120 |
max-width: 350px;
|
@@ -125,6 +128,10 @@
|
|
125 |
display: flex;
|
126 |
flex-direction: column;
|
127 |
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
|
|
|
|
|
|
|
|
128 |
}
|
129 |
.menu-video {
|
130 |
height: 200px;
|
@@ -132,82 +139,15 @@
|
|
132 |
object-fit: cover;
|
133 |
border-radius: 15px 15px 0 0;
|
134 |
}
|
135 |
-
.card-body
|
|
|
|
|
|
|
|
|
136 |
font-size: 1.2rem;
|
137 |
font-weight: 600;
|
138 |
-
margin: 10px 0;
|
139 |
-
color: #333333;
|
140 |
-
}
|
141 |
-
.card-body .card-text.price {
|
142 |
-
font-size: 1rem;
|
143 |
-
font-weight: 500;
|
144 |
-
color: #000000;
|
145 |
-
margin-bottom: 5px;
|
146 |
-
}
|
147 |
-
.btn-primary {
|
148 |
-
font-size: 12px;
|
149 |
-
font-weight: bold;
|
150 |
-
border-radius: 8px;
|
151 |
-
width: 70px;
|
152 |
-
height: 35px;
|
153 |
-
background-color: #0FAA39;
|
154 |
-
border-color: #0FAA39;
|
155 |
-
display: flex;
|
156 |
-
align-items: center;
|
157 |
-
justify-content: center;
|
158 |
-
padding: 0;
|
159 |
-
}
|
160 |
-
/* Modal styling from menu.html */
|
161 |
-
.modal-fullscreen {
|
162 |
-
width: 100vw;
|
163 |
-
max-width: none;
|
164 |
-
height: 100%;
|
165 |
margin: 0;
|
166 |
-
|
167 |
-
.modal-fullscreen .modal-content {
|
168 |
-
height: 100%;
|
169 |
-
border: none;
|
170 |
-
border-radius: 0;
|
171 |
-
background-color: #fdf4e3;
|
172 |
-
}
|
173 |
-
.modal-body {
|
174 |
-
padding: 20px;
|
175 |
-
overflow-y: auto;
|
176 |
-
}
|
177 |
-
.modal-footer {
|
178 |
-
padding: 15px;
|
179 |
-
display: flex;
|
180 |
-
justify-content: space-between;
|
181 |
-
align-items: center;
|
182 |
-
border-top: none;
|
183 |
-
}
|
184 |
-
.addon-section {
|
185 |
-
background-color: #fff;
|
186 |
-
border: 2px solid #ffa500;
|
187 |
-
border-radius: 8px;
|
188 |
-
padding: 12px;
|
189 |
-
margin-bottom: 15px;
|
190 |
-
}
|
191 |
-
.addon-section h6 {
|
192 |
-
margin-bottom: 10px;
|
193 |
-
font-size: 1.1rem;
|
194 |
-
font-weight: bold;
|
195 |
-
color: #333;
|
196 |
-
}
|
197 |
-
.form-check {
|
198 |
-
margin-bottom: 8px;
|
199 |
-
}
|
200 |
-
.form-check-input {
|
201 |
-
margin-right: 10px;
|
202 |
-
}
|
203 |
-
.quantity-controls {
|
204 |
-
display: flex;
|
205 |
-
align-items: center;
|
206 |
-
gap: 10px;
|
207 |
-
}
|
208 |
-
.quantity-controls input {
|
209 |
-
width: 50px;
|
210 |
-
text-align: center;
|
211 |
}
|
212 |
</style>
|
213 |
</head>
|
@@ -223,30 +163,13 @@
|
|
223 |
<h2>Search Results</h2>
|
224 |
<div id="searchResults" class="row">
|
225 |
{% for item in all_items %}
|
226 |
-
<div class="col-md-6 mb-4 search-item" data-name="{{ item.Name | lower }}" data-section="{{ item.Section__c | lower }}"
|
|
|
227 |
<div class="card menu-card">
|
228 |
-
<
|
229 |
-
|
230 |
-
muted
|
231 |
-
loop
|
232 |
-
preload="auto"
|
233 |
-
data-src="{{ item.Video1__c }}"
|
234 |
-
poster="{{ item.Image1__c | default('/static/placeholder.jpg') }}"
|
235 |
-
width="350"
|
236 |
-
height="200"
|
237 |
-
onmouseover="this.play()"
|
238 |
-
onmouseout="this.pause(); this.currentTime = 0;">
|
239 |
-
<source src="{{ item.Video1__c }}" type="video/mp4">
|
240 |
-
</video>
|
241 |
<div class="card-body">
|
242 |
<h5 class="card-title">{{ item.Name }}</h5>
|
243 |
-
<p class="card-text price">${{ item.Price__c }}</p>
|
244 |
-
<button class="btn btn-primary"
|
245 |
-
data-bs-toggle="modal"
|
246 |
-
data-bs-target="#itemModal"
|
247 |
-
onclick="showItemDetails('{{ item.Name | e }}', '{{ item.Price__c }}', '{{ item.Image2__c | default(item.Image1__c) | default('/static/placeholder.jpg') }}', '{{ item.Description__c | e }}', '{{ item.IngredientsInfo__c | default('Not specified') | e }}', '{{ item.NutritionalInfo__c | default('Not available') | e }}', '{{ item.Allergens__c | default('None listed') | e }}', '{{ item.Section__c | e }}', '{{ item.Veg_NonVeg__c | default('both') | e }}', '{{ 'true' if item.is_menu_item else 'false' }}')">
|
248 |
-
ADD
|
249 |
-
</button>
|
250 |
</div>
|
251 |
</div>
|
252 |
</div>
|
@@ -261,46 +184,6 @@
|
|
261 |
<div id="autocompleteSuggestions" class="autocomplete-suggestions"></div>
|
262 |
</div>
|
263 |
|
264 |
-
<!-- Item Modal (Exact replica from menu.html) -->
|
265 |
-
<div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
|
266 |
-
<div class="modal-dialog modal-fullscreen">
|
267 |
-
<div class="modal-content">
|
268 |
-
<div class="modal-header">
|
269 |
-
<h5 class="modal-title" id="itemModalLabel">Item Details</h5>
|
270 |
-
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
271 |
-
</div>
|
272 |
-
<div class="modal-body">
|
273 |
-
<img id="modal-img" class="img-fluid rounded mb-3 d-block mx-auto" alt="Item Image" style="max-height: 200px; object-fit: cover;">
|
274 |
-
<h5 id="modal-name" class="fw-bold text-center"></h5>
|
275 |
-
<p id="modal-price" class="text-muted text-center"></p>
|
276 |
-
<p id="modal-description" class="text-secondary text-center"></p>
|
277 |
-
<div class="nutritional-info text-center">
|
278 |
-
<strong>Ingredients:</strong> <span id="modal-ingredients"></span><br>
|
279 |
-
<strong>Nutrition:</strong> <span id="modal-nutrition"></span><br>
|
280 |
-
<strong>Allergens:</strong> <span id="modal-allergens"></span>
|
281 |
-
</div>
|
282 |
-
<div id="modal-addons" class="modal-addons mt-4">
|
283 |
-
<h6 class="text-center">Customization Options</h6>
|
284 |
-
<div id="addons-list" class="addons-container">Loading customization options...</div>
|
285 |
-
</div>
|
286 |
-
<div class="mt-4">
|
287 |
-
<h6 class="text-center">Custom Request</h6>
|
288 |
-
<textarea id="modal-instructions" class="form-control" placeholder="Enter any special instructions here..."></textarea>
|
289 |
-
</div>
|
290 |
-
<span id="modal-section" data-section="" data-category="" data-is-menu-item="" style="display: none;"></span>
|
291 |
-
</div>
|
292 |
-
<div class="modal-footer">
|
293 |
-
<div class="quantity-controls">
|
294 |
-
<button type="button" class="btn btn-outline-secondary" id="decreaseQuantity">-</button>
|
295 |
-
<input type="text" class="form-control" id="quantityInput" value="1" readonly>
|
296 |
-
<button type="button" class="btn btn-outline-secondary" id="increaseQuantity">+</button>
|
297 |
-
</div>
|
298 |
-
<button type="button" class="btn btn-primary" onclick="addToCartFromModal()">Add to Cart</button>
|
299 |
-
</div>
|
300 |
-
</div>
|
301 |
-
</div>
|
302 |
-
</div>
|
303 |
-
|
304 |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
|
305 |
<script>
|
306 |
const menuItems = [
|
@@ -371,155 +254,6 @@
|
|
371 |
suggestionsContainer.style.display = 'none';
|
372 |
}
|
373 |
});
|
374 |
-
|
375 |
-
// Quantity controls
|
376 |
-
const decreaseBtn = document.getElementById('decreaseQuantity');
|
377 |
-
const increaseBtn = document.getElementById('increaseQuantity');
|
378 |
-
const quantityInput = document.getElementById('quantityInput');
|
379 |
-
|
380 |
-
decreaseBtn.addEventListener('click', function () {
|
381 |
-
let currentQuantity = parseInt(quantityInput.value);
|
382 |
-
if (currentQuantity > 1) {
|
383 |
-
currentQuantity--;
|
384 |
-
quantityInput.value = currentQuantity;
|
385 |
-
}
|
386 |
-
});
|
387 |
-
|
388 |
-
increaseBtn.addEventListener('click', function () {
|
389 |
-
let currentQuantity = parseInt(quantityInput.value);
|
390 |
-
currentQuantity++;
|
391 |
-
quantityInput.value = currentQuantity;
|
392 |
-
});
|
393 |
-
|
394 |
-
window.showItemDetails = function(name, price, image, description, ingredients, nutrition, allergens, section, vegNonVeg, isMenuItem) {
|
395 |
-
document.getElementById('modal-name').innerText = name;
|
396 |
-
document.getElementById('modal-price').innerText = `$${parseFloat(price).toFixed(2)}`;
|
397 |
-
const modalImg = document.getElementById('modal-img');
|
398 |
-
modalImg.src = image || '/static/placeholder.jpg';
|
399 |
-
document.getElementById('modal-description').innerText = description || 'No description available.';
|
400 |
-
document.getElementById('modal-ingredients').innerText = ingredients || 'Not specified';
|
401 |
-
document.getElementById('modal-nutrition').innerText = nutrition || 'Not available';
|
402 |
-
document.getElementById('modal-allergens').innerText = allergens || 'None listed';
|
403 |
-
document.getElementById('addons-list').innerHTML = 'Loading customization options...';
|
404 |
-
document.getElementById('modal-instructions').value = '';
|
405 |
-
const modalSectionEl = document.getElementById('modal-section');
|
406 |
-
modalSectionEl.setAttribute('data-section', section);
|
407 |
-
modalSectionEl.setAttribute('data-category', vegNonVeg === 'Veg' ? 'Veg' : vegNonVeg === 'Non veg' ? 'Non veg' : 'All');
|
408 |
-
modalSectionEl.setAttribute('data-is-menu-item', isMenuItem);
|
409 |
-
document.getElementById('quantityInput').value = 1;
|
410 |
-
|
411 |
-
fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
|
412 |
-
.then(response => response.json())
|
413 |
-
.then(data => {
|
414 |
-
const addonsList = document.getElementById('addons-list');
|
415 |
-
addonsList.innerHTML = '';
|
416 |
-
if (!data.success || !data.addons || data.addons.length === 0) {
|
417 |
-
addonsList.innerHTML = '<p>No customization options available.</p>';
|
418 |
-
return;
|
419 |
-
}
|
420 |
-
data.addons.forEach(addon => {
|
421 |
-
const sectionDiv = document.createElement('div');
|
422 |
-
sectionDiv.classList.add('addon-section');
|
423 |
-
const title = document.createElement('h6');
|
424 |
-
title.innerText = addon.name;
|
425 |
-
sectionDiv.appendChild(title);
|
426 |
-
const optionsContainer = document.createElement('div');
|
427 |
-
addon.options.forEach((option, index) => {
|
428 |
-
const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
|
429 |
-
const inputType = addon.max_selections === 1 ? 'radio' : 'checkbox';
|
430 |
-
const listItem = document.createElement('div');
|
431 |
-
listItem.classList.add('form-check');
|
432 |
-
listItem.innerHTML = `
|
433 |
-
<input type="${inputType}" class="form-check-input addon-option" id="${optionId}"
|
434 |
-
name="${addon.name}" value="${option}"
|
435 |
-
data-name="${option}" data-group="${addon.name}"
|
436 |
-
data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
|
437 |
-
<label class="form-check-label" for="${optionId}">
|
438 |
-
${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
|
439 |
-
</label>
|
440 |
-
`;
|
441 |
-
optionsContainer.appendChild(listItem);
|
442 |
-
});
|
443 |
-
if (addon.max_selections > 1) {
|
444 |
-
const inputs = optionsContainer.querySelectorAll('input[type="checkbox"]');
|
445 |
-
inputs.forEach(input => {
|
446 |
-
input.addEventListener('change', function () {
|
447 |
-
const checkedCount = optionsContainer.querySelectorAll('input[type="checkbox"]:checked').length;
|
448 |
-
if (checkedCount > addon.max_selections) {
|
449 |
-
this.checked = false;
|
450 |
-
alert(`You can select up to ${addon.max_selections} options for ${addon.name}.`);
|
451 |
-
}
|
452 |
-
});
|
453 |
-
});
|
454 |
-
}
|
455 |
-
sectionDiv.appendChild(optionsContainer);
|
456 |
-
addonsList.appendChild(sectionDiv);
|
457 |
-
});
|
458 |
-
})
|
459 |
-
.catch(err => {
|
460 |
-
console.error('Error fetching add-ons:', err);
|
461 |
-
document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
|
462 |
-
});
|
463 |
-
};
|
464 |
-
|
465 |
-
window.addToCartFromModal = function() {
|
466 |
-
const itemName = document.getElementById('modal-name').innerText;
|
467 |
-
const itemPrice = parseFloat(document.getElementById('modal-price').innerText.replace('$', ''));
|
468 |
-
const itemImage = document.getElementById('modal-img').src;
|
469 |
-
const instructions = document.getElementById('modal-instructions').value;
|
470 |
-
const quantity = parseInt(document.getElementById('quantityInput').value);
|
471 |
-
const modalSectionEl = document.getElementById('modal-section');
|
472 |
-
const section = modalSectionEl.getAttribute('data-section');
|
473 |
-
const category = modalSectionEl.getAttribute('data-category');
|
474 |
-
const isMenuItem = modalSectionEl.getAttribute('data-is-menu-item') === 'true';
|
475 |
-
|
476 |
-
const addons = [];
|
477 |
-
document.querySelectorAll('.addon-option:checked').forEach(checkbox => {
|
478 |
-
addons.push({
|
479 |
-
name: checkbox.getAttribute('data-name'),
|
480 |
-
price: parseFloat(checkbox.getAttribute('data-price')) || 0
|
481 |
-
});
|
482 |
-
});
|
483 |
-
|
484 |
-
const cartPayload = {
|
485 |
-
itemName: itemName,
|
486 |
-
itemPrice: itemPrice,
|
487 |
-
itemImage: itemImage,
|
488 |
-
section: section,
|
489 |
-
category: category,
|
490 |
-
addons: addons,
|
491 |
-
instructions: instructions,
|
492 |
-
quantity: quantity
|
493 |
-
};
|
494 |
-
|
495 |
-
fetch('/cart/add', {
|
496 |
-
method: 'POST',
|
497 |
-
headers: {
|
498 |
-
'Content-Type': 'application/json',
|
499 |
-
},
|
500 |
-
body: JSON.stringify(cartPayload)
|
501 |
-
})
|
502 |
-
.then(response => {
|
503 |
-
if (!response.ok) {
|
504 |
-
throw new Error(`HTTP error! status: ${response.status}`);
|
505 |
-
}
|
506 |
-
return response.json();
|
507 |
-
})
|
508 |
-
.then(data => {
|
509 |
-
if (data.success) {
|
510 |
-
alert('Item added to cart successfully!');
|
511 |
-
const modal = bootstrap.Modal.getInstance(document.getElementById('itemModal'));
|
512 |
-
modal.hide();
|
513 |
-
} else {
|
514 |
-
console.error('Failed to add item to cart:', data.error);
|
515 |
-
alert(data.error || 'Failed to add item to cart.');
|
516 |
-
}
|
517 |
-
})
|
518 |
-
.catch(err => {
|
519 |
-
console.error('Error adding item to cart:', err);
|
520 |
-
alert('Error adding item to cart. Please check the console for details.');
|
521 |
-
});
|
522 |
-
};
|
523 |
});
|
524 |
</script>
|
525 |
</body>
|
|
|
114 |
.container {
|
115 |
max-width: 900px;
|
116 |
margin-top: 20px;
|
117 |
+
margin-bottom: 70px;
|
118 |
+
}
|
119 |
+
.search-item {
|
120 |
+
cursor: pointer;
|
121 |
}
|
122 |
.menu-card {
|
123 |
max-width: 350px;
|
|
|
128 |
display: flex;
|
129 |
flex-direction: column;
|
130 |
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
131 |
+
transition: transform 0.2s;
|
132 |
+
}
|
133 |
+
.menu-card:hover {
|
134 |
+
transform: scale(1.05);
|
135 |
}
|
136 |
.menu-video {
|
137 |
height: 200px;
|
|
|
139 |
object-fit: cover;
|
140 |
border-radius: 15px 15px 0 0;
|
141 |
}
|
142 |
+
.card-body {
|
143 |
+
padding: 10px;
|
144 |
+
text-align: center;
|
145 |
+
}
|
146 |
+
.card-title {
|
147 |
font-size: 1.2rem;
|
148 |
font-weight: 600;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
margin: 0;
|
150 |
+
color: #333333;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
152 |
</style>
|
153 |
</head>
|
|
|
163 |
<h2>Search Results</h2>
|
164 |
<div id="searchResults" class="row">
|
165 |
{% for item in all_items %}
|
166 |
+
<div class="col-md-6 mb-4 search-item" data-name="{{ item.Name | lower }}" data-section="{{ item.Section__c | lower }}"
|
167 |
+
onclick="window.location.href='/menu?highlight={{ item.Name | urlencode }}'">
|
168 |
<div class="card menu-card">
|
169 |
+
<img src="{{ item.Image2__c | default(item.Image1__c) | default('/static/placeholder.jpg') }}"
|
170 |
+
class="card-img-top menu-video" alt="{{ item.Name }}" style="height: 200px; object-fit: cover;">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
<div class="card-body">
|
172 |
<h5 class="card-title">{{ item.Name }}</h5>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
</div>
|
174 |
</div>
|
175 |
</div>
|
|
|
184 |
<div id="autocompleteSuggestions" class="autocomplete-suggestions"></div>
|
185 |
</div>
|
186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
|
188 |
<script>
|
189 |
const menuItems = [
|
|
|
254 |
suggestionsContainer.style.display = 'none';
|
255 |
}
|
256 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
});
|
258 |
</script>
|
259 |
</body>
|