diff --git a/backend/core/serializers.py b/backend/core/serializers.py
index 43332b224..6595dd66a 100644
--- a/backend/core/serializers.py
+++ b/backend/core/serializers.py
@@ -119,6 +119,7 @@ class AssessmentReadSerializer(BaseModelSerializer):
class RiskMatrixReadSerializer(ReferentialSerializer):
folder = FieldsRelatedField()
json_definition = serializers.JSONField(source="get_json_translated")
+ library = FieldsRelatedField(["name", "id"])
class Meta:
model = RiskMatrix
diff --git a/frontend/src/lib/utils/crud.ts b/frontend/src/lib/utils/crud.ts
index 2a23ce371..609b3cb71 100644
--- a/frontend/src/lib/utils/crud.ts
+++ b/frontend/src/lib/utils/crud.ts
@@ -178,7 +178,8 @@ export const URL_MODEL_MAP: ModelMap = {
verboseName: 'Risk matrix',
verboseNamePlural: 'Risk matrices',
foreignKeyFields: [
- { field: 'folder', urlModel: 'folders', urlParams: 'content_type=DO&content_type=GL' }
+ { field: 'folder', urlModel: 'folders', urlParams: 'content_type=DO&content_type=GL' },
+ { field: 'library', urlModel: 'libraries' }
]
},
'risk-assessments': {
diff --git a/frontend/src/routes/(app)/(internal)/risk-matrices/[id=uuid]/+page.svelte b/frontend/src/routes/(app)/(internal)/risk-matrices/[id=uuid]/+page.svelte
index d4c653f8a..e5947f4ec 100644
--- a/frontend/src/routes/(app)/(internal)/risk-matrices/[id=uuid]/+page.svelte
+++ b/frontend/src/routes/(app)/(internal)/risk-matrices/[id=uuid]/+page.svelte
@@ -38,12 +38,17 @@
{/each}
{:else if value.id}
- {@const itemHref = `/${
- URL_MODEL_MAP['risk-matrices']['foreignKeyFields']?.find(
- (item) => item.field === key
- )?.urlModel
- }/${value.id}`}
- {value.str}
+ {#if key === 'library'}
+ {@const itemHref = `/libraries/${value.id}?loaded`}
+ {value.name}
+ {:else}
+ {@const itemHref = `/${
+ URL_MODEL_MAP['risk-matrices']['foreignKeyFields']?.find(
+ (item) => item.field === key
+ )?.urlModel
+ }/${value.id}`}
+ {value.str}
+ {/if}
{:else}
{value.str ?? value}
{/if}