fixing the db migrations

This commit is contained in:
2025-10-01 12:40:58 -07:00
parent 63b3575797
commit 7ffc57a7a8
7 changed files with 158 additions and 51 deletions

View File

@@ -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>