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>
|
||||||
|
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="Exit altitude" [(ngModel)]="defaultExitAltitude" name="defaultExitAltitude">
|
<input matInput placeholder="Exit altitude" [(ngModel)]="exitAltitude" name="exitAltitude" type="number">
|
||||||
<button mat-button *ngIf="defaultExitAltitude" matSuffix mat-icon-button aria-label="Clear"
|
<button mat-button *ngIf="exitAltitude" matSuffix mat-icon-button aria-label="Clear"
|
||||||
(click)="defaultExitAltitude=''">
|
(click)="exitAltitude=undefined">
|
||||||
<mat-icon>close</mat-icon>
|
<mat-icon>close</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="Deploy altitude" [(ngModel)]="defaultDeployAltitude" name="defaultDeployAltitude">
|
<input matInput placeholder="Deploy altitude" [(ngModel)]="deployAltitude" name="deployAltitude" type="number">
|
||||||
<button mat-button *ngIf="defaultDeployAltitude" matSuffix mat-icon-button aria-label="Clear"
|
<button mat-button *ngIf="deployAltitude" matSuffix mat-icon-button aria-label="Clear"
|
||||||
(click)="defaultDeployAltitude=''">
|
(click)="deployAltitude=undefined">
|
||||||
<mat-icon>close</mat-icon>
|
<mat-icon>close</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="Count of jumps" [(ngModel)]="countOfJumps" name="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=''">
|
<button mat-button *ngIf="countOfJumps" matSuffix mat-icon-button aria-label="Clear"
|
||||||
|
(click)="countOfJumps=undefined">
|
||||||
<mat-icon>close</mat-icon>
|
<mat-icon>close</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<button class="btn btn-primary" *ngIf="isValidatedForm">Submit</button>
|
<button class="btn btn-primary" *ngIf="isValidatedForm()">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { AircraftResp } from "../../models/aircraft";
|
|||||||
import { DropZoneResp } from "../../models/dropzone";
|
import { DropZoneResp } from "../../models/dropzone";
|
||||||
import { DateService } from "../../services/date.service";
|
import { DateService } from "../../services/date.service";
|
||||||
import { GearResp } from "../../models/gear";
|
import { GearResp } from "../../models/gear";
|
||||||
|
import { isNumber } from "util";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-new-jump",
|
selector: "app-new-jump",
|
||||||
@@ -16,8 +17,8 @@ import { GearResp } from "../../models/gear";
|
|||||||
export class NewJumpComponent implements OnInit {
|
export class NewJumpComponent implements OnInit {
|
||||||
beginDate: Date;
|
beginDate: Date;
|
||||||
endDate: Date;
|
endDate: Date;
|
||||||
defaultExitAltitude: number;
|
exitAltitude: number;
|
||||||
defaultDeployAltitude: number;
|
deployAltitude: number;
|
||||||
countOfJumps: number;
|
countOfJumps: number;
|
||||||
selectedDz: number;
|
selectedDz: number;
|
||||||
selectedGear: number;
|
selectedGear: number;
|
||||||
@@ -43,8 +44,8 @@ export class NewJumpComponent implements OnInit {
|
|||||||
|
|
||||||
this.beginDate = this.dateService.AddDays(new Date(), -1);
|
this.beginDate = this.dateService.AddDays(new Date(), -1);
|
||||||
|
|
||||||
this.defaultExitAltitude = 4000;
|
this.exitAltitude = 4000;
|
||||||
this.defaultDeployAltitude = 1000;
|
this.deployAltitude = 1500;
|
||||||
this.countOfJumps = 1;
|
this.countOfJumps = 1;
|
||||||
|
|
||||||
this.getListOfJumpTypes();
|
this.getListOfJumpTypes();
|
||||||
@@ -59,17 +60,23 @@ export class NewJumpComponent implements OnInit {
|
|||||||
this.withCutaway,
|
this.withCutaway,
|
||||||
this.beginDate,
|
this.beginDate,
|
||||||
this.endDate,
|
this.endDate,
|
||||||
this.defaultExitAltitude,
|
this.exitAltitude,
|
||||||
this.defaultDeployAltitude,
|
this.deployAltitude,
|
||||||
this.countOfJumps
|
this.countOfJumps
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public isValidatedForm: boolean =
|
public isValidatedForm(): boolean {
|
||||||
this.selectedDz != undefined &&
|
return (
|
||||||
this.selectedGear != undefined &&
|
this.selectedDz != undefined &&
|
||||||
this.selectedAircraft != undefined &&
|
this.selectedGear != undefined &&
|
||||||
this.selectedJumpType != 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() {
|
private getListOfJumpTypes() {
|
||||||
this.serviceApiGet.getListOfJumpTypes().subscribe(data => {
|
this.serviceApiGet.getListOfJumpTypes().subscribe(data => {
|
||||||
|
|||||||
Reference in New Issue
Block a user