feat(MatchReportApiDialog): implement auto-fill for absent players and enhance match side display
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 57s
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 57s
This commit is contained in:
@@ -556,8 +556,8 @@
|
||||
<template v-for="(m, idx) in results" :key="idx">
|
||||
<tr>
|
||||
<td>{{ idx + 1 }}</td>
|
||||
<td>{{ m.homeName }}</td>
|
||||
<td>{{ m.guestName }}</td>
|
||||
<td>{{ displayMatchSide(m.homeName) }}</td>
|
||||
<td>{{ displayMatchSide(m.guestName) }}</td>
|
||||
<td v-for="(s, sIdx) in m.sets" :key="sIdx" class="set-cell">
|
||||
<div class="set-input-wrapper">
|
||||
<input
|
||||
@@ -573,6 +573,10 @@
|
||||
</td>
|
||||
<td class="state-cell">
|
||||
<div class="state-content">
|
||||
<button v-if="!viewOnly && !m.completed && canAutoFillAbsentMatch(m)"
|
||||
class="state-btn absent-player-btn"
|
||||
@click="autoFillAbsentMatch(idx)"
|
||||
title="Nicht anwesend: Begegnung automatisch werten">⚡</button>
|
||||
<button v-if="!viewOnly && !m.completed" class="state-btn" @click="completeMatch(idx)" title="Match abschließen">✔</button>
|
||||
<button v-else-if="!viewOnly" class="state-btn" @click="reopenMatch(idx)" title="Match wieder öffnen">✎</button>
|
||||
<div class="set-ratio">{{ getSetRatio(m) }}</div>
|
||||
@@ -1579,27 +1583,54 @@ Wir wünschen den Spielen einen schönen, spannenden und fairen Verlauf und begr
|
||||
console.log('🔧 Starte Auto-Fill für leere Matches...');
|
||||
|
||||
this.results.forEach((match, index) => {
|
||||
const hasHomePlayer = match.homeName && match.homeName.trim() !== '';
|
||||
const hasGuestPlayer = match.guestName && match.guestName.trim() !== '';
|
||||
const winner = this.getAbsentMatchWinner(match);
|
||||
|
||||
console.log(`🔍 Match ${index + 1}: Heim="${match.homeName}", Gast="${match.guestName}"`);
|
||||
console.log(` hat Heim-Spieler: ${hasHomePlayer}, hat Gast-Spieler: ${hasGuestPlayer}`);
|
||||
|
||||
// Nur wenn genau ein Spieler vorhanden ist (der andere ist leer)
|
||||
if (hasHomePlayer && !hasGuestPlayer) {
|
||||
// Nur bei genau einer anwesenden Seite werten. Sind beide
|
||||
// nicht anwesend, darf keine Begegnung automatisch entstehen.
|
||||
if (winner === 'home') {
|
||||
console.log(`✅ Auto-Fill Match ${index + 1}: Heim ${match.homeName} gewinnt 3:0`);
|
||||
this.autoFillMatch(index, 'home', 3, 0);
|
||||
} else if (!hasHomePlayer && hasGuestPlayer) {
|
||||
} else if (winner === 'guest') {
|
||||
console.log(`✅ Auto-Fill Match ${index + 1}: Gast ${match.guestName} gewinnt 3:0`);
|
||||
this.autoFillMatch(index, 'guest', 0, 3);
|
||||
} else if (!hasHomePlayer && !hasGuestPlayer) {
|
||||
console.log(`⏭️ Match ${index + 1}: Keine Spieler → überspringe`);
|
||||
} else {
|
||||
console.log(`⏭️ Match ${index + 1}: Beide Spieler vorhanden → überspringe`);
|
||||
console.log(`⏭️ Match ${index + 1}: Keine eindeutige anwesende Seite → überspringe`);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
isMatchSidePresent(name) {
|
||||
const normalized = String(name || '').trim().toLocaleLowerCase('de-DE');
|
||||
return normalized !== '' && normalized !== 'nicht anwesend' && normalized !== '—';
|
||||
},
|
||||
|
||||
displayMatchSide(name) {
|
||||
return this.isMatchSidePresent(name) ? name : 'nicht anwesend';
|
||||
},
|
||||
|
||||
getAbsentMatchWinner(match) {
|
||||
const homePresent = this.isMatchSidePresent(match?.homeName);
|
||||
const guestPresent = this.isMatchSidePresent(match?.guestName);
|
||||
if (homePresent === guestPresent) {
|
||||
return null;
|
||||
}
|
||||
return homePresent ? 'home' : 'guest';
|
||||
},
|
||||
|
||||
canAutoFillAbsentMatch(match) {
|
||||
return this.getAbsentMatchWinner(match) !== null;
|
||||
},
|
||||
|
||||
autoFillAbsentMatch(matchIndex) {
|
||||
if (this.viewOnly) return;
|
||||
const winner = this.getAbsentMatchWinner(this.results[matchIndex]);
|
||||
if (winner) {
|
||||
this.autoFillMatch(matchIndex, winner, winner === 'home' ? 3 : 0, winner === 'guest' ? 3 : 0);
|
||||
}
|
||||
},
|
||||
|
||||
autoFillMatch(matchIndex, winner, winnerGames, opponentGames) {
|
||||
if (matchIndex < 0 || matchIndex >= this.results.length) {
|
||||
console.error(`❌ Ungültiger Match-Index: ${matchIndex}`);
|
||||
@@ -1608,8 +1639,11 @@ Wir wünschen den Spielen einen schönen, spannenden und fairen Verlauf und begr
|
||||
|
||||
const match = this.results[matchIndex];
|
||||
|
||||
// Setze 3 x 11:0 Sätze für den Gewinner
|
||||
for (let setIndex = 0; setIndex < 3; setIndex++) {
|
||||
// Best-of-five: Zum Gewinnen sind drei Sätze nötig. Alle
|
||||
// erforderlichen Sätze werden explizit als 11:0 bzw. 0:11
|
||||
// eingetragen, damit die automatische Wertung valide ist.
|
||||
const setsNeededToWin = 3;
|
||||
for (let setIndex = 0; setIndex < setsNeededToWin; setIndex++) {
|
||||
if (winner === 'home') {
|
||||
match.sets[setIndex] = '11:0'; // Heim gewinnt
|
||||
} else {
|
||||
@@ -1617,9 +1651,11 @@ Wir wünschen den Spielen einen schönen, spannenden und fairen Verlauf und begr
|
||||
}
|
||||
}
|
||||
|
||||
// Setze auch Satz 4 und 5 als leer
|
||||
if (match.sets[3] === undefined) match.sets[3] = '';
|
||||
if (match.sets[4] === undefined) match.sets[4] = '';
|
||||
// Frühere Eingaben in nicht benötigten Sätzen dürfen nicht in
|
||||
// einer später automatisch gewerteten Begegnung stehen bleiben.
|
||||
for (let setIndex = setsNeededToWin; setIndex < 5; setIndex++) {
|
||||
match.sets[setIndex] = '';
|
||||
}
|
||||
|
||||
// Berechne Match-Ergebnis neu
|
||||
this.calculateMatchResult(matchIndex);
|
||||
|
||||
Reference in New Issue
Block a user