From 5a56e2594ac454799402f24d67c7f1faf43e5df8 Mon Sep 17 00:00:00 2001 From: bduran Date: Mon, 11 Nov 2024 10:48:28 -0800 Subject: [PATCH] fix constraint invocation deletion --- src/components/modals/ManagePlanConstraintsModal.svelte | 9 +++++---- src/utilities/gql.ts | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/modals/ManagePlanConstraintsModal.svelte b/src/components/modals/ManagePlanConstraintsModal.svelte index 376114195b..424aa45dc3 100644 --- a/src/components/modals/ManagePlanConstraintsModal.svelte +++ b/src/components/modals/ManagePlanConstraintsModal.svelte @@ -211,11 +211,12 @@ const isSelected = selectedConstraints[constraintId]; // if we find at least one constraint invocation with the selected constraint_id, we don't want to insert this constraint_id into the plan spec // i.e. this constraint was already selected when we entered the modal, so we don't want to kick off an update, which would cause a duplicate invocation to appear - const constraintAlreadyExistsInPlanSpec = - $allowedConstraintPlanSpecs.find(e => e.constraint_id === constraintId) !== undefined; + const constraintsInPlanSpecification = $allowedConstraintPlanSpecs.filter( + constraintPlanSpecification => constraintPlanSpecification.constraint_id === constraintId, + ); if (isSelected) { - if (!constraintAlreadyExistsInPlanSpec) { + if (!constraintsInPlanSpecification.length) { return { ...prevConstraintPlanSpecUpdates, constraintPlanSpecsToAdd: [ @@ -235,7 +236,7 @@ ...prevConstraintPlanSpecUpdates, constraintPlanSpecIdsToDelete: [ ...prevConstraintPlanSpecUpdates.constraintPlanSpecIdsToDelete, - constraintId, + ...constraintsInPlanSpecification.map(({ invocation_id }) => invocation_id), ], }; } diff --git a/src/utilities/gql.ts b/src/utilities/gql.ts index 946e585d10..a8266f2a33 100644 --- a/src/utilities/gql.ts +++ b/src/utilities/gql.ts @@ -3588,7 +3588,7 @@ const gql = { } deleteConstraintPlanSpecifications: ${Queries.DELETE_CONSTRAINT_SPECIFICATIONS}( where: { - constraint_id: { _in: $constraintSpecIdsToDelete }, + invocation_id: { _in: $constraintSpecIdsToDelete }, } ) { affected_rows