From 2b06a8dd10c0485ffe49914bc4be320bcbfd8f04 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Thu, 13 Nov 2025 18:18:31 +0100 Subject: [PATCH] Enhance participant update handling and UI responsiveness in DiaryView This commit improves the participant update process by ensuring the latest participant data is fetched from the database before emitting socket events. It also refines the DiaryView component's UI, adding better handling for dropdowns and member group selections, enhancing user experience. Additionally, new CSS styles are introduced for member group select elements to ensure consistent appearance across browsers. --- backend/controllers/participantController.js | 22 ++- backend/services/socketService.js | 1 + frontend/src/services/socketService.js | 7 +- frontend/src/views/DiaryView.vue | 188 ++++++++++++++----- 4 files changed, 166 insertions(+), 52 deletions(-) diff --git a/backend/controllers/participantController.js b/backend/controllers/participantController.js index 0469a78..c06d1e9 100644 --- a/backend/controllers/participantController.js +++ b/backend/controllers/participantController.js @@ -40,12 +40,26 @@ export const updateParticipantGroup = async (req, res) => { participant.groupId = groupId || null; await participant.save(); - // Emit Socket-Event - if (participant.diaryDate?.clubId) { - emitParticipantUpdated(participant.diaryDate.clubId, dateId, participant); + // Lade den Participant erneut aus der DB, um sicherzustellen, dass wir den aktuellen Wert haben + const updatedParticipant = await Participant.findOne({ + where: { + diaryDateId: dateId, + memberId: memberId + }, + include: [{ + model: DiaryDates, + as: 'diaryDate', + attributes: ['clubId'] + }] + }); + + // Emit Socket-Event mit dem aktualisierten Participant + if (updatedParticipant?.diaryDate?.clubId) { + console.log('📡 [Backend] Emit participant:updated mit groupId:', updatedParticipant.groupId); + emitParticipantUpdated(updatedParticipant.diaryDate.clubId, dateId, updatedParticipant); } - res.status(200).json(participant); + res.status(200).json(updatedParticipant || participant); } catch (error) { devLog(error); res.status(500).json({ error: 'Fehler beim Aktualisieren der Teilnehmer-Gruppenzuordnung' }); diff --git a/backend/services/socketService.js b/backend/services/socketService.js index a1e0238..0defb3b 100644 --- a/backend/services/socketService.js +++ b/backend/services/socketService.js @@ -64,6 +64,7 @@ export const emitParticipantRemoved = (clubId, dateId, participantId) => { }; export const emitParticipantUpdated = (clubId, dateId, participant) => { + console.log('📡 [Socket] Emit participant:updated für Club', clubId, 'Date', dateId, 'Participant:', participant); emitToClub(clubId, 'participant:updated', { dateId, participant }); }; diff --git a/frontend/src/services/socketService.js b/frontend/src/services/socketService.js index 2a3574a..f6fea2a 100644 --- a/frontend/src/services/socketService.js +++ b/frontend/src/services/socketService.js @@ -77,7 +77,12 @@ export const onParticipantRemoved = (callback) => { export const onParticipantUpdated = (callback) => { if (socket) { - socket.on('participant:updated', callback); + socket.on('participant:updated', (data) => { + console.log('📡 [Socket] participant:updated empfangen:', data); + callback(data); + }); + } else { + console.warn('⚠️ [Socket] onParticipantUpdated: Socket nicht verbunden'); } }; diff --git a/frontend/src/views/DiaryView.vue b/frontend/src/views/DiaryView.vue index fba8e7e..d96c54b 100644 --- a/frontend/src/views/DiaryView.vue +++ b/frontend/src/views/DiaryView.vue @@ -189,37 +189,39 @@ - - - -