Skip to content

Commit

Permalink
fix: Library uuid replaced by name in matrix view
Browse files Browse the repository at this point in the history
  • Loading branch information
Axxiar committed Dec 16, 2024
1 parent e9a5f4e commit 585d429
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions backend/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lib/utils/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,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': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,17 @@
{/each}
</ul>
{:else if value.id}
{@const itemHref = `/${
URL_MODEL_MAP['risk-matrices']['foreignKeyFields']?.find(
(item) => item.field === key
)?.urlModel
}/${value.id}`}
<a href={itemHref} class="anchor">{value.str}</a>
{#if key === 'library'}
{@const itemHref = `/libraries/${value.id}?loaded`}
<a href={itemHref} class="anchor">{value.name}</a>
{:else}
{@const itemHref = `/${
URL_MODEL_MAP['risk-matrices']['foreignKeyFields']?.find(
(item) => item.field === key
)?.urlModel
}/${value.id}`}
<a href={itemHref} class="anchor">{value.str}</a>
{/if}
{:else}
{value.str ?? value}
{/if}
Expand Down

0 comments on commit 585d429

Please sign in to comment.