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 2752b5f63f..a244b4d66b 100644 --- a/src/utilities/gql.ts +++ b/src/utilities/gql.ts @@ -3596,7 +3596,7 @@ const gql = { } deleteConstraintPlanSpecifications: ${Queries.DELETE_CONSTRAINT_SPECIFICATIONS}( where: { - constraint_id: { _in: $constraintSpecIdsToDelete }, + invocation_id: { _in: $constraintSpecIdsToDelete }, } ) { affected_rows