From bf0d5b0935599d64de9642bd71a7b87d7bffe862 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Sat, 29 Nov 2025 00:28:47 +0100 Subject: [PATCH] Refactor TournamentPlacementsTab to use groupedRankingList and improve final placements display - Updated the final placements logic to utilize groupedRankingList for better performance and accuracy. - Enhanced the display of class placements, including handling cases for entries without a class. - Improved the no placements message condition to reflect the new data structure. - Added a new computed method to retrieve player names from entry objects, enhancing clarity in the UI. --- .../tournament/TournamentPlacementsTab.vue | 114 ++++-------------- frontend/src/views/TournamentTab.vue | 1 + 2 files changed, 26 insertions(+), 89 deletions(-) diff --git a/frontend/src/components/tournament/TournamentPlacementsTab.vue b/frontend/src/components/tournament/TournamentPlacementsTab.vue index 6f8f071..a7b5e3c 100644 --- a/frontend/src/components/tournament/TournamentPlacementsTab.vue +++ b/frontend/src/components/tournament/TournamentPlacementsTab.vue @@ -9,13 +9,16 @@ /> -
+

{{ $t('tournaments.finalPlacements') }}

-
+

{{ $t('tournaments.noPlacementsYet') }}

@@ -108,6 +111,10 @@ export default { type: Object, required: true }, + groupedRankingList: { + type: Object, + required: true + }, participants: { type: Array, required: true @@ -125,91 +132,10 @@ export default { 'update:selectedViewClass' ], computed: { - finalPlacements() { - // Extrahiere Endplatzierungen aus den K.O.-Matches - const placements = []; - const finishedMatches = this.knockoutMatches.filter(m => m.isFinished); - - // Finde die Finale-Matches (letzte Runde) - const rounds = [...new Set(finishedMatches.map(m => m.round))]; - if (rounds.length === 0) return []; - - // Sortiere Runden nach Reihenfolge (Finale ist die letzte) - const roundOrder = ['Finale', 'Halbfinale', 'Viertelfinale', 'Achtelfinale']; - rounds.sort((a, b) => { - const aIdx = roundOrder.indexOf(a); - const bIdx = roundOrder.indexOf(b); - if (aIdx === -1 && bIdx === -1) return a.localeCompare(b); - if (aIdx === -1) return 1; - if (bIdx === -1) return -1; - return aIdx - bIdx; - }); - - const finalRound = rounds[rounds.length - 1]; - const finalMatches = finishedMatches.filter(m => m.round === finalRound); - - // Für jedes Finale-Match: Gewinner = Platz 1, Verlierer = Platz 2 - finalMatches.forEach(match => { - const winner = this.getMatchWinner(match); - const loser = this.getMatchLoser(match); - - if (winner) { - placements.push({ - id: `final-${match.id}-winner`, - classId: match.classId, - position: 1, - name: winner, - matchId: match.id - }); - } - if (loser) { - placements.push({ - id: `final-${match.id}-loser`, - classId: match.classId, - position: 2, - name: loser, - matchId: match.id - }); - } - }); - - // Wenn es Halbfinale gibt, finde die Verlierer (Platz 3) - const semiFinalRound = rounds.find(r => r.includes('Halbfinale')); - if (semiFinalRound) { - const semiFinalMatches = finishedMatches.filter(m => m.round === semiFinalRound); - semiFinalMatches.forEach(match => { - const loser = this.getMatchLoser(match); - if (loser) { - placements.push({ - id: `semi-${match.id}-loser`, - classId: match.classId, - position: 3, - name: loser, - matchId: match.id - }); - } - }); - } - - return placements.sort((a, b) => { - if (a.classId !== b.classId) { - const aNum = a.classId || 999999; - const bNum = b.classId || 999999; - return aNum - bNum; - } - return a.position - b.position; - }); - }, finalPlacementsByClass() { - const grouped = {}; - this.finalPlacements.forEach(p => { - const key = p.classId || 'null'; - if (!grouped[key]) { - grouped[key] = []; - } - grouped[key].push(p); - }); - return grouped; + // Verwende die bereits berechnete groupedRankingList aus TournamentTab + // Diese enthält die korrekten Platzierungen basierend auf extendedRankingList oder rankingList + return this.groupedRankingList; }, groupPlacements() { // Extrahiere Gruppenplatzierungen @@ -393,6 +319,16 @@ export default { name1: this.getPlayerName(match.player1, match), name2: this.getPlayerName(match.player2, match) }; + }, + getEntryPlayerName(entry) { + // Die entry hat die Struktur: { position, member, classId } + // member ist ein Member-Objekt mit firstName/lastName direkt + if (entry.member) { + if (entry.member.firstName && entry.member.lastName) { + return `${entry.member.firstName} ${entry.member.lastName}`; + } + } + return this.$t('tournaments.unknown'); } } }; diff --git a/frontend/src/views/TournamentTab.vue b/frontend/src/views/TournamentTab.vue index 03112d9..a9ed556 100644 --- a/frontend/src/views/TournamentTab.vue +++ b/frontend/src/views/TournamentTab.vue @@ -218,6 +218,7 @@ :knockout-matches="knockoutMatches" :groups="groups" :group-rankings="groupRankings" + :grouped-ranking-list="groupedRankingList" :participants="participants" :external-participants="externalParticipants" :pairings="pairings"