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>
|
||||
</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-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
</table>
|
||||
|
||||
@@ -22,7 +22,8 @@ export class ListOfJumpsComponent implements OnInit {
|
||||
'jumpDate',
|
||||
'jumpType',
|
||||
'aircraft',
|
||||
'dropZone'
|
||||
'dropZone',
|
||||
'actions'
|
||||
];
|
||||
public dataSourceTable;
|
||||
public resultsLength = 0;
|
||||
@@ -51,11 +52,15 @@ export class ListOfJumpsComponent implements OnInit {
|
||||
|
||||
openDialog(item: JumpResp) {
|
||||
this.dialog.open(JumpInfosComponent, {
|
||||
data: item //,
|
||||
// position: {
|
||||
// top: '0px',
|
||||
// left: '0px'
|
||||
// }
|
||||
data: item
|
||||
});
|
||||
}
|
||||
|
||||
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>
|
||||
<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>
|
||||
<form class="formNewJumps" (ngSubmit)="onFormSubmit()" *ngIf="notLoadingToDisplay() else loading">
|
||||
<mat-form-field>
|
||||
|
||||
@@ -17,24 +17,25 @@ import { GearService } from "../../services/gear.service";
|
||||
styleUrls: ["./new-jump.component.css"]
|
||||
})
|
||||
export class NewJumpComponent implements OnInit {
|
||||
beginDate: Date;
|
||||
endDate: Date;
|
||||
exitAltitude: number;
|
||||
deployAltitude: number;
|
||||
countOfJumps: number;
|
||||
selectedDz: DropZoneResp;
|
||||
selectedGear: GearResp;
|
||||
selectedAircraft: AircraftResp;
|
||||
selectedJumpType: JumpTypeResp;
|
||||
withCutaway: boolean;
|
||||
listOfJumpType: Array<JumpTypeResp>;
|
||||
listOfAircraft: Array<AircraftResp>;
|
||||
private listOfDropZone: Array<DropZoneResp>;
|
||||
listOfFilteredDropZone: Array<DropZoneResp>;
|
||||
listOfGear: Array<GearResp>;
|
||||
public beginDate: Date;
|
||||
public endDate: Date;
|
||||
public exitAltitude: number;
|
||||
public deployAltitude: number;
|
||||
public countOfJumps: number;
|
||||
public selectedDz: DropZoneResp;
|
||||
public selectedGear: GearResp;
|
||||
public selectedAircraft: AircraftResp;
|
||||
public selectedJumpType: JumpTypeResp;
|
||||
public withCutaway: boolean;
|
||||
public listOfJumpType: Array<JumpTypeResp>;
|
||||
public listOfAircraft: Array<AircraftResp>;
|
||||
public listOfFilteredDropZone: Array<DropZoneResp>;
|
||||
public listOfGear: Array<GearResp>;
|
||||
public comments: string;
|
||||
public resetForm: boolean;
|
||||
private countDatasLoaded: number;
|
||||
private pendingAddRequest: boolean;
|
||||
comments: string;
|
||||
private listOfDropZone: Array<DropZoneResp>;
|
||||
|
||||
constructor(private serviceComm: ServiceComm,
|
||||
private serviceJump: JumpService,
|
||||
@@ -69,28 +70,28 @@ export class NewJumpComponent implements OnInit {
|
||||
this.comments);
|
||||
|
||||
setTimeout(() => {
|
||||
this.initForm();
|
||||
if (this.resetForm === true) {
|
||||
this.initForm();
|
||||
}
|
||||
this.pendingAddRequest = false;
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
public isValidatedForm(): boolean {
|
||||
return (
|
||||
this.selectedDz !== undefined &&
|
||||
this.selectedDz.id !== undefined &&
|
||||
this.selectedGear !== undefined &&
|
||||
this.selectedGear.id !== undefined &&
|
||||
this.selectedAircraft !== undefined &&
|
||||
this.selectedAircraft.id !== undefined &&
|
||||
this.selectedJumpType !== undefined &&
|
||||
this.selectedJumpType.id !== undefined &&
|
||||
this.exitAltitude !== undefined &&
|
||||
typeof this.exitAltitude === "number" &&
|
||||
this.deployAltitude !== undefined &&
|
||||
typeof this.deployAltitude === "number" &&
|
||||
this.countOfJumps !== undefined &&
|
||||
typeof this.countOfJumps === "number"
|
||||
);
|
||||
return (this.selectedDz !== undefined &&
|
||||
this.selectedDz.id !== undefined &&
|
||||
this.selectedGear !== undefined &&
|
||||
this.selectedGear.id !== undefined &&
|
||||
this.selectedAircraft !== undefined &&
|
||||
this.selectedAircraft.id !== undefined &&
|
||||
this.selectedJumpType !== undefined &&
|
||||
this.selectedJumpType.id !== undefined &&
|
||||
this.exitAltitude !== undefined &&
|
||||
typeof this.exitAltitude === "number" &&
|
||||
this.deployAltitude !== undefined &&
|
||||
typeof this.deployAltitude === "number" &&
|
||||
this.countOfJumps !== undefined &&
|
||||
typeof this.countOfJumps === "number");
|
||||
}
|
||||
|
||||
private getListOfJumpTypes() {
|
||||
|
||||
@@ -74,6 +74,12 @@ export class JumpService extends BaseService {
|
||||
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,
|
||||
selectedAircraft: number,
|
||||
selectedDz: number,
|
||||
@@ -99,11 +105,10 @@ export class JumpService extends BaseService {
|
||||
jumpDate: this.datePipe.transform(jumpDate, "yyyy-MM-dd")
|
||||
};
|
||||
|
||||
this.http
|
||||
.post(`${this.apiUrl}/Jump`, bodyNewjump, {
|
||||
headers: this.headers,
|
||||
})
|
||||
.subscribe((data) => console.log(data));
|
||||
this.http.post(`${this.apiUrl}/Jump`,
|
||||
bodyNewjump,
|
||||
{ headers: this.headers, })
|
||||
.subscribe((data) => console.log(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user