Skip to content

Commit

Permalink
fix: Library uuid replaced by name in matrix view (#1198)
Browse files Browse the repository at this point in the history
  • Loading branch information
nas-tabchiche authored Dec 20, 2024
2 parents 5aaa64b + 585d429 commit e5b1b38
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 @@ -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': {
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 e5b1b38

Please sign in to comment.