feat: enable updating time from a food entry

- Add visible time input (foodEntryTime) in index.html, hidden by default
- Show time input only when editing a food entry (setFoodToEdit)
- Use foodEntryTime value when saving an edited entry (updateFood)
- Hide and reset time input on clearEditing (cancel/save)
- input type=time ensures HH:MM format is preserved

Agent-Logs-Url: https://github.com/RMCampos/calories-tracker/sessions/085efbe7-b9c8-4a81-a58f-5dbdf91f2942

Co-authored-by: RMCampos <2219519+RMCampos@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-27 19:20:15 +00:00
committed by GitHub
parent b07861f88f
commit e4fa1f9c1c
3 changed files with 13 additions and 287 deletions
+9 -1
View File
@@ -429,6 +429,10 @@ function clearEditing() {
getInputById('foodTimeToUpdate').value = '';
getInputById('foodCaloriesToUpdate').value = '';
// Hide and reset the visible time input (only shown when editing)
getInputById('foodEntryTime').value = '';
getDivById('foodTimeGroup').classList.add('hidden');
selectedFood = null;
}
@@ -1048,6 +1052,10 @@ async function setFoodToEdit(foodId: string) {
getInputById('foodTimeToUpdate').value = foodToEdit[0].time;
getInputById('foodCaloriesToUpdate').value = foodToEdit[0].calories;
// Show the time input and populate it with the existing time
getDivById('foodTimeGroup').classList.remove('hidden');
getInputById('foodEntryTime').value = foodToEdit[0].time;
// Scroll to top
const titleDiv = getDivById('add-foot-title') as HTMLElement;
if (titleDiv) {
@@ -1228,7 +1236,7 @@ const updateFood = async () => {
fiber: proportion.info.fiber,
date: date.split('T')[0],
alkaline: selectedFood.info.alkaline,
time: getInputById('foodTimeToUpdate').value,
time: getInputById('foodEntryTime').value,
};
// Save to Appwrite