Skip to content

Commit

Permalink
Delete allocations in new desktop client
Browse files Browse the repository at this point in the history
  • Loading branch information
daveajlee committed Nov 12, 2023
1 parent 8b693a3 commit 554e096
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Expand Up @@ -20,7 +20,7 @@ <h1 class="display-4 text-center">Vehicle Allocations</h1>
<td> {{allocationEl.routeNumber}} </td>
<td> {{allocationEl.fleetNumber}} </td>
<td> {{allocationEl.tourNumber}} </td>
<td><button class="btn btn-danger" style="margin: 5px;" type="submit" (click)="deleteAllocation()">Delete</button></td>
<td><button class="btn btn-danger" style="margin: 5px;" type="submit" (click)="deleteAllocation(allocationEl.routeNumber, allocationEl.fleetNumber, allocationEl.tourNumber)">Delete</button></td>
</tr>
</tbody>

Expand Down
15 changes: 13 additions & 2 deletions desktop/src/app/allocationslist/allocationslist.component.ts
Expand Up @@ -30,8 +30,19 @@ export class AllocationslistComponent {
this.allocations = this.gameService.getGame().allocations;
}

deleteAllocation(): void {
alert('Coming Soon!');
deleteAllocation(routeNumber: string, fleetNumber: string, tourNumber: string): void {
var allAllocations = this.gameService.getGame().allocations;
for ( var i = 0; i < allAllocations.length; i++ ) {
if ( this.gameService.getGame().allocations[i].fleetNumber.valueOf() === fleetNumber.valueOf() &&
this.gameService.getGame().allocations[i].routeNumber.valueOf() === routeNumber.valueOf() &&
this.gameService.getGame().allocations[i].tourNumber.valueOf() === tourNumber.valueOf()
) {
this.gameService.getGame().allocations.splice(i, 1);
alert('Allocation was deleted successfully');
this.router.navigate(['allocationslist']);
}
}

}

backToManagementScreen(): void {
Expand Down

0 comments on commit 554e096

Please sign in to comment.