diff --git a/frontend/src/lib/utils/crud.ts b/frontend/src/lib/utils/crud.ts index 0c9c667f46..49f30e7ab8 100644 --- a/frontend/src/lib/utils/crud.ts +++ b/frontend/src/lib/utils/crud.ts @@ -114,6 +114,7 @@ interface Field { interface SelectField { field: string; detail?: boolean; + valueType?: 'string' | 'number'; } export interface ModelMapEntry { @@ -620,7 +621,8 @@ export const URL_MODEL_MAP: ModelMap = { { field: 'ebios_rm_study', urlModel: 'ebios-rm' }, { field: 'assets', urlModel: 'assets' }, { field: 'qualifications', urlModel: 'qualifications' } - ] + ], + selectFields: [{ field: 'gravity', valueType: 'number', detail: true }] } }; diff --git a/frontend/src/lib/utils/load.ts b/frontend/src/lib/utils/load.ts index 25155d91f5..b4a42ec111 100644 --- a/frontend/src/lib/utils/load.ts +++ b/frontend/src/lib/utils/load.ts @@ -109,7 +109,7 @@ export const loadDetail = async ({ event, model, id }) => { selectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { diff --git a/frontend/src/routes/(app)/(internal)/[model=urlmodel]/+page.server.ts b/frontend/src/routes/(app)/(internal)/[model=urlmodel]/+page.server.ts index 61f4258526..fe10f5bf23 100644 --- a/frontend/src/routes/(app)/(internal)/[model=urlmodel]/+page.server.ts +++ b/frontend/src/routes/(app)/(internal)/[model=urlmodel]/+page.server.ts @@ -48,7 +48,7 @@ export const load: PageServerLoad = async ({ params, fetch }) => { selectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { diff --git a/frontend/src/routes/(app)/(internal)/[model=urlmodel]/[id=uuid]/edit/+layout.server.ts b/frontend/src/routes/(app)/(internal)/[model=urlmodel]/[id=uuid]/edit/+layout.server.ts index a6d843e1e8..918df2f186 100644 --- a/frontend/src/routes/(app)/(internal)/[model=urlmodel]/[id=uuid]/edit/+layout.server.ts +++ b/frontend/src/routes/(app)/(internal)/[model=urlmodel]/[id=uuid]/edit/+layout.server.ts @@ -65,7 +65,7 @@ export const load: LayoutServerLoad = async (event) => { if (selectFields) { for (const selectField of selectFields) { - const url = `${BASE_API_URL}/${event.params.model}/${ + const url = `${BASE_API_URL}/${model.endpointUrl ?? event.params.model}/${ selectField.detail ? event.params.id + '/' : '' }${selectField.field}/`; const response = await event.fetch(url); @@ -73,7 +73,7 @@ export const load: LayoutServerLoad = async (event) => { selectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { diff --git a/frontend/src/routes/(app)/(internal)/ebios-rm/+page.server.ts b/frontend/src/routes/(app)/(internal)/ebios-rm/+page.server.ts index 1c395758c3..809ca81b9d 100644 --- a/frontend/src/routes/(app)/(internal)/ebios-rm/+page.server.ts +++ b/frontend/src/routes/(app)/(internal)/ebios-rm/+page.server.ts @@ -50,7 +50,7 @@ export const load: PageServerLoad = async ({ params, fetch }) => { selectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { diff --git a/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-one/baseline/+page.server.ts b/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-one/baseline/+page.server.ts index b4dd9b6c2f..2d907c25fc 100644 --- a/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-one/baseline/+page.server.ts +++ b/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-one/baseline/+page.server.ts @@ -58,7 +58,7 @@ export const load: PageServerLoad = async ({ params, fetch }) => { selectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { diff --git a/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-one/ebios-rm-study/+page.server.ts b/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-one/ebios-rm-study/+page.server.ts index e28cc52ea3..346bfdee2f 100644 --- a/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-one/ebios-rm-study/+page.server.ts +++ b/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-one/ebios-rm-study/+page.server.ts @@ -45,7 +45,7 @@ export const load: PageServerLoad = async (event) => { selectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { diff --git a/frontend/src/routes/(app)/(internal)/risk-assessments/[id=uuid]/+layout.server.ts b/frontend/src/routes/(app)/(internal)/risk-assessments/[id=uuid]/+layout.server.ts index f1d7479658..80f149cec1 100644 --- a/frontend/src/routes/(app)/(internal)/risk-assessments/[id=uuid]/+layout.server.ts +++ b/frontend/src/routes/(app)/(internal)/risk-assessments/[id=uuid]/+layout.server.ts @@ -94,7 +94,7 @@ export const load: LayoutServerLoad = async ({ fetch, params }) => { selectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { diff --git a/frontend/src/routes/(app)/(internal)/risk-matrices/[id=uuid]/+layout.server.ts b/frontend/src/routes/(app)/(internal)/risk-matrices/[id=uuid]/+layout.server.ts index bfc57593b6..36d5cfa306 100644 --- a/frontend/src/routes/(app)/(internal)/risk-matrices/[id=uuid]/+layout.server.ts +++ b/frontend/src/routes/(app)/(internal)/risk-matrices/[id=uuid]/+layout.server.ts @@ -69,7 +69,7 @@ export const load: LayoutServerLoad = async ({ fetch, params }) => { selectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { diff --git a/frontend/src/routes/(app)/(internal)/risk-scenarios/[id=uuid]/edit/+page.server.ts b/frontend/src/routes/(app)/(internal)/risk-scenarios/[id=uuid]/edit/+page.server.ts index 1f9f712218..52682d0c13 100644 --- a/frontend/src/routes/(app)/(internal)/risk-scenarios/[id=uuid]/edit/+page.server.ts +++ b/frontend/src/routes/(app)/(internal)/risk-scenarios/[id=uuid]/edit/+page.server.ts @@ -79,7 +79,7 @@ export const load: PageServerLoad = async ({ params, fetch }) => { selectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { @@ -122,7 +122,7 @@ export const load: PageServerLoad = async ({ params, fetch }) => { .then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ) ) @@ -152,7 +152,7 @@ export const load: PageServerLoad = async ({ params, fetch }) => { measureSelectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { diff --git a/frontend/src/routes/(app)/(internal)/settings/+page.server.ts b/frontend/src/routes/(app)/(internal)/settings/+page.server.ts index 450eab6b2a..cc2dba5b97 100644 --- a/frontend/src/routes/(app)/(internal)/settings/+page.server.ts +++ b/frontend/src/routes/(app)/(internal)/settings/+page.server.ts @@ -28,7 +28,7 @@ export const load: PageServerLoad = async ({ fetch }) => { selectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { @@ -47,7 +47,7 @@ export const load: PageServerLoad = async ({ fetch }) => { selectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { diff --git a/frontend/src/routes/(app)/(third-party)/[model=thirdparty_urlmodels]/+page.server.ts b/frontend/src/routes/(app)/(third-party)/[model=thirdparty_urlmodels]/+page.server.ts index e1a02c4631..ce9f05aabd 100644 --- a/frontend/src/routes/(app)/(third-party)/[model=thirdparty_urlmodels]/+page.server.ts +++ b/frontend/src/routes/(app)/(third-party)/[model=thirdparty_urlmodels]/+page.server.ts @@ -51,7 +51,7 @@ export const load: PageServerLoad = async ({ params, fetch }) => { selectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { diff --git a/frontend/src/routes/(app)/(third-party)/[model=thirdparty_urlmodels]/[id=uuid]/edit/+layout.server.ts b/frontend/src/routes/(app)/(third-party)/[model=thirdparty_urlmodels]/[id=uuid]/edit/+layout.server.ts index 5b0ef39136..c152b8703b 100644 --- a/frontend/src/routes/(app)/(third-party)/[model=thirdparty_urlmodels]/[id=uuid]/edit/+layout.server.ts +++ b/frontend/src/routes/(app)/(third-party)/[model=thirdparty_urlmodels]/[id=uuid]/edit/+layout.server.ts @@ -67,7 +67,7 @@ export const load: LayoutServerLoad = async (event) => { selectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { diff --git a/frontend/src/routes/(app)/(third-party)/compliance-assessments/[id=uuid]/+page.server.ts b/frontend/src/routes/(app)/(third-party)/compliance-assessments/[id=uuid]/+page.server.ts index 6ee0140c15..983c9c84a3 100644 --- a/frontend/src/routes/(app)/(third-party)/compliance-assessments/[id=uuid]/+page.server.ts +++ b/frontend/src/routes/(app)/(third-party)/compliance-assessments/[id=uuid]/+page.server.ts @@ -71,7 +71,7 @@ export const load = (async ({ fetch, params }) => { selectOptions[selectField.field] = await response.json().then((data) => Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })) ); } else { diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts index 08e68fed12..9670f96578 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts @@ -72,7 +72,7 @@ export const load = (async ({ fetch, params }) => { if (data) { selectOptions[selectField.field] = Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })); } }) @@ -98,7 +98,7 @@ export const load = (async ({ fetch, params }) => { if (data) { measureSelectOptions[selectField.field] = Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })); } else { console.error(`Failed to fetch data for ${selectField.field}: ${response.statusText}`); @@ -169,7 +169,7 @@ export const load = (async ({ fetch, params }) => { if (data) { evidenceSelectOptions[selectField.field] = Object.entries(data).map(([key, value]) => ({ label: value, - value: key + value: selectField.valueType === 'number' ? parseInt(key) : key })); } })