From c5f390d2fbea46b7e18c37fe6f2c9d53da52e10e Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Mon, 16 Sep 2024 20:57:47 +0200 Subject: [PATCH] feat: fix table-mode --- frontend/messages/en.json | 4 +- .../[id=uuid]/table-mode/+page.server.ts | 3 + .../[id=uuid]/table-mode/+page.svelte | 111 ++++++++++-------- 3 files changed, 69 insertions(+), 49 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index ec76240ea..018ef4d71 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -174,6 +174,7 @@ "dueDate": "Due date", "attachment": "Attachment", "observation": "Observation", + "noObservation": "No observation", "importMatrices": "Import matrices", "importFrameworks": "Import frameworks", "summary": "Summary", @@ -725,5 +726,6 @@ "conclusion": "Conclusion", "blocker": "Blocker", "createUser": "Create user", - "createUserHelpText": "Create or link a third party user to the representative based on the email" + "createUserHelpText": "Create or link a third party user to the representative based on the email", + "nameDuplicate": "Name already exists" } diff --git a/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/table-mode/+page.server.ts b/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/table-mode/+page.server.ts index 5546c3948..b376023de 100644 --- a/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/table-mode/+page.server.ts +++ b/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/table-mode/+page.server.ts @@ -134,6 +134,9 @@ export const actions: Actions = { setFlash({ type: 'error', message: response.error }, event); return { createForm: form }; } + if (response[0]) { + setError(form, 'non_field_errors', m.nameDuplicate()); + } Object.entries(response).forEach(([key, value]) => { setError(form, key, value); }); diff --git a/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/table-mode/+page.svelte b/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/table-mode/+page.svelte index 424e2e350..a8e794f12 100644 --- a/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/table-mode/+page.svelte +++ b/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/table-mode/+page.svelte @@ -110,7 +110,7 @@ modalStore.trigger(modal); } - let addeddEvidence = 0; + let addedEvidence = 0; $: if (createdEvidence && shallow) { data.requirements @@ -120,7 +120,7 @@ id: createdEvidence.id }); createdEvidence = undefined; - addeddEvidence = +1; + addedEvidence = +1; } function modalConfirmDelete(id: string, name: string): void { @@ -144,6 +144,7 @@ }; modalStore.trigger(modal); data.requirements.forEach((requirementAssessment) => { + console.log(requirementAssessment.evidences); requirementAssessment.evidences = requirementAssessment.evidences.filter( (evidence) => evidence.id !== id ); @@ -296,37 +297,45 @@ >
-