mirror of
https://github.com/sstent/foodplanner.git
synced 2026-01-25 11:11:36 +00:00
fixing the db migrations
This commit is contained in:
@@ -12,15 +12,16 @@
|
||||
<input type="hidden" name="date" value="{{ current_date.isoformat() }}">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Select Food</label>
|
||||
<select class="form-control" name="food_id" required>
|
||||
<select class="form-control" name="food_id" required onchange="updateServingSizeNote(this)">
|
||||
<option value="">Choose food...</option>
|
||||
{% for food in foods %}
|
||||
<option value="{{ food.id }}">{{ food.name }}</option>
|
||||
<option value="{{ food.id }}" data-serving-size="{{ food.serving_size }}">{{ food.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Quantity (g)</label>
|
||||
<span id="servingSizeNote" class="text-muted small ms-2"></span>
|
||||
<input type="number" step="0.1" class="form-control" name="quantity" value="1.0" min="0.1" required>
|
||||
</div>
|
||||
<input type="hidden" name="meal_time" id="addSingleFoodMealTime">
|
||||
@@ -30,6 +31,19 @@
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" onclick="submitAddSingleFood()">Add Food</button>
|
||||
</div>
|
||||
<script>
|
||||
function updateServingSizeNote(selectElement) {
|
||||
const selectedOption = selectElement.options[selectElement.selectedIndex];
|
||||
const servingSize = selectedOption.getAttribute('data-serving-size');
|
||||
const servingSizeNote = document.getElementById('servingSizeNote');
|
||||
|
||||
if (servingSize) {
|
||||
servingSizeNote.textContent = `(Serving size: ${servingSize}g)`;
|
||||
} else {
|
||||
servingSizeNote.textContent = '';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user