Compare commits
10 Commits
368aa53b9d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 87d9291bfb | |||
| c646ae15ee | |||
|
|
8128ba4744 | ||
|
|
19e4372006 | ||
|
|
7fd84005f9 | ||
|
|
a56317fecd | ||
|
|
ecbb16776c | ||
|
|
3008f45dfa | ||
|
|
5baf1228f7 | ||
|
|
aacf06e203 |
@@ -0,0 +1,22 @@
|
|||||||
|
<mat-dialog-content>
|
||||||
|
<h3>Kies een teller:</h3>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<mat-form-field appearance="fill">
|
||||||
|
<mat-label>Teller</mat-label>
|
||||||
|
<mat-select [(ngModel)]="counter">
|
||||||
|
<mat-option>Geen</mat-option>
|
||||||
|
@for (player of data.availableCounters; track player.playerId) {
|
||||||
|
<mat-option [value]="player">
|
||||||
|
{{ player.name }}
|
||||||
|
</mat-option>
|
||||||
|
}
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
</mat-dialog-content>
|
||||||
|
<mat-dialog-actions>
|
||||||
|
@if (counter) {
|
||||||
|
<button mat-button [mat-dialog-close]="{counter: counter}">Opslaan</button>
|
||||||
|
}
|
||||||
|
<button mat-button (click)="onAnnulerenClick()">Annuleren</button>
|
||||||
|
</mat-dialog-actions>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
button:disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
pointer-events: all !important;
|
||||||
|
}
|
||||||
@@ -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<CounterSelectionComponent>);
|
||||||
|
|
||||||
|
constructor(@Inject(MAT_DIALOG_DATA) public data: {
|
||||||
|
match: Match,
|
||||||
|
availableCounters: TournamentPlayer[]
|
||||||
|
}) {}
|
||||||
|
|
||||||
|
onAnnulerenClick() {
|
||||||
|
this.dialogRef.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
[team]="data.match.team1"
|
[team]="data.match.team1"
|
||||||
[event]="data.event"
|
[event]="data.event"
|
||||||
[tournament]="data.tournament"
|
[tournament]="data.tournament"
|
||||||
[inline]="true">
|
[inline]="false">
|
||||||
</app-team-display>
|
</app-team-display>
|
||||||
</div>
|
</div>
|
||||||
</mat-grid-tile>
|
</mat-grid-tile>
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
[team]="data.match.team2"
|
[team]="data.match.team2"
|
||||||
[event]="data.event"
|
[event]="data.event"
|
||||||
[tournament]="data.tournament"
|
[tournament]="data.tournament"
|
||||||
[inline]="true">
|
[inline]="false">
|
||||||
</app-team-display>
|
</app-team-display>
|
||||||
</div>
|
</div>
|
||||||
</mat-grid-tile>
|
</mat-grid-tile>
|
||||||
|
|||||||
@@ -12,15 +12,24 @@ import {MatTooltip} from '@angular/material/tooltip';
|
|||||||
styleUrls: ['./player-display.component.scss'],
|
styleUrls: ['./player-display.component.scss'],
|
||||||
template: `
|
template: `
|
||||||
@let substitute = getSubstituteForEvent(player, event);
|
@let substitute = getSubstituteForEvent(player, event);
|
||||||
<span [class.has-substitute]="substitute"
|
@if (exlicitSubstitute) {
|
||||||
[matTooltip]="substitute ? 'Valt in voor ' + (player | fullName) : ''"
|
@if (substitute) {
|
||||||
matTooltipPosition="below">{{ substitute || (player | fullName) }}</span>
|
{{ substitute }} (valt in voor {{ player | fullName }})
|
||||||
|
} @else {
|
||||||
|
{{ player | fullName }}
|
||||||
|
}
|
||||||
|
} @else {
|
||||||
|
<span [class.has-substitute]="substitute"
|
||||||
|
[matTooltip]="substitute ? 'Valt in voor ' + (player | fullName) : ''"
|
||||||
|
matTooltipPosition="below">{{ substitute || (player | fullName) }}</span>
|
||||||
|
}
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class PlayerDisplayComponent {
|
export class PlayerDisplayComponent {
|
||||||
@Input({ required: true }) player!: Player;
|
@Input({ required: true }) player!: Player;
|
||||||
@Input({ required: true }) event!: Event;
|
@Input({ required: true }) event!: Event;
|
||||||
@Input({ required: true }) tournament!: Tournament;
|
@Input({ required: true }) tournament!: Tournament;
|
||||||
|
@Input({ required: false }) exlicitSubstitute: boolean = false;
|
||||||
|
|
||||||
getSubstituteForEvent(player: Player, event: Event): string | undefined {
|
getSubstituteForEvent(player: Player, event: Event): string | undefined {
|
||||||
const tournamentPlayer = this.tournament.tournamentPlayers.find(
|
const tournamentPlayer = this.tournament.tournamentPlayers.find(
|
||||||
|
|||||||
@@ -39,7 +39,8 @@
|
|||||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
</table>
|
</table>
|
||||||
<mat-paginator [pageSizeOptions]="[10, 20, 50]"
|
<mat-paginator [pageSizeOptions]="[10, 25, 100]"
|
||||||
|
[pageSize]="100"
|
||||||
showFirstLastButtons
|
showFirstLastButtons
|
||||||
aria-label="Select page of periodic elements">
|
aria-label="Select page of periodic elements">
|
||||||
</mat-paginator>
|
</mat-paginator>
|
||||||
|
|||||||
@@ -5,3 +5,7 @@ a {
|
|||||||
td, th {
|
td, th {
|
||||||
background-color: transparent !important;
|
background-color: transparent !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mat-mdc-row:hover {
|
||||||
|
background-color: rgba(0, 0, 0, 0.075);
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,14 +18,23 @@
|
|||||||
@if (eventRegistration.doublesEvent) {
|
@if (eventRegistration.doublesEvent) {
|
||||||
<mat-form-field appearance="fill">
|
<mat-form-field appearance="fill">
|
||||||
<mat-label>Partner</mat-label>
|
<mat-label>Partner</mat-label>
|
||||||
<mat-select [value]="eventRegistration.partner" [disabled]="!tournamentRegistration.editable || !eventRegistration.registered" [(ngModel)]="eventRegistration.partner">
|
<input type="text"
|
||||||
<mat-option>Geen</mat-option>
|
matInput
|
||||||
@for (player of getRelevantPlayers(eventRegistration.type); track player.id) {
|
[matAutocomplete]="auto"
|
||||||
|
[disabled]="!tournamentRegistration.editable || !eventRegistration.registered"
|
||||||
|
[(ngModel)]="eventRegistration.partner"
|
||||||
|
(input)="onPartnerSearch($any($event.target).value, eventRegistration)"
|
||||||
|
[name]="'partner-' + eventRegistration.id">
|
||||||
|
<mat-autocomplete #auto="matAutocomplete"
|
||||||
|
[displayWith]="displayPartnerName.bind(this)"
|
||||||
|
(optionSelected)="onPartnerSelected($event, eventRegistration)">
|
||||||
|
<mat-option [value]="null">Geen</mat-option>
|
||||||
|
@for (player of getFilteredPlayers(eventRegistration); track player.id) {
|
||||||
<mat-option [value]="player.id">
|
<mat-option [value]="player.id">
|
||||||
{{ player | fullName }}
|
{{ player | fullName }}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
}
|
}
|
||||||
</mat-select>
|
</mat-autocomplete>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,12 +9,13 @@ import {RegistrationService} from "../../service/registration.service";
|
|||||||
import {MatCheckbox, MatCheckboxChange} from "@angular/material/checkbox";
|
import {MatCheckbox, MatCheckboxChange} from "@angular/material/checkbox";
|
||||||
import {EventRegistration, TournamentRegistration} from "../../model/tournamentRegistration";
|
import {EventRegistration, TournamentRegistration} from "../../model/tournamentRegistration";
|
||||||
import {MatOption} from "@angular/material/core";
|
import {MatOption} from "@angular/material/core";
|
||||||
import {MatSelect} from "@angular/material/select";
|
|
||||||
import {MatIcon} from "@angular/material/icon";
|
import {MatIcon} from "@angular/material/icon";
|
||||||
import {MatAnchor, MatButton} from "@angular/material/button";
|
import {MatAnchor, MatButton} from "@angular/material/button";
|
||||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||||
import {FullNamePipe} from "../../pipes/fullname-pipe";
|
import {FullNamePipe} from "../../pipes/fullname-pipe";
|
||||||
import {HeaderService} from "../../service/header.service";
|
import {HeaderService} from "../../service/header.service";
|
||||||
|
import {MatAutocomplete, MatAutocompleteTrigger} from "@angular/material/autocomplete";
|
||||||
|
import {MatInput} from "@angular/material/input";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-player-registrations',
|
selector: 'app-player-registrations',
|
||||||
@@ -30,11 +31,14 @@ import {HeaderService} from "../../service/header.service";
|
|||||||
MatCardActions,
|
MatCardActions,
|
||||||
RouterLink,
|
RouterLink,
|
||||||
MatOption,
|
MatOption,
|
||||||
MatSelect,
|
// MatSelect,
|
||||||
MatIcon,
|
MatIcon,
|
||||||
MatButton,
|
MatButton,
|
||||||
MatAnchor,
|
MatAnchor,
|
||||||
FullNamePipe
|
FullNamePipe,
|
||||||
|
MatAutocomplete,
|
||||||
|
MatAutocompleteTrigger,
|
||||||
|
MatInput,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
FullNamePipe
|
FullNamePipe
|
||||||
@@ -52,6 +56,8 @@ export class PlayerRegistrationsComponent implements OnInit {
|
|||||||
|
|
||||||
waitingForBackend: boolean = false;
|
waitingForBackend: boolean = false;
|
||||||
|
|
||||||
|
private partnerSearchTerms: Map<number, string> = new Map();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _snackBar: MatSnackBar,
|
private _snackBar: MatSnackBar,
|
||||||
private playerService: PlayerService,
|
private playerService: PlayerService,
|
||||||
@@ -76,6 +82,40 @@ export class PlayerRegistrationsComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPartnerSearch(searchTerm: any, eventRegistration: EventRegistration) {
|
||||||
|
// Only treat as search if it's a string (typed input)
|
||||||
|
if (typeof searchTerm === 'string') {
|
||||||
|
this.partnerSearchTerms.set(eventRegistration.id, searchTerm?.toLowerCase() || '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getFilteredPlayers(eventRegistration: EventRegistration): Player[] {
|
||||||
|
const allRelevant = this.getRelevantPlayers(eventRegistration.type);
|
||||||
|
const searchTerm = this.partnerSearchTerms.get(eventRegistration.id);
|
||||||
|
|
||||||
|
if (!searchTerm) {
|
||||||
|
return allRelevant;
|
||||||
|
}
|
||||||
|
|
||||||
|
return allRelevant.filter(player => {
|
||||||
|
const fullName = this.fullNamePipe.transform(player).toLowerCase();
|
||||||
|
return fullName.includes(searchTerm);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
displayPartnerName(playerId: number | null): string {
|
||||||
|
if (!playerId || !this.allPlayers) return '';
|
||||||
|
const player = this.allPlayers.find(p => p.id === playerId);
|
||||||
|
return player ? this.fullNamePipe.transform(player) : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
onPartnerSelected(event: any, eventRegistration: EventRegistration) {
|
||||||
|
eventRegistration.partner = event.option.value;
|
||||||
|
// Clear the search term when a partner is selected
|
||||||
|
this.partnerSearchTerms.delete(eventRegistration.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
saveRegistration(tournamentRegistration: TournamentRegistration, event: MouseEvent) {
|
saveRegistration(tournamentRegistration: TournamentRegistration, event: MouseEvent) {
|
||||||
this.waitingForBackend = true;
|
this.waitingForBackend = true;
|
||||||
this.registrationService.saveTournamentRegistrations(tournamentRegistration, this.player.id).subscribe(data => {
|
this.registrationService.saveTournamentRegistrations(tournamentRegistration, this.player.id).subscribe(data => {
|
||||||
|
|||||||
@@ -108,7 +108,8 @@
|
|||||||
[team]="entry.team"
|
[team]="entry.team"
|
||||||
[event]="this.event"
|
[event]="this.event"
|
||||||
[tournament]="this.tournament"
|
[tournament]="this.tournament"
|
||||||
[inline]="true">
|
[inline]="true"
|
||||||
|
[explicitSubstitute]="true">
|
||||||
</app-team-display>
|
</app-team-display>
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle">{{ entry.played }}</td>
|
<td class="align-middle">{{ entry.played }}</td>
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ import {Team} from "../../model/team";
|
|||||||
<app-player-display
|
<app-player-display
|
||||||
[player]="team.player1"
|
[player]="team.player1"
|
||||||
[event]="event"
|
[event]="event"
|
||||||
[tournament]="tournament">
|
[tournament]="tournament"
|
||||||
|
[exlicitSubstitute]="explicitSubstitute">
|
||||||
</app-player-display>
|
</app-player-display>
|
||||||
|
|
||||||
@if (event.doublesEvent && team.player2) {
|
@if (event.doublesEvent && team.player2) {
|
||||||
@@ -34,4 +35,5 @@ export class TeamDisplayComponent {
|
|||||||
@Input({ required: true }) event!: Event;
|
@Input({ required: true }) event!: Event;
|
||||||
@Input({ required: true }) tournament!: Tournament;
|
@Input({ required: true }) tournament!: Tournament;
|
||||||
@Input({ required: false }) inline: boolean = true;
|
@Input({ required: false }) inline: boolean = true;
|
||||||
|
@Input({ required: false }) explicitSubstitute: boolean = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,9 +158,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<mat-action-row>
|
<mat-action-row>
|
||||||
<button class="align-baseline" mat-button (click)="editResult(activeMatch.match, activeMatch.event, activeMatch.group, activeMatch.round)">
|
<button class="align-baseline" mat-button (click)="editResult(activeMatch.match, activeMatch.event, activeMatch.group, activeMatch.round)">
|
||||||
<mat-icon>edit</mat-icon>
|
<mat-icon>leaderboard</mat-icon>
|
||||||
Uitslag invoeren
|
Uitslag invoeren
|
||||||
</button>
|
</button>
|
||||||
|
<button mat-button (click)="changeCounter(activeMatch.match)">
|
||||||
|
<mat-icon>person</mat-icon>
|
||||||
|
Teller wijzigen
|
||||||
|
</button>
|
||||||
<button mat-button (click)="stopMatch(activeMatch.match)">
|
<button mat-button (click)="stopMatch(activeMatch.match)">
|
||||||
<mat-icon>stop</mat-icon>
|
<mat-icon>stop</mat-icon>
|
||||||
Wedstrijd stoppen
|
Wedstrijd stoppen
|
||||||
@@ -297,7 +301,6 @@
|
|||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<!-- }-->
|
|
||||||
} @else if (round.status == 'IN_PROGRESS') {
|
} @else if (round.status == 'IN_PROGRESS') {
|
||||||
<table class="table table-hover m-4 wide w-95">
|
<table class="table table-hover m-4 wide w-95">
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -320,18 +323,31 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="align-middle w-fill">
|
<td class="align-middle w-fill">
|
||||||
@if (match.status == 'NOT_STARTED') {
|
@if (match.status == 'NOT_STARTED') {
|
||||||
<button mat-button (click)="startMatch(match)">
|
@if (match.canStart) {
|
||||||
<mat-icon>play_arrow</mat-icon>
|
<button mat-button (click)="startMatch(match)">
|
||||||
Wedstrijd starten
|
<mat-icon>play_arrow</mat-icon>
|
||||||
</button>
|
Wedstrijd starten
|
||||||
|
</button>
|
||||||
|
} @else {
|
||||||
|
<span [matTooltip]="match.cantStartReason" style="cursor: not-allowed;">
|
||||||
|
<button mat-button disabled>
|
||||||
|
<mat-icon>play_arrow</mat-icon>
|
||||||
|
Wedstrijd starten
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
}
|
||||||
} @else if (match.status == 'IN_PROGRESS') {
|
} @else if (match.status == 'IN_PROGRESS') {
|
||||||
<button mat-button (click)="editResult(match, event, group, round)">
|
<button mat-button (click)="editResult(match, event, group, round)">
|
||||||
<mat-icon>edit</mat-icon>
|
<mat-icon>leaderboard</mat-icon>
|
||||||
Uitslag invoeren
|
Uitslag
|
||||||
|
</button>
|
||||||
|
<button mat-button (click)="changeCounter(match)">
|
||||||
|
<mat-icon>person</mat-icon>
|
||||||
|
Teller
|
||||||
</button>
|
</button>
|
||||||
<button mat-button (click)="stopMatch(match)">
|
<button mat-button (click)="stopMatch(match)">
|
||||||
<mat-icon>stop</mat-icon>
|
<mat-icon>stop</mat-icon>
|
||||||
Wedstrijd stoppen
|
Stoppen
|
||||||
</button>
|
</button>
|
||||||
} @else if (match.status == 'FINISHED') {
|
} @else if (match.status == 'FINISHED') {
|
||||||
<div class="row result align-items-center">
|
<div class="row result align-items-center">
|
||||||
@@ -347,7 +363,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<mat-menu #finishedMatchMenu="matMenu">
|
<mat-menu #finishedMatchMenu="matMenu">
|
||||||
<button mat-menu-item (click)="editResult(match, event, group, round)">
|
<button mat-menu-item (click)="editResult(match, event, group, round)">
|
||||||
<mat-icon>edit</mat-icon>
|
<mat-icon>leaderboard</mat-icon>
|
||||||
Uitslag bewerken
|
Uitslag bewerken
|
||||||
</button>
|
</button>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
@@ -429,7 +445,14 @@
|
|||||||
@for (entry of getStandingsForRound(round, group).entries; track entry.position) {
|
@for (entry of getStandingsForRound(round, group).entries; track entry.position) {
|
||||||
<tr>
|
<tr>
|
||||||
<td class="align-middle">{{ entry.position }}</td>
|
<td class="align-middle">{{ entry.position }}</td>
|
||||||
<td class="align-middle">{{ entry.team | teamText }}</td>
|
<td class="align-middle">
|
||||||
|
<app-team-display
|
||||||
|
[team]="entry.team"
|
||||||
|
[event]="event"
|
||||||
|
[tournament]="this.tournament"
|
||||||
|
[inline]="true">
|
||||||
|
</app-team-display>
|
||||||
|
</td>
|
||||||
<td class="align-middle">{{ entry.played }}</td>
|
<td class="align-middle">{{ entry.played }}</td>
|
||||||
<td class="align-middle">
|
<td class="align-middle">
|
||||||
@if (entry.played > 0 ) {
|
@if (entry.played > 0 ) {
|
||||||
|
|||||||
@@ -33,8 +33,10 @@ import {Standings} from "../../model/standings";
|
|||||||
import {HeaderService} from "../../service/header.service";
|
import {HeaderService} from "../../service/header.service";
|
||||||
import {TournamentPlayersComponent} from "../tournament-players/tournament-players.component";
|
import {TournamentPlayersComponent} from "../tournament-players/tournament-players.component";
|
||||||
import {TournamentPlayer} from "../../model/tournamentPlayer";
|
import {TournamentPlayer} from "../../model/tournamentPlayer";
|
||||||
import {MatTooltip} from "@angular/material/tooltip";
|
|
||||||
import {TeamDisplayComponent} from "../team-display/team-display.component";
|
import {TeamDisplayComponent} from "../team-display/team-display.component";
|
||||||
|
import {CounterSelectionComponent} from "../counter-selection/counter-selection.component";
|
||||||
|
import {Observable, Subscription, tap} from "rxjs";
|
||||||
|
import {MatTooltip} from '@angular/material/tooltip';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-tournament-manage',
|
selector: 'app-tournament-manage',
|
||||||
@@ -65,6 +67,7 @@ import {TeamDisplayComponent} from "../team-display/team-display.component";
|
|||||||
TournamentPlayersComponent,
|
TournamentPlayersComponent,
|
||||||
MatExpansionPanelActionRow,
|
MatExpansionPanelActionRow,
|
||||||
TeamDisplayComponent,
|
TeamDisplayComponent,
|
||||||
|
MatTooltip,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
FullNamePipe,
|
FullNamePipe,
|
||||||
@@ -97,10 +100,10 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
|
|||||||
this.activeRoundTab = params['tab'];
|
this.activeRoundTab = params['tab'];
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.tournamentService.getById(Number(id)).subscribe(data => {
|
this.loadTournament(
|
||||||
this.tournament = data;
|
this.tournamentService.getById(Number(id)),
|
||||||
this.headerService.setTitle(this.tournament.name);
|
(tournament) => this.headerService.setTitle(tournament.name)
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
@@ -151,45 +154,31 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startRound(round: Round) {
|
startRound(round: Round) {
|
||||||
this.tournamentService.startRound(this.tournament.id, round.id).subscribe(data => {
|
this.loadTournament(this.tournamentService.startRound(this.tournament.id, round.id));
|
||||||
this.tournament = data;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finishRound(round: Round) {
|
finishRound(round: Round) {
|
||||||
this.tournamentService.finishRound(this.tournament.id, round.id).subscribe(data => {
|
this.loadTournament(this.tournamentService.finishRound(this.tournament.id, round.id));
|
||||||
this.tournament = data;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finishGroup(group: Group) {
|
finishGroup(group: Group) {
|
||||||
this.tournamentService.finishGroup(this.tournament.id, group.id).subscribe(data => {
|
this.loadTournament(this.tournamentService.finishGroup(this.tournament.id, group.id));
|
||||||
this.tournament = data;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reopenGroup(group: Group) {
|
reopenGroup(group: Group) {
|
||||||
this.tournamentService.reopenGroup(this.tournament.id, group.id).subscribe(data => {
|
this.loadTournament(this.tournamentService.reopenGroup(this.tournament.id, group.id));
|
||||||
this.tournament = data;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
divideTournament() {
|
divideTournament() {
|
||||||
this.tournamentService.divide(this.tournament.id).subscribe(data => {
|
this.loadTournament(this.tournamentService.divide(this.tournament.id));
|
||||||
this.tournament = data;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clearDivision() {
|
clearDivision() {
|
||||||
this.tournamentService.clearDivision(this.tournament.id).subscribe(data => {
|
this.loadTournament(this.tournamentService.clearDivision(this.tournament.id));
|
||||||
this.tournament = data;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drawTournament() {
|
drawTournament() {
|
||||||
this.tournamentService.draw(this.tournament.id).subscribe(data => {
|
this.loadTournament(this.tournamentService.draw(this.tournament.id));
|
||||||
this.tournament = data;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startMatch(match: Match) {
|
startMatch(match: Match) {
|
||||||
@@ -213,9 +202,7 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
|
|||||||
minHeight: '250px'
|
minHeight: '250px'
|
||||||
}).afterClosed().subscribe(result => {
|
}).afterClosed().subscribe(result => {
|
||||||
if (result != undefined) {
|
if (result != undefined) {
|
||||||
this.tournamentService.startMatch(this.tournament.id, match.id, result.court, result.counter.playerId).subscribe(data => {
|
this.loadTournament(this.tournamentService.startMatch(this.tournament.id, match.id, result.court, result.counter.playerId));
|
||||||
this.tournament = data;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -223,26 +210,48 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
matchContainsPlayersThatArePlaying(match: Match): boolean {
|
matchContainsPlayersThatArePlaying(match: Match): boolean {
|
||||||
let matchPlayers: number[] = [];
|
let matchPlayers: number[] = [];
|
||||||
matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team1.player1).id);
|
matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player1, match.type).id);
|
||||||
if (match.team1.player2) matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team1.player2).id);
|
if (match.team1.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player2, match.type).id);
|
||||||
matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team2.player1).id);
|
matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player1, match.type).id);
|
||||||
if (match.team2.player2) matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team2.player2).id);
|
if (match.team2.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player2, match.type).id);
|
||||||
|
|
||||||
let matchPlayersThatArePlaying = this.tournament.playersPlaying.filter(Set.prototype.has, new Set(matchPlayers));
|
let matchPlayersThatArePlaying = this.tournament.playersPlaying.filter(Set.prototype.has, new Set(matchPlayers));
|
||||||
return matchPlayersThatArePlaying.length > 0;
|
return matchPlayersThatArePlaying.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
matchPlayersThatArePlaying(match: Match): number[] {
|
||||||
|
let matchPlayers: number[] = [];
|
||||||
|
|
||||||
|
matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player1, match.type).id);
|
||||||
|
if (match.team1.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player2, match.type).id);
|
||||||
|
matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player1, match.type).id);
|
||||||
|
if (match.team2.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player2, match.type).id);
|
||||||
|
|
||||||
|
return this.tournament.playersPlaying.filter(Set.prototype.has, new Set(matchPlayers));
|
||||||
|
}
|
||||||
|
|
||||||
matchContainsPlayersThatAreCounting(match: Match): boolean {
|
matchContainsPlayersThatAreCounting(match: Match): boolean {
|
||||||
let matchPlayers: number[] = [];
|
let matchPlayers: number[] = [];
|
||||||
matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team1.player1).id);
|
matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player1, match.type).id);
|
||||||
if (match.team1.player2) matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team1.player2).id);
|
if (match.team1.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player2, match.type).id);
|
||||||
matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team2.player1).id);
|
matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player1, match.type).id);
|
||||||
if (match.team2.player2) matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team2.player2).id);
|
if (match.team2.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player2, match.type).id);
|
||||||
|
|
||||||
let matchPlayersThatAreCounting = this.tournament.playersCounting.filter(Set.prototype.has, new Set(matchPlayers));
|
let matchPlayersThatAreCounting = this.tournament.playersCounting.filter(Set.prototype.has, new Set(matchPlayers));
|
||||||
return matchPlayersThatAreCounting.length > 0;
|
return matchPlayersThatAreCounting.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
matchPlayersThatAreCounting(match: Match): number[] {
|
||||||
|
let matchPlayers: number[] = [];
|
||||||
|
|
||||||
|
matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player1, match.type).id);
|
||||||
|
if (match.team1.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player2, match.type).id);
|
||||||
|
matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player1, match.type).id);
|
||||||
|
if (match.team2.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player2, match.type).id);
|
||||||
|
|
||||||
|
return this.tournament.playersCounting.filter(Set.prototype.has, new Set(matchPlayers));
|
||||||
|
}
|
||||||
|
|
||||||
getTournamentPlayerFromPlayer(player: Player): TournamentPlayer {
|
getTournamentPlayerFromPlayer(player: Player): TournamentPlayer {
|
||||||
for (let tournamentPlayer of this.tournament.tournamentPlayers) {
|
for (let tournamentPlayer of this.tournament.tournamentPlayers) {
|
||||||
if (tournamentPlayer.playerId == player.id) {
|
if (tournamentPlayer.playerId == player.id) {
|
||||||
@@ -302,15 +311,11 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stopMatch(match: Match) {
|
stopMatch(match: Match) {
|
||||||
this.tournamentService.stopMatch(this.tournament.id, match.id).subscribe(data => {
|
this.loadTournament(this.tournamentService.stopMatch(this.tournament.id, match.id));
|
||||||
this.tournament = data;
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newRound(group: Group) {
|
newRound(group: Group) {
|
||||||
this.tournamentService.newRound(this.tournament.id, group.id).subscribe(data => {
|
this.loadTournament(this.tournamentService.newRound(this.tournament.id, group.id));
|
||||||
this.tournament = data;
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getStrength(strength: string | undefined) {
|
getStrength(strength: string | undefined) {
|
||||||
@@ -367,6 +372,7 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
matchResultDialog = inject(MatDialog);
|
matchResultDialog = inject(MatDialog);
|
||||||
courtSelectionDialog = inject(MatDialog);
|
courtSelectionDialog = inject(MatDialog);
|
||||||
|
counterSelectionDialog = inject(MatDialog);
|
||||||
|
|
||||||
editResult(match: Match, event: Event, group: Group, round: Round) {
|
editResult(match: Match, event: Event, group: Group, round: Round) {
|
||||||
this.matchResultDialog.open(MatchResultComponent, {
|
this.matchResultDialog.open(MatchResultComponent, {
|
||||||
@@ -374,9 +380,7 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
|
|||||||
minWidth: '800px'
|
minWidth: '800px'
|
||||||
}).afterClosed().subscribe(result => {
|
}).afterClosed().subscribe(result => {
|
||||||
if (result != undefined) {
|
if (result != undefined) {
|
||||||
this.tournamentService.saveResult(this.tournament.id, result.matchId, result).subscribe(data => {
|
this.loadTournament(this.tournamentService.saveResult(this.tournament.id, result.matchId, result));
|
||||||
this.tournament = data;
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -427,6 +431,84 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
|
|||||||
return count;
|
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.loadTournament(this.tournamentService.updateCounter(this.tournament.id, match.id, result.counter.playerId));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private loadTournament(
|
||||||
|
observable: Observable<Tournament>,
|
||||||
|
afterLoad?: (tournament: Tournament) => void
|
||||||
|
): Subscription {
|
||||||
|
return observable.subscribe(data => {
|
||||||
|
this.tournament = data;
|
||||||
|
this.updateMatchAvailability();
|
||||||
|
afterLoad?.(data); // Optional chaining
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateMatchAvailability() {
|
||||||
|
for (const event of this.tournament.events) {
|
||||||
|
for (const group of event.groups) {
|
||||||
|
for (const round of group.rounds) {
|
||||||
|
for (const match of round.matches) {
|
||||||
|
let canStart = true;
|
||||||
|
let matchPlayersThatArePlaying = this.matchPlayersThatArePlaying(match);
|
||||||
|
let matchPlayersThatAreCounting = this.matchPlayersThatAreCounting(match);
|
||||||
|
|
||||||
|
let cantStartReason = "";
|
||||||
|
|
||||||
|
if (matchPlayersThatArePlaying.length > 0) {
|
||||||
|
canStart = false;
|
||||||
|
cantStartReason = this.joinWithEn(matchPlayersThatArePlaying.map(m => this.getTournamentPlayerFromId(m).name));
|
||||||
|
if (matchPlayersThatArePlaying.length == 1) {
|
||||||
|
cantStartReason += " is al aan het spelen";
|
||||||
|
} else {
|
||||||
|
cantStartReason += " zijn al aan het spelen";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matchPlayersThatAreCounting.length > 0) {
|
||||||
|
canStart = false;
|
||||||
|
if (cantStartReason.length > 0) {
|
||||||
|
cantStartReason += " en ";
|
||||||
|
}
|
||||||
|
cantStartReason += this.joinWithEn(matchPlayersThatAreCounting.map(m => this.getTournamentPlayerFromId(m).name));
|
||||||
|
if (matchPlayersThatAreCounting.length == 1) {
|
||||||
|
cantStartReason += " is aan het tellen";
|
||||||
|
} else {
|
||||||
|
cantStartReason += " zijn aan het tellen";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
match.canStart = canStart;
|
||||||
|
match.cantStartReason = cantStartReason;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
joinWithEn(items: string[], separator = ", "): string {
|
||||||
|
const len = items.length;
|
||||||
|
|
||||||
|
if (len === 0) return "";
|
||||||
|
if (len === 1) return items[0];
|
||||||
|
if (len === 2) return items.join(" en ");
|
||||||
|
|
||||||
|
return items.slice(0, -1).join(separator) + `${separator}and ${items[len - 1]}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ActiveMatch {
|
class ActiveMatch {
|
||||||
|
|||||||
@@ -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.');
|
||||||
|
|||||||
@@ -13,4 +13,6 @@ export class Match {
|
|||||||
games: Game[];
|
games: Game[];
|
||||||
court: number;
|
court: number;
|
||||||
counter: Player;
|
counter: Player;
|
||||||
|
canStart?: boolean;
|
||||||
|
cantStartReason?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,10 @@ export class TournamentService {
|
|||||||
return this.http.post<Tournament>(`${this.tournamentsUrl}/${tournamentId}/players/${playerId}/substitutions`, substitutions)
|
return this.http.post<Tournament>(`${this.tournamentsUrl}/${tournamentId}/players/${playerId}/substitutions`, substitutions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public updateCounter(tournamentId: number, matchId: number, counter: number): Observable<Tournament> {
|
||||||
|
return this.http.patch<Tournament>(`${this.tournamentsUrl}/${tournamentId}/matches/${matchId}/update?counter=${counter}`, null);
|
||||||
|
}
|
||||||
|
|
||||||
public addTestData(): Observable<void> {
|
public addTestData(): Observable<void> {
|
||||||
return this.http.get<void>(`${environment.backendUrl}/testdata`);
|
return this.http.get<void>(`${environment.backendUrl}/testdata`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,3 +7,6 @@ body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
|
|||||||
z-index: 2000 !important;
|
z-index: 2000 !important;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
.mat-tooltip {
|
||||||
|
white-space: pre-line !important;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user