From 1ffe48882612cfb03da0427316dbc4daa7caeb86 Mon Sep 17 00:00:00 2001 From: Danielo Rodriguez Date: Fri, 5 Jul 2024 19:52:54 +0200 Subject: [PATCH 1/2] fix(builder): properly save the isSet condition --- src/views/components/FormBuilder/ConditionInput.svelte | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/views/components/FormBuilder/ConditionInput.svelte b/src/views/components/FormBuilder/ConditionInput.svelte index 18e3305e..bc0a70c0 100644 --- a/src/views/components/FormBuilder/ConditionInput.svelte +++ b/src/views/components/FormBuilder/ConditionInput.svelte @@ -28,11 +28,20 @@ }), ); if (O.isSome($valueField)) { + // By the time we are able to set a value, the condition is complete so we can submit it + // Using each of the set functions will ensure type safety if ($valueField.value.type === "dropdown") $valueField.value.set(booleanValue); if ($valueField.value.type === "text") $valueField.value.set(textValue); if ($valueField.value.type === "number") $valueField.value.set(numberValue); } } + $: { + if ($conditionType === "isSet") { + // This is the only case where we can submit a condition without a value + if ($dependencyName !== condition.dependencyName && $dependencyName !== undefined) + onChange({ type: "isSet", dependencyName: $dependencyName }); + } + } From 0d23e0b8b56877f566b753f738f36497b40c5c0d Mon Sep 17 00:00:00 2001 From: Danielo Rodriguez Date: Fri, 5 Jul 2024 19:53:19 +0200 Subject: [PATCH 2/2] feat(runtime): allow the select to be used as condition for other fields --- src/core/input/dependentFields.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/input/dependentFields.ts b/src/core/input/dependentFields.ts index 8d00d03a..f1fcf063 100644 --- a/src/core/input/dependentFields.ts +++ b/src/core/input/dependentFields.ts @@ -48,7 +48,9 @@ export function availableConditionsForInput(input: FieldDefinition["input"]): Co case "time": case "datetime": return ["isSet"]; + // Select values are always set, so that's why we don't have an "isSet" condition case "select": + return ["startsWith", "endsWith", "isExactly", "contains"]; case "multiselect": case "tag": case "dataview":