Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Library uuid replaced by name in matrix view #1198

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading