diff --git a/frontend/src/lib/components/Forms/Score.svelte b/frontend/src/lib/components/Forms/Score.svelte index e309ce9f9..950582e66 100644 --- a/frontend/src/lib/components/Forms/Score.svelte +++ b/frontend/src/lib/components/Forms/Score.svelte @@ -30,30 +30,15 @@ export let scores_definition: ScoresDefinition[] = []; - const tables = {}; - export let form: SuperForm>; const { value, errors, constraints } = formFieldProxy(form, field); - let isScoredField = formFieldProxy(form, `is_scored`)['value']; - let isScored: boolean; - if ($isScoredField === undefined) { - isScored = $value !== null; - } else { - isScored = $isScoredField; - $value = $value ?? min_score; - } + const isScored = formFieldProxy(form, `is_scored`)['value']; - function handleIsScoredChange() { - if ($isScoredField === undefined) { - $value = isScored ? $value || min_score : null; - } else { - $isScoredField = isScored; - } - } + $: $value = $isScored ? ($value ?? min_score) : $value; if (always_enabled) { - isScored = true; + $isScored = true; } $: if (max_score === 100) score_step = 5; @@ -93,13 +78,12 @@ max={max_score} step={score_step} ticked - disabled={!isScored} + disabled={!$isScored} >
{#if !always_enabled} {m.scoringHelpText()}

{/if} - {#if isScored && scores_definition && $value !== null} + {#if $isScored && scores_definition && $value !== null} {#each scores_definition as definition} {#if definition.score === $value}

@@ -120,20 +104,20 @@ {securityObjectiveDisplay($value) ?? (isScored ? $value : '--')}{securityObjectiveDisplay($value) ?? ($isScored ? $value : '--')} {:else} {isScored ? $value : '--'}{$isScored ? $value : '--'} {/if}