Ajout d'un check de validation

sur le formulaire d'ajout de sauts
This commit is contained in:
Sébastien André
2019-11-24 18:56:58 +01:00
parent bab92186dd
commit c748db4ae5
2 changed files with 28 additions and 20 deletions

View File

@@ -7,6 +7,7 @@ import { AircraftResp } from "../../models/aircraft";
import { DropZoneResp } from "../../models/dropzone";
import { DateService } from "../../services/date.service";
import { GearResp } from "../../models/gear";
import { isNumber } from "util";
@Component({
selector: "app-new-jump",
@@ -16,8 +17,8 @@ import { GearResp } from "../../models/gear";
export class NewJumpComponent implements OnInit {
beginDate: Date;
endDate: Date;
defaultExitAltitude: number;
defaultDeployAltitude: number;
exitAltitude: number;
deployAltitude: number;
countOfJumps: number;
selectedDz: number;
selectedGear: number;
@@ -43,8 +44,8 @@ export class NewJumpComponent implements OnInit {
this.beginDate = this.dateService.AddDays(new Date(), -1);
this.defaultExitAltitude = 4000;
this.defaultDeployAltitude = 1000;
this.exitAltitude = 4000;
this.deployAltitude = 1500;
this.countOfJumps = 1;
this.getListOfJumpTypes();
@@ -59,17 +60,23 @@ export class NewJumpComponent implements OnInit {
this.withCutaway,
this.beginDate,
this.endDate,
this.defaultExitAltitude,
this.defaultDeployAltitude,
this.exitAltitude,
this.deployAltitude,
this.countOfJumps
);
}
public isValidatedForm: boolean =
this.selectedDz != undefined &&
this.selectedGear != undefined &&
this.selectedAircraft != undefined &&
this.selectedJumpType != undefined;
public isValidatedForm(): boolean {
return (
this.selectedDz != undefined &&
this.selectedGear != undefined &&
this.selectedAircraft != undefined &&
this.selectedJumpType != undefined &&
this.exitAltitude != undefined && isNumber(this.exitAltitude) &&
this.deployAltitude != undefined && isNumber(this.deployAltitude) &&
this.countOfJumps != undefined && isNumber(this.countOfJumps)
);
}
private getListOfJumpTypes() {
this.serviceApiGet.getListOfJumpTypes().subscribe(data => {