From 8d1c388dc91887ed07437b7a7a8853e204d5ce67 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 9 Oct 2024 14:40:51 +0200 Subject: [PATCH] feat: hide suggest controls checkbox in audit creation form if no suggestions --- backend/core/serializers.py | 1 + .../Forms/ModelForm/ComplianceAssessmentForm.svelte | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/core/serializers.py b/backend/core/serializers.py index 1180b179b..85eca813f 100644 --- a/backend/core/serializers.py +++ b/backend/core/serializers.py @@ -479,6 +479,7 @@ class Meta: class FrameworkReadSerializer(ReferentialSerializer): folder = FieldsRelatedField() library = FieldsRelatedField(["name", "id"]) + reference_controls = FieldsRelatedField(many=True) class Meta: model = Framework diff --git a/frontend/src/lib/components/Forms/ModelForm/ComplianceAssessmentForm.svelte b/frontend/src/lib/components/Forms/ModelForm/ComplianceAssessmentForm.svelte index 6b77f02c5..bbfe2a9f3 100644 --- a/frontend/src/lib/components/Forms/ModelForm/ComplianceAssessmentForm.svelte +++ b/frontend/src/lib/components/Forms/ModelForm/ComplianceAssessmentForm.svelte @@ -16,6 +16,8 @@ export let initialData: Record = {}; export let object: any = {}; export let context: string; + + let suggestions = false; {#if context === 'fromBaseline' && initialData.baseline} @@ -72,6 +74,7 @@ model.selectOptions['selected_implementation_groups'] = implementation_groups.map( (group) => ({ label: group.name, value: group.ref_id }) ); + suggestions = r['reference_controls'].length > 0; }); } }} @@ -131,7 +134,7 @@ cacheLock={cacheLocks['observation']} bind:cachedValue={formDataCache['observation']} /> -{#if context === 'create'} +{#if context === 'create' && suggestions}