diff --git a/src/app/components/counter-selection/counter-selection.component.html b/src/app/components/counter-selection/counter-selection.component.html new file mode 100644 index 0000000..dcad043 --- /dev/null +++ b/src/app/components/counter-selection/counter-selection.component.html @@ -0,0 +1,22 @@ + + Kies een teller: + + + Teller + + Geen + @for (player of data.availableCounters; track player.playerId) { + + {{ player.name }} + + } + + + + + + @if (counter) { + Opslaan + } + Annuleren + diff --git a/src/app/components/counter-selection/counter-selection.component.scss b/src/app/components/counter-selection/counter-selection.component.scss new file mode 100644 index 0000000..8a202a9 --- /dev/null +++ b/src/app/components/counter-selection/counter-selection.component.scss @@ -0,0 +1,4 @@ +button:disabled { + cursor: not-allowed; + pointer-events: all !important; +} diff --git a/src/app/components/counter-selection/counter-selection.component.ts b/src/app/components/counter-selection/counter-selection.component.ts new file mode 100644 index 0000000..a2e089d --- /dev/null +++ b/src/app/components/counter-selection/counter-selection.component.ts @@ -0,0 +1,49 @@ +import {Component, inject, Inject} from '@angular/core'; +import { + MAT_DIALOG_DATA, + MatDialogActions, + MatDialogClose, + MatDialogContent, + MatDialogRef +} from "@angular/material/dialog"; +import {Match} from "../../model/match"; +import {MatButton} from "@angular/material/button"; +import {TournamentPlayer} from "../../model/tournamentPlayer"; +import {MatFormField, MatLabel} from "@angular/material/form-field"; +import {MatOption, MatSelect} from "@angular/material/select"; +import {FormsModule} from "@angular/forms"; + +@Component({ + selector: 'app-counter-selection', + imports: [ + MatDialogContent, + MatButton, + MatDialogClose, + MatDialogActions, + MatFormField, + MatLabel, + MatOption, + MatSelect, + FormsModule, + + ], + templateUrl: './counter-selection.component.html', + standalone: true, + styleUrl: './counter-selection.component.scss' +}) +export class CounterSelectionComponent { + + counter: TournamentPlayer; + + readonly dialogRef = inject(MatDialogRef); + + constructor(@Inject(MAT_DIALOG_DATA) public data: { + match: Match, + availableCounters: TournamentPlayer[] + }) {} + + onAnnulerenClick() { + this.dialogRef.close(); + } + +} diff --git a/src/app/components/tournament-manage/tournament-manage.component.html b/src/app/components/tournament-manage/tournament-manage.component.html index 975b8c8..0a5aa60 100644 --- a/src/app/components/tournament-manage/tournament-manage.component.html +++ b/src/app/components/tournament-manage/tournament-manage.component.html @@ -161,6 +161,10 @@ edit Uitslag invoeren + + person + Teller wijzigen + stop Wedstrijd stoppen @@ -329,6 +333,10 @@ edit Uitslag invoeren + + person + Teller + stop Wedstrijd stoppen diff --git a/src/app/components/tournament-manage/tournament-manage.component.ts b/src/app/components/tournament-manage/tournament-manage.component.ts index a946b9f..dee95b2 100644 --- a/src/app/components/tournament-manage/tournament-manage.component.ts +++ b/src/app/components/tournament-manage/tournament-manage.component.ts @@ -35,6 +35,7 @@ import {TournamentPlayersComponent} from "../tournament-players/tournament-playe import {TournamentPlayer} from "../../model/tournamentPlayer"; import {MatTooltip} from "@angular/material/tooltip"; import {TeamDisplayComponent} from "../team-display/team-display.component"; +import {CounterSelectionComponent} from "../counter-selection/counter-selection.component"; @Component({ selector: 'app-tournament-manage', @@ -367,6 +368,7 @@ export class TournamentManageComponent implements OnInit, OnDestroy { matchResultDialog = inject(MatDialog); courtSelectionDialog = inject(MatDialog); + counterSelectionDialog = inject(MatDialog); editResult(match: Match, event: Event, group: Group, round: Round) { this.matchResultDialog.open(MatchResultComponent, { @@ -427,6 +429,23 @@ export class TournamentManageComponent implements OnInit, OnDestroy { return count; } + changeCounter(match: Match) { + this.counterSelectionDialog.open(CounterSelectionComponent, { + data: { + match: match, + availableCounters: this.getAvailableCounters(match) + }, + minWidth: '800px', + minHeight: '250px' + }).afterClosed().subscribe(result => { + if (result != undefined) { + this.tournamentService.updateCounter(this.tournament.id, match.id, result.counter.playerId).subscribe(data => { + this.tournament = data; + }); + } + }); + + } } class ActiveMatch { diff --git a/src/app/service/tournament.service.ts b/src/app/service/tournament.service.ts index 3359544..bdd03b4 100644 --- a/src/app/service/tournament.service.ts +++ b/src/app/service/tournament.service.ts @@ -97,6 +97,10 @@ export class TournamentService { return this.http.post(`${this.tournamentsUrl}/${tournamentId}/players/${playerId}/substitutions`, substitutions) } + public updateCounter(tournamentId: number, matchId: number, counter: number): Observable { + return this.http.patch(`${this.tournamentsUrl}/${tournamentId}/matches/${matchId}/update?counter=${counter}`, null); + } + public addTestData(): Observable { return this.http.get(`${environment.backendUrl}/testdata`); }