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 }} {{ element.reserveCanopy }}
</td> </td>
</ng-container> </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 <tr
mat-header-row mat-header-row
*matHeaderRowDef="displayedColumns; sticky: true" *matHeaderRowDef="displayedColumns; sticky: true"
@@ -33,6 +33,7 @@ export class ListOfGearsComponent implements OnInit {
"aad", "aad",
"mainCanopy", "mainCanopy",
"reserveCanopy", "reserveCanopy",
"equipment",
]; ];
public dataSourceTable: MatTableDataSource<GearResp>; public dataSourceTable: MatTableDataSource<GearResp>;
public resultsLength = 0; public resultsLength = 0;
@@ -42,6 +42,12 @@
<input matInput type="text" formControlName="reserveCanopy" /> <input matInput type="text" formControlName="reserveCanopy" />
</mat-form-field> </mat-form-field>
</p> </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> <button mat-raised-button color="accent" type="submit">Add</button>
</form> </form>
@@ -60,6 +60,11 @@ export class NewGearComponent implements OnInit {
Validators.min(60), Validators.min(60),
Validators.max(320), Validators.max(320),
]), ]),
equipment: new FormControl("RAS", [
Validators.required,
Validators.min(60),
Validators.max(320),
]),
}, },
{ updateOn: "blur" }, { updateOn: "blur" },
); );
@@ -85,6 +90,7 @@ export class NewGearComponent implements OnInit {
formData.aad, formData.aad,
formData.mainCanopy, formData.mainCanopy,
formData.reserveCanopy, formData.reserveCanopy,
formData.equipment,
) )
.subscribe(() => { .subscribe(() => {
this.serviceComm.refreshData(AddAction.Gear); this.serviceComm.refreshData(AddAction.Gear);
@@ -69,6 +69,7 @@
"ListGears_Header_Aad": "AAD system", "ListGears_Header_Aad": "AAD system",
"ListGears_Header_Main": "Main canopy", "ListGears_Header_Main": "Main canopy",
"ListGears_Header_Reserve": "Reserve canopy", "ListGears_Header_Reserve": "Reserve canopy",
"ListGears_Header_Equipment": "Equipment",
"ListJumpType_Add": "Add a jump type", "ListJumpType_Add": "Add a jump type",
"ListJumpType_Header_Id": "ID", "ListJumpType_Header_Id": "ID",
@@ -69,6 +69,7 @@
"ListGears_Header_Aad": "Système de sécurité", "ListGears_Header_Aad": "Système de sécurité",
"ListGears_Header_Main": "Principale", "ListGears_Header_Main": "Principale",
"ListGears_Header_Reserve": "Réserve", "ListGears_Header_Reserve": "Réserve",
"ListGears_Header_Equipment": "Équipment",
"ListJumpType_Add": "Ajouter un type de saut", "ListJumpType_Add": "Ajouter un type de saut",
"ListJumpType_Header_Id": "ID", "ListJumpType_Header_Id": "ID",
+24 -22
View File
@@ -1,29 +1,31 @@
export class GearReq { export class GearReq {
constructor(data: any) { constructor(data: any) {
Object.assign(this, data); Object.assign(this, data);
} }
public id: number; public id: number;
public name: string; public name: string;
public manufacturer: string; public manufacturer: string;
public minSize: number; public minSize: number;
public maxSize: number; public maxSize: number;
public aad: string; public aad: string;
public mainCanopy: string; public mainCanopy: string;
public reserveCanopy: string; public reserveCanopy: string;
public equipment: string;
} }
export class GearResp { export class GearResp {
constructor(data: any) { constructor(data: any) {
Object.assign(this, data); Object.assign(this, data);
} }
public id: number; public id: number;
public name: string; public name: string;
public manufacturer: string; public manufacturer: string;
public minSize: number; public minSize: number;
public maxSize: number; public maxSize: number;
public aad: string; public aad: string;
public mainCanopy: string; public mainCanopy: string;
public reserveCanopy: string; public reserveCanopy: string;
public equipment: string;
} }
@@ -10,46 +10,59 @@ import { CacheApiKey } from "../models/cache-api-key.enum";
@Injectable() @Injectable()
export class GearService extends BaseService { export class GearService extends BaseService {
constructor(private http: HttpClient) { constructor(private http: HttpClient) {
super(); super();
} }
public getListOfGears(): Observable<Array<GearResp>> { public getListOfGears(): Observable<Array<GearResp>> {
let callToApi = this.http.get<Array<GearResp>>(`${this.apiUrl}/Gear`, { headers: this.headers }); let callToApi = this.http.get<Array<GearResp>>(`${this.apiUrl}/Gear`, {
return this.serviceCacheApi.get<Array<GearResp>>(CacheApiKey.Gear, callToApi); headers: this.headers,
} });
return this.serviceCacheApi.get<Array<GearResp>>(
CacheApiKey.Gear,
callToApi,
);
}
public addGear(name: string, public addGear(
manufacturer: string, name: string,
minSize: number, manufacturer: string,
maxSize: number, minSize: number,
aad: string, maxSize: number,
mainCanopy: string, aad: string,
reserveCanopy: string) mainCanopy: string,
{ reserveCanopy: string,
const bodyNewGear: GearReq = { equipment: string,
id: 0, ) {
name: name, const bodyNewGear: GearReq = {
manufacturer: manufacturer, id: 0,
minSize: minSize, name: name,
maxSize: maxSize, manufacturer: manufacturer,
aad: aad, minSize: minSize,
mainCanopy: mainCanopy, maxSize: maxSize,
reserveCanopy: reserveCanopy aad: aad,
}; mainCanopy: mainCanopy,
reserveCanopy: reserveCanopy,
equipment: equipment,
};
this.serviceCacheApi.delete(CacheApiKey.Gear); 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> { public getById(id: number): Observable<GearResp> {
return this.serviceCacheApi.getByKey<Array<GearResp>>(CacheApiKey.Gear) return this.serviceCacheApi
.pipe(map(data => { .getByKey<Array<GearResp>>(CacheApiKey.Gear)
return data.find(f => f.id === id); .pipe(
})); map((data) => {
} return data.find((f) => f.id === id);
}),
);
}
public getFromCache(): Observable<Array<GearResp>> { public getFromCache(): Observable<Array<GearResp>> {
return this.serviceCacheApi.getByKey<Array<GearResp>>(CacheApiKey.Gear); return this.serviceCacheApi.getByKey<Array<GearResp>>(CacheApiKey.Gear);
} }
} }