feat(TournamentTab): improve knockout section handling and data validation

- Refactored stages and advancements data retrieval to ensure proper handling of empty or invalid responses.
- Added scrollToKnockoutSection method to enhance user experience by automatically scrolling to the knockout section after initiating tournament actions.
- Updated knockout operation flow to include scrolling behavior, ensuring better visibility of the knockout stage during tournament management.
This commit is contained in:
Torsten Schulz (local)
2026-03-28 11:20:34 +01:00
parent 2c11f6b975
commit 92d29dc64e

View File

@@ -2644,8 +2644,9 @@ export default {
}
});
const stages = stagesRes?.data?.stages;
if (Array.isArray(stages) && stages.length > 0) {
const stages = Array.isArray(stagesRes?.data?.stages) ? stagesRes.data.stages : [];
const advancements = Array.isArray(stagesRes?.data?.advancements) ? stagesRes.data.advancements : [];
if (stages.length > 0 && advancements.length > 0) {
const normalizedStages = stages
.map(s => ({
...s,
@@ -2680,6 +2681,7 @@ export default {
if ((stage.type || stage.targetType || stage.target) === 'knockout') {
await this.loadTournamentData();
await this.scrollToKnockoutSection();
return;
}
@@ -2696,6 +2698,7 @@ export default {
tournamentId: this.selectedDate
});
await this.loadTournamentData();
await this.scrollToKnockoutSection();
} catch (error) {
console.error('Fehler beim Starten der K.o.-Runde:', error);
await this.showInfo(
@@ -2708,6 +2711,21 @@ export default {
this.knockoutOperationInProgress = false;
}
},
async scrollToKnockoutSection() {
await this.$nextTick();
window.setTimeout(() => {
const knockoutSection = document.querySelector('.ko-round');
if (knockoutSection && typeof knockoutSection.scrollIntoView === 'function') {
knockoutSection.scrollIntoView({ behavior: 'smooth', block: 'start' });
return;
}
const placementsSection = document.querySelector('.ranking');
if (placementsSection && typeof placementsSection.scrollIntoView === 'function') {
placementsSection.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}, 120);
},
formatResult(match) {
if (!match.tournamentResults?.length) return '-';