import { Component, OnInit, Input } from '@angular/core'; import { AuthService } from 'src/app/shared/services/auth.service'; import { UtilityService } from 'src/app/shared/services/utility.service'; import { AttendeeTournamentView, TournamentTicketSlice } from 'tournee.businesslogic'; @Component({ selector: 'app-tournament-viewer', templateUrl: './tournament-viewer.component.html', styleUrls: ['./tournament-viewer.component.css'] }) export class TournamentViewerComponent implements OnInit { @Input() Tournament: AttendeeTournamentView; @Input() Url: string; @Input() UseBranding: boolean = false; TicketRows: Array> = [] constructor(public auth: AuthService, public utility: UtilityService) { } ngOnInit() { this.split_tickets_into_rows(); } split_tickets_into_rows() { this.TicketRows.push([]); for (let i = 0; i < this.Tournament.tickets.length; i++) { const ticket = this.Tournament.tickets[i]; if (this.TicketRows[this.TicketRows.length -1].length == 3) { this.TicketRows.push([]); } this.TicketRows[this.TicketRows.length -1].push(ticket); } } CalculatedRowWidth() { if (this.TicketRows.length > 0) { if (this.TicketRows.length == 1) { const first = this.TicketRows[0]; if (first.length == 1) { return "col"; } else if (first.length == 2) { return "col-sm-6"; } else { return "col-sm-4"; } } else { return "col-sm-4"; } } } }