Skip to content

Commit

Permalink
feat: filter feared-events assets choices
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene committed Dec 11, 2024
1 parent 3375def commit 3e18282
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frontend/src/lib/utils/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ export const URL_MODEL_MAP: ModelMap = {
verboseNamePlural: 'Feared events',
foreignKeyFields: [
{ field: 'ebios_rm_study', urlModel: 'ebios-rm', endpointUrl: 'ebios-rm/studies' },
{ field: 'assets', urlModel: 'assets' },
{ field: 'assets', urlModel: 'assets', urlParams: 'ebios_rm_studies=' },
{ field: 'qualifications', urlModel: 'qualifications' }
],
selectFields: [{ field: 'gravity', valueType: 'number', detail: true }]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ export const load: PageServerLoad = async ({ params, fetch }) => {
for (const keyField of foreignKeyFields) {
const model = getModelInfo(keyField.urlModel);
const queryParams = keyField.urlParams ? `?${keyField.urlParams}` : '';
const url = model.endpointUrl
let url = model.endpointUrl
? `${BASE_API_URL}/${model.endpointUrl}/${queryParams}`
: `${BASE_API_URL}/${model.urlModel}/${queryParams}`;
if (model.urlModel === 'assets') {
url = `${BASE_API_URL}/${model.urlModel}/${queryParams}${params.id}`;
console.log(url);
}
const response = await fetch(url);
if (response.ok) {
foreignKeys[keyField.field] = await response.json().then((data) => data.results);
Expand Down

0 comments on commit 3e18282

Please sign in to comment.