Skip to content

Commit 423cbdf

Browse files
prevent drag and drop if heat started
1 parent bfe74c4 commit 423cbdf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/app/surf-event/surf-event/competition/round/heat/heat.component.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges
22
import {CdkDragDrop} from "@angular/cdk/drag-drop";
33
import {FormArray, FormControl, FormGroup, Validators} from "@angular/forms";
44
import {Heat, Result} from "../../../../../core/models/competition.model";
5+
import {SnackbarService} from "../../../../../core/services/snackbar.service";
56

67
@Component({
78
selector: 'rs-heat',
@@ -17,7 +18,7 @@ export class HeatComponent implements OnInit, OnChanges {
1718

1819
heatForm!: FormGroup;
1920

20-
constructor() {
21+
constructor(private snackbarService: SnackbarService) {
2122
}
2223

2324
ngOnInit(): void {
@@ -57,16 +58,18 @@ export class HeatComponent implements OnInit, OnChanges {
5758
}
5859

5960
onDrop(event: CdkDragDrop<string[], any>) {
60-
this.drop.emit(event);
61+
if (this.heat.state === "idle") {
62+
this.drop.emit(event);
63+
} else {
64+
this.snackbarService.send("Fella, this heat is already in progress!", "warning");
65+
}
6166
}
6267

6368
getControl(index: number): FormControl {
6469
return <FormControl>(this.heatForm.get('heat') as FormArray).controls[index];
6570
}
6671

6772
ngOnChanges(changes: SimpleChanges): void {
68-
//this.status = this.heat.results.length > 0 ? 'finished' : 'assigned'
69-
7073
this.heatForm?.get('heat')?.reset();
7174

7275
this.heatForm = new FormGroup({

0 commit comments

Comments
 (0)