diff --git a/src/views/Entries.vue b/src/views/Entries.vue index 45c53bc..7e9dd0d 100644 --- a/src/views/Entries.vue +++ b/src/views/Entries.vue @@ -122,10 +122,10 @@
-
+

Edit Entry

@@ -163,14 +163,34 @@ />
- +
- - + +
+
+ +
+
+ + : + +
+
@@ -256,6 +276,11 @@ const editForm = reactive({ duration: 0 }) +// Split date/time refs for edit dialog +const editDate = ref('') +const editHour = ref(0) +const editMinute = ref(0) + // Duration in minutes (computed for editing) const durationMinutes = computed({ get: () => Math.round(editForm.duration / 60), @@ -336,8 +361,17 @@ function openEditDialog(entry: TimeEntry) { editForm.id = entry.id || 0 editForm.project_id = entry.project_id editForm.description = entry.description || '' - editForm.start_time = entry.start_time.slice(0, 16) // Format for datetime-local editForm.duration = entry.duration + + // Split start_time into date and time parts + const dt = new Date(entry.start_time) + const y = dt.getFullYear() + const m = String(dt.getMonth() + 1).padStart(2, '0') + const d = String(dt.getDate()).padStart(2, '0') + editDate.value = `${y}-${m}-${d}` + editHour.value = dt.getHours() + editMinute.value = dt.getMinutes() + showEditDialog.value = true } @@ -350,8 +384,9 @@ function closeEditDialog() { // Handle edit submit async function handleEdit() { if (editingEntry.value) { - // Recalculate end_time based on duration - const start = new Date(editForm.start_time) + // Reconstruct start time from split date/time fields + const [y, m, d] = editDate.value.split('-').map(Number) + const start = new Date(y, m - 1, d, editHour.value, editMinute.value) const end = new Date(start.getTime() + editForm.duration * 1000) const updatedEntry: TimeEntry = {