From d463d156afd75ec9625cfad688ec8cbe5bf6dafa Mon Sep 17 00:00:00 2001 From: deacon Date: Sun, 15 Mar 2026 23:47:22 -0400 Subject: [PATCH] fix: prevent dual-value submission in Add Potential Link modal When a user selects a fact checkbox, clear any custom value for that fact. When a user types a custom value, deselect all fact checkboxes for that fact. This prevents multiple unexpected links from being queued when both a custom value and a fact source value are provided for the same fact template. Fixes #22 --- .../operations/AddPotentialLinkModal.vue | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/operations/AddPotentialLinkModal.vue b/src/components/operations/AddPotentialLinkModal.vue index ef7f47a..8d79591 100644 --- a/src/components/operations/AddPotentialLinkModal.vue +++ b/src/components/operations/AddPotentialLinkModal.vue @@ -99,6 +99,21 @@ const potentialLinksToAdd = computed(() => { const canSelectAgent = computed(() => !props.agent || !props.agent.paw); +// When a custom value is typed, deselect all fact checkboxes for that fact name +function onCustomValueInput(factName) { + selectedPotentialLinkFacts.value[factName].facts.forEach((fact) => { + fact.selected = false; + }); +} + +// When a fact checkbox is selected, clear the custom value for that fact name +function onFactSelected(factName) { + const hasSelected = selectedPotentialLinkFacts.value[factName].facts.some((fact) => fact.selected); + if (hasSelected) { + selectedPotentialLinkFacts.value[factName].customValue = ""; + } +} + const operationSourceFacts = computed(() => props.operation?.source?.facts || []); onMounted(async () => { @@ -246,10 +261,10 @@ const selectPotentialLink = async (link) => { v-tooltip="`There are currently empty fact templates. You can still add this link but it may not run properly.`") font-awesome-icon(icon="fa-exclamation-triangle") .control - input.input(v-model="selectedPotentialLinkFacts[factName].customValue" type="text" placeholder="Enter a custom value") + input.input(v-model="selectedPotentialLinkFacts[factName].customValue" type="text" placeholder="Enter a custom value" @input="onCustomValueInput(factName)") div(v-for="fact in selectedPotentialLinkFacts[factName].facts") label.checkbox - input.mr-2(type="checkbox" v-model="fact.selected") + input.mr-2(type="checkbox" v-model="fact.selected" @change="onFactSelected(factName)") span.mr-2 {{ fact.value }} span.tag.mr-2 {{ fact.origin }}