Add the jump type in the tunnel flight
This commit is contained in:
@@ -4,6 +4,19 @@
|
||||
</div>
|
||||
|
||||
<form class="formNewJumps" (ngSubmit)="onFormSubmit()" *ngIf="notLoadingToDisplay() else loading">
|
||||
<mat-form-field>
|
||||
<mat-label>{{ 'NewTunnelFlight_ChooseJumpType' | translate }}</mat-label>
|
||||
<input type="text" matInput [matAutocomplete]="autoJumpType" [(ngModel)]="selectedJumpType" name="selectedJumpType">
|
||||
<mat-autocomplete #autoJumpType="matAutocomplete" [displayWith]="displayNameFn">
|
||||
<mat-option *ngFor="let jumpType of listOfJumpType" [value]="jumpType">
|
||||
{{jumpType.name}}
|
||||
</mat-option>
|
||||
</mat-autocomplete>
|
||||
<button *ngIf="selectedJumpType" matSuffix mat-icon-button aria-label="Clear" (click)="selectedJumpType=undefined">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>{{ 'NewTunnelFlight_ChooseTunnel' | translate }}</mat-label>
|
||||
<input type="text" matInput [matAutocomplete]="autoDropZone" [(ngModel)]="selectedTunnel"
|
||||
|
||||
@@ -5,11 +5,12 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { TunnelResp } from "../../models/tunnel";
|
||||
|
||||
import { DateService } from '../../services/date.service';
|
||||
import { JumpTypeResp } from "../../models/jumpType";
|
||||
import { TunnelService } from '../../services/tunnel.service';
|
||||
import { ServiceComm } from '../../services/service-comm.service';
|
||||
import { StatsService } from '../../services/stats.service';
|
||||
import { TunnelFlightService } from "../../services/tunnel-flight.service";
|
||||
import { JumpTypeService } from "../../services/jump-type.service";
|
||||
|
||||
export const PICK_FORMATS = {
|
||||
parse: { dateInput: 'yy MM dd' },
|
||||
@@ -39,18 +40,20 @@ export class NewTunnelFlightComponent implements OnInit {
|
||||
public flightDate: Date;
|
||||
public minutesOfFlight: number;
|
||||
public selectedTunnel: TunnelResp;
|
||||
public selectedJumpType: JumpTypeResp;
|
||||
public listOfTunnel: Array<TunnelResp>;
|
||||
public listOfFilteredTunnel: Array<TunnelResp>;
|
||||
public resetForm: boolean;
|
||||
public comments: string;
|
||||
private countDatasLoaded: number;
|
||||
private pendingAddRequest: boolean;
|
||||
public listOfJumpType: Array<JumpTypeResp>;
|
||||
|
||||
constructor(private serviceComm: ServiceComm,
|
||||
private serviceTunnel: TunnelService,
|
||||
private serviceTunnelFlight: TunnelFlightService,
|
||||
private translateService: TranslateService,
|
||||
private statsService: StatsService) { }
|
||||
private serviceJumpType: JumpTypeService,
|
||||
private translateService: TranslateService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.serviceComm.forceTranslateTitle.subscribe((data) => {
|
||||
@@ -60,20 +63,22 @@ export class NewTunnelFlightComponent implements OnInit {
|
||||
});
|
||||
this.updateTitle();
|
||||
|
||||
this.countDatasLoaded = 0;
|
||||
this.pendingAddRequest = false;
|
||||
this.initForm();
|
||||
this.getListOfTunnels();
|
||||
this.getListOfJumpTypes();
|
||||
}
|
||||
|
||||
public onFormSubmit() {
|
||||
this.pendingAddRequest = true;
|
||||
|
||||
this.serviceTunnelFlight.addFlight(this.selectedTunnel.id,
|
||||
this.selectedJumpType.id,
|
||||
this.flightDate,
|
||||
this.minutesOfFlight,
|
||||
this.comments)
|
||||
.subscribe(() => {
|
||||
this.statsService.resetStats();
|
||||
this.comments = undefined;
|
||||
|
||||
if (this.resetForm === true) {
|
||||
@@ -91,17 +96,26 @@ export class NewTunnelFlightComponent implements OnInit {
|
||||
}
|
||||
|
||||
private getListOfTunnels() {
|
||||
this.serviceTunnel.getListOfTunnels().subscribe((data) => {
|
||||
data.sort((a, b) => a.name.localeCompare(b.name));
|
||||
this.listOfTunnel = data;
|
||||
this.listOfFilteredTunnel = data;
|
||||
this.countDatasLoaded++;
|
||||
});
|
||||
this.serviceTunnel.getListOfTunnels()
|
||||
.subscribe((data) => {
|
||||
data.sort((a, b) => a.name.localeCompare(b.name));
|
||||
this.listOfTunnel = data;
|
||||
this.listOfFilteredTunnel = data;
|
||||
this.countDatasLoaded++;
|
||||
});
|
||||
}
|
||||
|
||||
private getListOfJumpTypes() {
|
||||
this.serviceJumpType.getListOfJumpTypes()
|
||||
.subscribe((data) => {
|
||||
data.sort((a, b) => a.name.localeCompare(b.name));
|
||||
this.listOfJumpType = data;
|
||||
this.countDatasLoaded++;
|
||||
});
|
||||
}
|
||||
|
||||
public notLoadingToDisplay(): boolean {
|
||||
// return !(this.pendingAddRequest || this.countDatasLoaded > 1);
|
||||
return true;
|
||||
return !(this.pendingAddRequest || this.countDatasLoaded !== 2);
|
||||
}
|
||||
|
||||
private updateTitle() {
|
||||
|
||||
Reference in New Issue
Block a user