From 46812a0c14fcd79e687a47402ab85b22e04d4a1e Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Tue, 17 Mar 2026 14:54:47 +0100 Subject: [PATCH] fix(DiaryView): improve drag-and-drop item reordering logic - Updated the drag-and-drop functionality to correctly handle item indices during reordering, ensuring accurate updates to the training plan. - Enhanced error handling by loading the training plan after a successful reorder, improving user experience and stability. --- frontend/src/views/DiaryView.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/DiaryView.vue b/frontend/src/views/DiaryView.vue index 6e8ba38a..9b64cfd7 100644 --- a/frontend/src/views/DiaryView.vue +++ b/frontend/src/views/DiaryView.vue @@ -2242,15 +2242,17 @@ export default { } }, async onDragEnd(evt) { - const movedItem = this.trainingPlan[evt.oldIndex]; + const oldIndex = Number.isInteger(evt.oldDraggableIndex) ? evt.oldDraggableIndex : evt.oldIndex; + const newIndex = Number.isInteger(evt.newDraggableIndex) ? evt.newDraggableIndex : evt.newIndex; + const movedItem = this.trainingPlan[oldIndex]; if (!movedItem) { return; } try { await apiClient.put(`/diary-date-activities/${this.currentClub}/${movedItem.id}/order`, { - orderId: evt.newIndex + orderId: newIndex + 1 }); - this.recalculateTimes(); + await this.loadTrainingPlan(); } catch (error) { this.showInfo(this.$t('messages.error'), this.$t('diary.errorOccurred'), '', 'error'); }