diff --git a/tournaments/templates/tournaments/broadcast/broadcasted_planning.html b/tournaments/templates/tournaments/broadcast/broadcasted_planning.html index be0215b..00f2385 100644 --- a/tournaments/templates/tournaments/broadcast/broadcasted_planning.html +++ b/tournaments/templates/tournaments/broadcast/broadcasted_planning.html @@ -194,17 +194,27 @@ // Rearrange groups in vertical order if (columns === 2) { - const rearrangedGroups = []; - const halfPageLength = Math.ceil(pageGroups.length / 2); - // Create groups with alternating order: [0, halfPageLength, 1, halfPageLength+1, ...] - for (let col = 0; col < halfPageLength; col++) { - rearrangedGroups.push(pageGroups[col]); // First column - if (col + halfPageLength < pageGroups.length) { - rearrangedGroups.push(pageGroups[col + halfPageLength]); // Second column + if (this.courtCount < 5 && pageGroups.length < groupsPerPageThreshold / 2) { + const pageLength = pageGroups.length; + const rearrangedGroups = new Array(pageGroups.length); + for (let col = 0; col < pageLength; col++) { + rearrangedGroups[col * 2] = pageGroups[col]; // First column: indices 0, 2, 4, etc. } + paginatedGroups.push(rearrangedGroups); + } else { + const rearrangedGroups = []; + const halfPageLength = Math.ceil(pageGroups.length / 2); + + // Create groups with alternating order: [0, halfPageLength, 1, halfPageLength+1, ...] + for (let col = 0; col < halfPageLength; col++) { + rearrangedGroups.push(pageGroups[col]); // First column + if (col + halfPageLength < pageGroups.length) { + rearrangedGroups.push(pageGroups[col + halfPageLength]); // Second column + } + } + paginatedGroups.push(rearrangedGroups); } - paginatedGroups.push(rearrangedGroups); } else { paginatedGroups.push(pageGroups); } @@ -217,7 +227,11 @@ return courtIndex; }, - organizeMatchesByCourt(matches) { + organizeMatchesByCourt(group) { + if (!group || !group.matches) { + return Array(this.courtCount).fill(null); + } + const matches = group.matches; const courtMatches = Array(this.courtCount).fill(null); if (matches && matches.length > 0) { matches.forEach(match => { @@ -326,11 +340,11 @@