Skip to content

Commit 42d42c3

Browse files
committed
Fix optional numeric column definitions for sample sheets.
It would work properly the first time but then regress on reload and resave in the form because this initialization logic wasn't taking into account optional parameter types.
1 parent fcb5e41 commit 42d42c3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

client/src/components/Workflow/Editor/Forms/FormColumnDefinition.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,19 @@ const isOptional = ref(props.value.optional ?? false);
176176
const defaultBoolean = ref(props.value.default_value === null ? "null" : props.value.default_value ? "true" : "false");
177177
const defaultString = ref(props.value.default_value || "");
178178
// form framework doesn't yield typed values it seems
179-
const defaultIntAsStr = ref(props.value.default_value ? props.value.default_value.toString() : "0");
180-
const defaultFloatAsStr = ref(props.value.default_value ? props.value.default_value.toString() : "0.0");
179+
180+
function defaultNumberAsString(defaultForType: string): string {
181+
if (props.value.default_value !== null && props.value.default_value !== undefined) {
182+
return props.value.default_value.toString();
183+
} else if (props.value.optional) {
184+
return "";
185+
} else {
186+
return defaultForType;
187+
}
188+
}
189+
190+
const defaultIntAsStr = ref(defaultNumberAsString("0"));
191+
const defaultFloatAsStr = ref(defaultNumberAsString("0.0"));
181192
182193
watch(isOptional, setIsOptional);
183194
watch(defaultIntAsStr, setDefaultByType);

0 commit comments

Comments
 (0)