Ajout d'un check de validation
sur le formulaire d'ajout de sauts
This commit is contained in:
@@ -50,27 +50,28 @@
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Exit altitude" [(ngModel)]="defaultExitAltitude" name="defaultExitAltitude">
|
||||
<button mat-button *ngIf="defaultExitAltitude" matSuffix mat-icon-button aria-label="Clear"
|
||||
(click)="defaultExitAltitude=''">
|
||||
<input matInput placeholder="Exit altitude" [(ngModel)]="exitAltitude" name="exitAltitude" type="number">
|
||||
<button mat-button *ngIf="exitAltitude" matSuffix mat-icon-button aria-label="Clear"
|
||||
(click)="exitAltitude=undefined">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Deploy altitude" [(ngModel)]="defaultDeployAltitude" name="defaultDeployAltitude">
|
||||
<button mat-button *ngIf="defaultDeployAltitude" matSuffix mat-icon-button aria-label="Clear"
|
||||
(click)="defaultDeployAltitude=''">
|
||||
<input matInput placeholder="Deploy altitude" [(ngModel)]="deployAltitude" name="deployAltitude" type="number">
|
||||
<button mat-button *ngIf="deployAltitude" matSuffix mat-icon-button aria-label="Clear"
|
||||
(click)="deployAltitude=undefined">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Count of jumps" [(ngModel)]="countOfJumps" name="countOfJumps">
|
||||
<button mat-button *ngIf="countOfJumps" matSuffix mat-icon-button aria-label="Clear" (click)="countOfJumps=''">
|
||||
<input matInput placeholder="Count of jumps" [(ngModel)]="countOfJumps" name="countOfJumps" type="number">
|
||||
<button mat-button *ngIf="countOfJumps" matSuffix mat-icon-button aria-label="Clear"
|
||||
(click)="countOfJumps=undefined">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</mat-form-field>
|
||||
|
||||
<br />
|
||||
<button class="btn btn-primary" *ngIf="isValidatedForm">Submit</button>
|
||||
<button class="btn btn-primary" *ngIf="isValidatedForm()">Submit</button>
|
||||
</form>
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user