Ajout de la possibilité de supprimer un saut
Ajout de la possibilité de ne pas reset le formulaire après ajout de sauts
This commit is contained in:
@@ -50,6 +50,14 @@
|
|||||||
<td mat-cell *matCellDef="let element">{{element.gear.name}}</td>
|
<td mat-cell *matCellDef="let element">{{element.gear.name}}</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="actions">
|
||||||
|
<th mat-header-cell *matHeaderCellDef></th>
|
||||||
|
<td mat-cell *matCellDef="let element" style="text-align: left;">
|
||||||
|
<mat-icon aria-hidden="false" aria-label="Delete this jump" style="cursor: pointer;"
|
||||||
|
(click)='delete(element)'>delete</mat-icon>
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
|
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ export class ListOfJumpsComponent implements OnInit {
|
|||||||
'jumpDate',
|
'jumpDate',
|
||||||
'jumpType',
|
'jumpType',
|
||||||
'aircraft',
|
'aircraft',
|
||||||
'dropZone'
|
'dropZone',
|
||||||
|
'actions'
|
||||||
];
|
];
|
||||||
public dataSourceTable;
|
public dataSourceTable;
|
||||||
public resultsLength = 0;
|
public resultsLength = 0;
|
||||||
@@ -51,11 +52,15 @@ export class ListOfJumpsComponent implements OnInit {
|
|||||||
|
|
||||||
openDialog(item: JumpResp) {
|
openDialog(item: JumpResp) {
|
||||||
this.dialog.open(JumpInfosComponent, {
|
this.dialog.open(JumpInfosComponent, {
|
||||||
data: item //,
|
data: item
|
||||||
// position: {
|
|
||||||
// top: '0px',
|
|
||||||
// left: '0px'
|
|
||||||
// }
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete(item: JumpResp) {
|
||||||
|
let data : Array<JumpResp> = this.dataSourceTable.data;
|
||||||
|
data = data.filter(d => d.id !== item.id);
|
||||||
|
this.dataSourceTable.data = data;
|
||||||
|
|
||||||
|
this.serviceApi.DeleteJump(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
<div>
|
<div>
|
||||||
<button mat-raised-button color="accent" [routerLink]="['/jumps']" [routerLinkActive]="['active']" skipLocationChange>View the jumps</button>
|
<button mat-raised-button color="accent" [routerLink]="['/jumps']" [routerLinkActive]="['active']" skipLocationChange>View the jumps</button>
|
||||||
|
<p><mat-checkbox [(ngModel)]="resetForm" labelPosition="before">Reset form after adding : </mat-checkbox></p>
|
||||||
</div>
|
</div>
|
||||||
<form class="formNewJumps" (ngSubmit)="onFormSubmit()" *ngIf="notLoadingToDisplay() else loading">
|
<form class="formNewJumps" (ngSubmit)="onFormSubmit()" *ngIf="notLoadingToDisplay() else loading">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
|
|||||||
@@ -17,24 +17,25 @@ import { GearService } from "../../services/gear.service";
|
|||||||
styleUrls: ["./new-jump.component.css"]
|
styleUrls: ["./new-jump.component.css"]
|
||||||
})
|
})
|
||||||
export class NewJumpComponent implements OnInit {
|
export class NewJumpComponent implements OnInit {
|
||||||
beginDate: Date;
|
public beginDate: Date;
|
||||||
endDate: Date;
|
public endDate: Date;
|
||||||
exitAltitude: number;
|
public exitAltitude: number;
|
||||||
deployAltitude: number;
|
public deployAltitude: number;
|
||||||
countOfJumps: number;
|
public countOfJumps: number;
|
||||||
selectedDz: DropZoneResp;
|
public selectedDz: DropZoneResp;
|
||||||
selectedGear: GearResp;
|
public selectedGear: GearResp;
|
||||||
selectedAircraft: AircraftResp;
|
public selectedAircraft: AircraftResp;
|
||||||
selectedJumpType: JumpTypeResp;
|
public selectedJumpType: JumpTypeResp;
|
||||||
withCutaway: boolean;
|
public withCutaway: boolean;
|
||||||
listOfJumpType: Array<JumpTypeResp>;
|
public listOfJumpType: Array<JumpTypeResp>;
|
||||||
listOfAircraft: Array<AircraftResp>;
|
public listOfAircraft: Array<AircraftResp>;
|
||||||
private listOfDropZone: Array<DropZoneResp>;
|
public listOfFilteredDropZone: Array<DropZoneResp>;
|
||||||
listOfFilteredDropZone: Array<DropZoneResp>;
|
public listOfGear: Array<GearResp>;
|
||||||
listOfGear: Array<GearResp>;
|
public comments: string;
|
||||||
|
public resetForm: boolean;
|
||||||
private countDatasLoaded: number;
|
private countDatasLoaded: number;
|
||||||
private pendingAddRequest: boolean;
|
private pendingAddRequest: boolean;
|
||||||
comments: string;
|
private listOfDropZone: Array<DropZoneResp>;
|
||||||
|
|
||||||
constructor(private serviceComm: ServiceComm,
|
constructor(private serviceComm: ServiceComm,
|
||||||
private serviceJump: JumpService,
|
private serviceJump: JumpService,
|
||||||
@@ -69,14 +70,15 @@ export class NewJumpComponent implements OnInit {
|
|||||||
this.comments);
|
this.comments);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if (this.resetForm === true) {
|
||||||
this.initForm();
|
this.initForm();
|
||||||
|
}
|
||||||
this.pendingAddRequest = false;
|
this.pendingAddRequest = false;
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public isValidatedForm(): boolean {
|
public isValidatedForm(): boolean {
|
||||||
return (
|
return (this.selectedDz !== undefined &&
|
||||||
this.selectedDz !== undefined &&
|
|
||||||
this.selectedDz.id !== undefined &&
|
this.selectedDz.id !== undefined &&
|
||||||
this.selectedGear !== undefined &&
|
this.selectedGear !== undefined &&
|
||||||
this.selectedGear.id !== undefined &&
|
this.selectedGear.id !== undefined &&
|
||||||
@@ -89,8 +91,7 @@ export class NewJumpComponent implements OnInit {
|
|||||||
this.deployAltitude !== undefined &&
|
this.deployAltitude !== undefined &&
|
||||||
typeof this.deployAltitude === "number" &&
|
typeof this.deployAltitude === "number" &&
|
||||||
this.countOfJumps !== undefined &&
|
this.countOfJumps !== undefined &&
|
||||||
typeof this.countOfJumps === "number"
|
typeof this.countOfJumps === "number");
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getListOfJumpTypes() {
|
private getListOfJumpTypes() {
|
||||||
|
|||||||
@@ -74,6 +74,12 @@ export class JumpService extends BaseService {
|
|||||||
notes);
|
notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DeleteJump(item: JumpResp) {
|
||||||
|
this.http.delete(`${this.apiUrl}/Jump/${item.id}`,
|
||||||
|
{ headers: this.headers, })
|
||||||
|
.subscribe((data) => console.log(data));
|
||||||
|
}
|
||||||
|
|
||||||
private AddJumps(selectedJumpType: number,
|
private AddJumps(selectedJumpType: number,
|
||||||
selectedAircraft: number,
|
selectedAircraft: number,
|
||||||
selectedDz: number,
|
selectedDz: number,
|
||||||
@@ -99,10 +105,9 @@ export class JumpService extends BaseService {
|
|||||||
jumpDate: this.datePipe.transform(jumpDate, "yyyy-MM-dd")
|
jumpDate: this.datePipe.transform(jumpDate, "yyyy-MM-dd")
|
||||||
};
|
};
|
||||||
|
|
||||||
this.http
|
this.http.post(`${this.apiUrl}/Jump`,
|
||||||
.post(`${this.apiUrl}/Jump`, bodyNewjump, {
|
bodyNewjump,
|
||||||
headers: this.headers,
|
{ headers: this.headers, })
|
||||||
})
|
|
||||||
.subscribe((data) => console.log(data));
|
.subscribe((data) => console.log(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user