Made tournament-players more standalone, now works from tournament screen
This commit is contained in:
@@ -2,14 +2,13 @@ import {Component, inject, Input, OnInit} from '@angular/core';
|
|||||||
import {CurrencyPipe} from "@angular/common";
|
import {CurrencyPipe} from "@angular/common";
|
||||||
import {MatSlideToggle, MatSlideToggleChange} from "@angular/material/slide-toggle";
|
import {MatSlideToggle, MatSlideToggleChange} from "@angular/material/slide-toggle";
|
||||||
import {TournamentService} from "../../service/tournament.service";
|
import {TournamentService} from "../../service/tournament.service";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute} from "@angular/router";
|
||||||
import {Tournament} from "../../model/tournament";
|
import {Tournament} from "../../model/tournament";
|
||||||
import {FormsModule} from "@angular/forms";
|
import {FormsModule} from "@angular/forms";
|
||||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||||
import {MatIcon} from "@angular/material/icon";
|
import {MatIcon} from "@angular/material/icon";
|
||||||
import {MatIconButton} from "@angular/material/button";
|
import {MatIconButton} from "@angular/material/button";
|
||||||
import {MatMenu, MatMenuItem, MatMenuTrigger} from "@angular/material/menu";
|
import {MatMenu, MatMenuItem, MatMenuTrigger} from "@angular/material/menu";
|
||||||
import {CourtSelectionComponent} from "../court-selection/court-selection.component";
|
|
||||||
import {MatDialog} from "@angular/material/dialog";
|
import {MatDialog} from "@angular/material/dialog";
|
||||||
import {SubstituteSelectionComponent} from "../substitute-selection/substitute-selection.component";
|
import {SubstituteSelectionComponent} from "../substitute-selection/substitute-selection.component";
|
||||||
import {TournamentPlayer} from "../../model/tournamentPlayer";
|
import {TournamentPlayer} from "../../model/tournamentPlayer";
|
||||||
@@ -34,15 +33,27 @@ import {MatTab, MatTabGroup, MatTabLabel} from "@angular/material/tabs";
|
|||||||
standalone: true,
|
standalone: true,
|
||||||
styleUrl: './tournament-players.component.scss'
|
styleUrl: './tournament-players.component.scss'
|
||||||
})
|
})
|
||||||
export class TournamentPlayersComponent {
|
export class TournamentPlayersComponent implements OnInit {
|
||||||
|
|
||||||
@Input() tournament: Tournament;
|
@Input() tournament: Tournament;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private tournamentService: TournamentService,
|
private tournamentService: TournamentService,
|
||||||
|
private route: ActivatedRoute,
|
||||||
private _snackBar: MatSnackBar,
|
private _snackBar: MatSnackBar,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
if (!this.tournament) {
|
||||||
|
const id = Number(this.route.snapshot.paramMap.get('id'));
|
||||||
|
if (id) {
|
||||||
|
this.tournamentService.getById(Number(id)).subscribe(data => {
|
||||||
|
this.tournament = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
playerPaid($event: MatSlideToggleChange, playerId: number) {
|
playerPaid($event: MatSlideToggleChange, playerId: number) {
|
||||||
this.tournamentService.playerPaid(this.tournament.id, playerId, $event.checked).subscribe(() => {
|
this.tournamentService.playerPaid(this.tournament.id, playerId, $event.checked).subscribe(() => {
|
||||||
this._snackBar.open('Opgeslagen.');
|
this._snackBar.open('Opgeslagen.');
|
||||||
|
|||||||
Reference in New Issue
Block a user