import { Component, OnInit, Input, ViewChild } from '@angular/core'; import { Tournament, TicketInvite } from 'tournee.businesslogic'; import { TournamentInvitesFormComponent } from '../../forms/tournament-invites-form/tournament-invites-form.component'; import { TournamentTicketsService } from 'src/app/shared/services/tournament.tickets.service'; @Component({ selector: 'app-selectable-listing-invites', templateUrl: './selectable-listing-invites.component.html', styleUrls: ['./selectable-listing-invites.component.css'], providers: [ TournamentTicketsService ] }) export class SelectableListingInvitesComponent implements OnInit { @ViewChild('Form') Form:TournamentInvitesFormComponent; @Input() Tournament: Tournament FormShown: boolean = false; PendingInvites: Array = []; constructor(private _tickets: TournamentTicketsService) { } ngOnInit() { this._tickets.get_invites(this.Tournament.id) .then((result) => [ this.bind(result.result.map((i) => { return new TicketInvite(i); })) ]) } add() { this.FormShown = true; this.Form.initiate(this.Tournament); } hide() { this.FormShown = false; this.Form.reset(); } bind(data: Array) { this.PendingInvites = data; this.hide(); } }