Add an equipement when you add and update a gear

This commit is contained in:
2026-05-03 23:32:12 +02:00
parent bd5a9f12ce
commit 5313384b48
8 changed files with 97 additions and 59 deletions
@@ -71,6 +71,14 @@
{{ element.reserveCanopy }}
</td>
</ng-container>
<ng-container matColumnDef="equipment">
<th mat-header-cell *matHeaderCellDef>
{{ "ListGears_Header_Equipment" | translate }}
</th>
<td mat-cell *matCellDef="let element">
{{ element.equipment }}
</td>
</ng-container>
<tr
mat-header-row
*matHeaderRowDef="displayedColumns; sticky: true"
@@ -33,6 +33,7 @@ export class ListOfGearsComponent implements OnInit {
"aad",
"mainCanopy",
"reserveCanopy",
"equipment",
];
public dataSourceTable: MatTableDataSource<GearResp>;
public resultsLength = 0;
@@ -42,6 +42,12 @@
<input matInput type="text" formControlName="reserveCanopy" />
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>Equipment</mat-label>
<input matInput type="text" formControlName="equipment" />
</mat-form-field>
</p>
<button mat-raised-button color="accent" type="submit">Add</button>
</form>
@@ -60,6 +60,11 @@ export class NewGearComponent implements OnInit {
Validators.min(60),
Validators.max(320),
]),
equipment: new FormControl("RAS", [
Validators.required,
Validators.min(60),
Validators.max(320),
]),
},
{ updateOn: "blur" },
);
@@ -85,6 +90,7 @@ export class NewGearComponent implements OnInit {
formData.aad,
formData.mainCanopy,
formData.reserveCanopy,
formData.equipment,
)
.subscribe(() => {
this.serviceComm.refreshData(AddAction.Gear);
@@ -69,6 +69,7 @@
"ListGears_Header_Aad": "AAD system",
"ListGears_Header_Main": "Main canopy",
"ListGears_Header_Reserve": "Reserve canopy",
"ListGears_Header_Equipment": "Equipment",
"ListJumpType_Add": "Add a jump type",
"ListJumpType_Header_Id": "ID",
@@ -69,6 +69,7 @@
"ListGears_Header_Aad": "Système de sécurité",
"ListGears_Header_Main": "Principale",
"ListGears_Header_Reserve": "Réserve",
"ListGears_Header_Equipment": "Équipment",
"ListJumpType_Add": "Ajouter un type de saut",
"ListJumpType_Header_Id": "ID",
+2
View File
@@ -11,6 +11,7 @@ export class GearReq {
public aad: string;
public mainCanopy: string;
public reserveCanopy: string;
public equipment: string;
}
export class GearResp {
@@ -26,4 +27,5 @@ export class GearResp {
public aad: string;
public mainCanopy: string;
public reserveCanopy: string;
public equipment: string;
}
@@ -15,18 +15,25 @@ export class GearService extends BaseService {
}
public getListOfGears(): Observable<Array<GearResp>> {
let callToApi = this.http.get<Array<GearResp>>(`${this.apiUrl}/Gear`, { headers: this.headers });
return this.serviceCacheApi.get<Array<GearResp>>(CacheApiKey.Gear, callToApi);
let callToApi = this.http.get<Array<GearResp>>(`${this.apiUrl}/Gear`, {
headers: this.headers,
});
return this.serviceCacheApi.get<Array<GearResp>>(
CacheApiKey.Gear,
callToApi,
);
}
public addGear(name: string,
public addGear(
name: string,
manufacturer: string,
minSize: number,
maxSize: number,
aad: string,
mainCanopy: string,
reserveCanopy: string)
{
reserveCanopy: string,
equipment: string,
) {
const bodyNewGear: GearReq = {
id: 0,
name: name,
@@ -35,18 +42,24 @@ export class GearService extends BaseService {
maxSize: maxSize,
aad: aad,
mainCanopy: mainCanopy,
reserveCanopy: reserveCanopy
reserveCanopy: reserveCanopy,
equipment: equipment,
};
this.serviceCacheApi.delete(CacheApiKey.Gear);
return this.http.post(`${this.apiUrl}/Gear`, bodyNewGear, { headers: this.headers});
return this.http.post(`${this.apiUrl}/Gear`, bodyNewGear, {
headers: this.headers,
});
}
public getById(id: number): Observable<GearResp> {
return this.serviceCacheApi.getByKey<Array<GearResp>>(CacheApiKey.Gear)
.pipe(map(data => {
return data.find(f => f.id === id);
}));
return this.serviceCacheApi
.getByKey<Array<GearResp>>(CacheApiKey.Gear)
.pipe(
map((data) => {
return data.find((f) => f.id === id);
}),
);
}
public getFromCache(): Observable<Array<GearResp>> {