@@ -72,13 +72,15 @@ export class BracketsViewer {
72
72
let groupNumber = 1 ;
73
73
74
74
for ( const groupMatches of matchesByGroup ) {
75
- const groupContainer = dom . createGroupContainer ( lang . getGroupName ( groupNumber ++ ) ) ;
75
+ const groupId = groupMatches [ 0 ] . group_id ;
76
+ const groupContainer = dom . createGroupContainer ( groupId , lang . getGroupName ( groupNumber ++ ) ) ;
76
77
const matchesByRound = splitBy ( groupMatches , 'round_id' ) ;
77
78
78
79
let roundNumber = 1 ;
79
80
80
81
for ( const roundMatches of matchesByRound ) {
81
- const roundContainer = dom . createRoundContainer ( lang . getRoundName ( roundNumber ++ , 0 ) ) ;
82
+ const roundId = roundMatches [ 0 ] . round_id ;
83
+ const roundContainer = dom . createRoundContainer ( roundId , lang . getRoundName ( roundNumber ++ , 0 ) ) ;
82
84
83
85
for ( const match of roundMatches )
84
86
roundContainer . append ( this . createMatch ( match ) ) ;
@@ -153,13 +155,15 @@ export class BracketsViewer {
153
155
* @param connectFinal Whether to connect the last match of the bracket to the final.
154
156
*/
155
157
private renderBracket ( root : HTMLElement , matchesByRound : Match [ ] [ ] , roundName : RoundName , bracketType : BracketType , connectFinal ?: boolean ) : void {
156
- const bracketContainer = dom . createBracketContainer ( ) ;
158
+ const groupId = matchesByRound [ 0 ] [ 0 ] . group_id ;
157
159
const roundCount = matchesByRound . length ;
160
+ const bracketContainer = dom . createBracketContainer ( groupId ) ;
158
161
159
162
let roundNumber = 1 ;
160
163
161
164
for ( const matches of matchesByRound ) {
162
- const roundContainer = dom . createRoundContainer ( roundName ( roundNumber , roundCount ) ) ;
165
+ const roundId = matches [ 0 ] . round_id ;
166
+ const roundContainer = dom . createRoundContainer ( roundId , roundName ( roundNumber , roundCount ) ) ;
163
167
164
168
for ( const match of matches )
165
169
roundContainer . append ( this . createBracketMatch ( roundNumber , roundCount , match , bracketType , connectFinal ) ) ;
@@ -187,8 +191,9 @@ export class BracketsViewer {
187
191
188
192
const roundCount = matches . length ;
189
193
190
- for ( let roundNumber = 1 ; roundNumber <= finalMatches . length ; roundNumber ++ ) {
191
- const roundContainer = dom . createRoundContainer ( lang . getFinalMatchLabel ( finalType , roundNumber , roundCount ) ) ;
194
+ for ( let roundIndex = 0 ; roundIndex < finalMatches . length ; roundIndex ++ ) {
195
+ const roundNumber = roundIndex + 1 ;
196
+ const roundContainer = dom . createRoundContainer ( finalMatches [ roundIndex ] . round_id , lang . getFinalMatchLabel ( finalType , roundNumber , roundCount ) ) ;
192
197
roundContainer . append ( this . createFinalMatch ( finalType , finalMatches , roundNumber , roundCount ) ) ;
193
198
upperBracket . append ( roundContainer ) ;
194
199
}
@@ -274,32 +279,32 @@ export class BracketsViewer {
274
279
/**
275
280
* Creates a match based on its results.
276
281
*
277
- * @param results Results of the match.
282
+ * @param match Results of the match.
278
283
* @param matchLocation Location of the match.
279
284
* @param connection Connection of this match with the others.
280
285
* @param label Label of the match.
281
286
* @param originHint Origin hint for the match.
282
287
* @param roundNumber Number of the round.
283
288
*/
284
- private createMatch ( results : MatchResults , matchLocation ?: BracketType , connection ?: Connection , label ?: string , originHint ?: OriginHint , roundNumber ?: number ) : HTMLElement {
285
- const match = dom . createMatchContainer ( ) ;
289
+ private createMatch ( match : MatchResults , matchLocation ?: BracketType , connection ?: Connection , label ?: string , originHint ?: OriginHint , roundNumber ?: number ) : HTMLElement {
290
+ const matchContainer = dom . createMatchContainer ( match . id ) ;
286
291
const opponents = dom . createOpponentsContainer ( ) ;
287
292
288
- const team1 = this . createTeam ( results . opponent1 , originHint , matchLocation , roundNumber ) ;
289
- const team2 = this . createTeam ( results . opponent2 , originHint , matchLocation , roundNumber ) ;
293
+ const team1 = this . createTeam ( match . opponent1 , originHint , matchLocation , roundNumber ) ;
294
+ const team2 = this . createTeam ( match . opponent2 , originHint , matchLocation , roundNumber ) ;
290
295
291
296
if ( label )
292
- opponents . append ( dom . createMatchLabel ( label , lang . getMatchStatus ( results . status ) ) ) ;
297
+ opponents . append ( dom . createMatchLabel ( label , lang . getMatchStatus ( match . status ) ) ) ;
293
298
294
299
opponents . append ( team1 , team2 ) ;
295
- match . append ( opponents ) ;
300
+ matchContainer . append ( opponents ) ;
296
301
297
302
if ( ! connection )
298
- return match ;
303
+ return matchContainer ;
299
304
300
- dom . setupConnection ( opponents , match , connection ) ;
305
+ dom . setupConnection ( opponents , matchContainer , connection ) ;
301
306
302
- return match ;
307
+ return matchContainer ;
303
308
}
304
309
305
310
/**
@@ -312,7 +317,7 @@ export class BracketsViewer {
312
317
*/
313
318
private createTeam ( participant : ParticipantResult | null , originHint : OriginHint , matchLocation ?: BracketType , roundNumber ?: number ) : HTMLElement {
314
319
const containers : ParticipantContainers = {
315
- participant : dom . createParticipantContainer ( ) ,
320
+ participant : dom . createParticipantContainer ( participant && participant . id ) ,
316
321
name : dom . createNameContainer ( ) ,
317
322
result : dom . createResultContainer ( ) ,
318
323
} ;
0 commit comments