updated the tracker to have more features

This commit is contained in:
2025-09-30 09:40:06 -07:00
parent b6184414c0
commit 9ce2695df5
4 changed files with 18 additions and 19 deletions

View File

@@ -290,7 +290,7 @@ async def detailed(request: Request, person: str = "Sarah", plan_date: str = Non
context = { context = {
"request": request, "request": request,
"title": f"{person}'s Detailed Plan for {plan_date_obj.strftime('%B %d, %Y')}", "title": f"Detailed Plan for {person} on {plan_date_obj.strftime('%B %d, %Y')}" if person else "Detailed View",
"meal_details": meal_details, "meal_details": meal_details,
"day_totals": day_totals, "day_totals": day_totals,
"person": person, "person": person,

View File

@@ -87,7 +87,7 @@ async def tracker_add_meal(request: Request, db: Session = Depends(get_db)):
date_str = form_data.get("date") date_str = form_data.get("date")
meal_id = form_data.get("meal_id") meal_id = form_data.get("meal_id")
meal_time = form_data.get("meal_time") meal_time = form_data.get("meal_time")
quantity = float(form_data.get("quantity", 1.0)) quantity = 1.0 # Default quantity to 1.0 as the field is removed from the UI
logging.info(f"DEBUG: Adding meal to tracker - person={person}, date={date_str}, meal_id={meal_id}, meal_time={meal_time}, quantity={quantity}") logging.info(f"DEBUG: Adding meal to tracker - person={person}, date={date_str}, meal_id={meal_id}, meal_time={meal_time}, quantity={quantity}")

View File

@@ -37,9 +37,6 @@
<button class="btn btn-primary" onclick="applyTemplate()"> <button class="btn btn-primary" onclick="applyTemplate()">
<i class="bi bi-upload"></i> Apply Template <i class="bi bi-upload"></i> Apply Template
</button> </button>
<button class="btn btn-info text-white" onclick="addSingleFood()">
<i class="bi bi-plus-circle"></i> Add Single Food
</button>
</div> </div>
<!-- Meal Times --> <!-- Meal Times -->
@@ -69,10 +66,10 @@
{% endif %} {% endif %}
</div> </div>
<div> <div>
<button class="btn btn-sm btn-outline-secondary me-1" onclick="editTrackedMeal({{ tracked_meal.id }})" title="Edit Meal"> <button class="btn btn-sm btn-outline-secondary me-1" onclick="editTrackedMeal('{{ tracked_meal.id }}')" title="Edit Meal">
<i class="bi bi-pencil"></i> <i class="bi bi-pencil"></i>
</button> </button>
<button class="btn btn-sm btn-outline-danger" onclick="removeMeal({{ tracked_meal.id }})"> <button class="btn btn-sm btn-outline-danger" onclick="removeMeal('{{ tracked_meal.id }}')">
<i class="bi bi-trash"></i> <i class="bi bi-trash"></i>
</button> </button>
</div> </div>
@@ -101,9 +98,14 @@
</div> </div>
<!-- Add Meal Button --> <!-- Add Meal Button -->
<button class="btn btn-sm btn-outline-success mt-2" onclick="addMealToTime('{{ meal_time }}')"> <div class="d-flex gap-2 mt-2">
<i class="bi bi-plus"></i> Add Meal <button class="btn btn-sm btn-outline-success" onclick="addMealToTime('{{ meal_time }}')">
</button> <i class="bi bi-plus"></i> Add Meal
</button>
<button class="btn btn-sm btn-info text-white" onclick="addSingleFoodToTime('{{ meal_time }}')">
<i class="bi bi-plus-circle"></i> Add Food
</button>
</div>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
@@ -193,10 +195,6 @@
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
<div class="mb-3">
<label class="form-label">Quantity (multiplier)</label>
<input type="number" step="0.1" class="form-control" name="quantity" value="1.0" min="0.1">
</div>
</form> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
@@ -317,7 +315,7 @@
</select> </select>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label class="form-label">Quantity</label> <label class="form-label">Quantity (g)</label>
<input type="number" step="0.1" class="form-control" name="quantity" value="1.0" min="0.1" required> <input type="number" step="0.1" class="form-control" name="quantity" value="1.0" min="0.1" required>
</div> </div>
<div class="mb-3"> <div class="mb-3">
@@ -637,12 +635,13 @@
}).catch(error => console.error('Error updating quantity:', error)); }).catch(error => console.error('Error updating quantity:', error));
} }
}); });
// Show add single food modal and pre-select meal time
// Show add single food modal function addSingleFoodToTime(mealTime) {
function addSingleFood() { document.querySelector('#addSingleFoodModal select[name="meal_time"]').value = mealTime;
new bootstrap.Modal(document.getElementById('addSingleFoodModal')).show(); new bootstrap.Modal(document.getElementById('addSingleFoodModal')).show();
} }
// Submit add single food form // Submit add single food form
async function submitAddSingleFood() { async function submitAddSingleFood() {
const form = document.getElementById('addSingleFoodForm'); const form = document.getElementById('addSingleFoodForm');

View File

@@ -43,7 +43,7 @@ def client_fixture(session):
def test_detailed_page_no_params(client): def test_detailed_page_no_params(client):
response = client.get("/detailed") response = client.get("/detailed")
assert response.status_code == 200 assert response.status_code == 200
assert "Detailed View for" in response.text assert "Detailed Plan for Sarah" in response.text
def test_detailed_page_default_date(client, session): def test_detailed_page_default_date(client, session):