From 5313384b4883428110110f4d623cb4ae49cf90e1 Mon Sep 17 00:00:00 2001 From: sandre Date: Sun, 3 May 2026 23:32:12 +0200 Subject: [PATCH] Add an equipement when you add and update a gear --- .../list-of-gears.component.html | 8 ++ .../list-of-gears/list-of-gears.component.ts | 1 + .../src/app/new-gear/new-gear.component.html | 6 ++ .../src/app/new-gear/new-gear.component.ts | 6 ++ Front/skydivelogs-app/src/assets/i18n/en.json | 1 + Front/skydivelogs-app/src/assets/i18n/fr.json | 1 + Front/skydivelogs-app/src/models/gear.ts | 46 +++++----- .../src/services/gear.service.ts | 87 +++++++++++-------- 8 files changed, 97 insertions(+), 59 deletions(-) diff --git a/Front/skydivelogs-app/src/app/list-of-gears/list-of-gears.component.html b/Front/skydivelogs-app/src/app/list-of-gears/list-of-gears.component.html index b8e76e2..898dd86 100644 --- a/Front/skydivelogs-app/src/app/list-of-gears/list-of-gears.component.html +++ b/Front/skydivelogs-app/src/app/list-of-gears/list-of-gears.component.html @@ -71,6 +71,14 @@ {{ element.reserveCanopy }} + + + {{ "ListGears_Header_Equipment" | translate }} + + + {{ element.equipment }} + + ; public resultsLength = 0; diff --git a/Front/skydivelogs-app/src/app/new-gear/new-gear.component.html b/Front/skydivelogs-app/src/app/new-gear/new-gear.component.html index f361f46..0bc63a9 100644 --- a/Front/skydivelogs-app/src/app/new-gear/new-gear.component.html +++ b/Front/skydivelogs-app/src/app/new-gear/new-gear.component.html @@ -42,6 +42,12 @@

+

+ + Equipment + + +

diff --git a/Front/skydivelogs-app/src/app/new-gear/new-gear.component.ts b/Front/skydivelogs-app/src/app/new-gear/new-gear.component.ts index abc8954..0e2e35a 100644 --- a/Front/skydivelogs-app/src/app/new-gear/new-gear.component.ts +++ b/Front/skydivelogs-app/src/app/new-gear/new-gear.component.ts @@ -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); diff --git a/Front/skydivelogs-app/src/assets/i18n/en.json b/Front/skydivelogs-app/src/assets/i18n/en.json index baf1683..4934e9e 100644 --- a/Front/skydivelogs-app/src/assets/i18n/en.json +++ b/Front/skydivelogs-app/src/assets/i18n/en.json @@ -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", diff --git a/Front/skydivelogs-app/src/assets/i18n/fr.json b/Front/skydivelogs-app/src/assets/i18n/fr.json index 3dc402b..694fe1e 100644 --- a/Front/skydivelogs-app/src/assets/i18n/fr.json +++ b/Front/skydivelogs-app/src/assets/i18n/fr.json @@ -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", diff --git a/Front/skydivelogs-app/src/models/gear.ts b/Front/skydivelogs-app/src/models/gear.ts index c438567..bc2c46f 100644 --- a/Front/skydivelogs-app/src/models/gear.ts +++ b/Front/skydivelogs-app/src/models/gear.ts @@ -1,29 +1,31 @@ export class GearReq { - constructor(data: any) { - Object.assign(this, data); - } + constructor(data: any) { + Object.assign(this, data); + } - public id: number; - public name: string; - public manufacturer: string; - public minSize: number; - public maxSize: number; - public aad: string; - public mainCanopy: string; - public reserveCanopy: string; + public id: number; + public name: string; + public manufacturer: string; + public minSize: number; + public maxSize: number; + public aad: string; + public mainCanopy: string; + public reserveCanopy: string; + public equipment: string; } export class GearResp { - constructor(data: any) { - Object.assign(this, data); - } + constructor(data: any) { + Object.assign(this, data); + } - public id: number; - public name: string; - public manufacturer: string; - public minSize: number; - public maxSize: number; - public aad: string; - public mainCanopy: string; - public reserveCanopy: string; + public id: number; + public name: string; + public manufacturer: string; + public minSize: number; + public maxSize: number; + public aad: string; + public mainCanopy: string; + public reserveCanopy: string; + public equipment: string; } diff --git a/Front/skydivelogs-app/src/services/gear.service.ts b/Front/skydivelogs-app/src/services/gear.service.ts index 4f5e7e3..fc0f3aa 100644 --- a/Front/skydivelogs-app/src/services/gear.service.ts +++ b/Front/skydivelogs-app/src/services/gear.service.ts @@ -10,46 +10,59 @@ import { CacheApiKey } from "../models/cache-api-key.enum"; @Injectable() export class GearService extends BaseService { - constructor(private http: HttpClient) { - super(); - } + constructor(private http: HttpClient) { + super(); + } - public getListOfGears(): Observable> { - let callToApi = this.http.get>(`${this.apiUrl}/Gear`, { headers: this.headers }); - return this.serviceCacheApi.get>(CacheApiKey.Gear, callToApi); - } + public getListOfGears(): Observable> { + let callToApi = this.http.get>(`${this.apiUrl}/Gear`, { + headers: this.headers, + }); + return this.serviceCacheApi.get>( + CacheApiKey.Gear, + callToApi, + ); + } - public addGear(name: string, - manufacturer: string, - minSize: number, - maxSize: number, - aad: string, - mainCanopy: string, - reserveCanopy: string) - { - const bodyNewGear: GearReq = { - id: 0, - name: name, - manufacturer: manufacturer, - minSize: minSize, - maxSize: maxSize, - aad: aad, - mainCanopy: mainCanopy, - reserveCanopy: reserveCanopy - }; + public addGear( + name: string, + manufacturer: string, + minSize: number, + maxSize: number, + aad: string, + mainCanopy: string, + reserveCanopy: string, + equipment: string, + ) { + const bodyNewGear: GearReq = { + id: 0, + name: name, + manufacturer: manufacturer, + minSize: minSize, + maxSize: maxSize, + aad: aad, + mainCanopy: mainCanopy, + reserveCanopy: reserveCanopy, + equipment: equipment, + }; - this.serviceCacheApi.delete(CacheApiKey.Gear); - return this.http.post(`${this.apiUrl}/Gear`, bodyNewGear, { headers: this.headers}); - } + this.serviceCacheApi.delete(CacheApiKey.Gear); + return this.http.post(`${this.apiUrl}/Gear`, bodyNewGear, { + headers: this.headers, + }); + } - public getById(id: number) : Observable { - return this.serviceCacheApi.getByKey>(CacheApiKey.Gear) - .pipe(map(data => { - return data.find(f => f.id === id); - })); - } + public getById(id: number): Observable { + return this.serviceCacheApi + .getByKey>(CacheApiKey.Gear) + .pipe( + map((data) => { + return data.find((f) => f.id === id); + }), + ); + } - public getFromCache(): Observable> { - return this.serviceCacheApi.getByKey>(CacheApiKey.Gear); - } + public getFromCache(): Observable> { + return this.serviceCacheApi.getByKey>(CacheApiKey.Gear); + } }