Skip to content

Commit d94a088

Browse files
authored
Merge pull request #20830 from jmchilton/fix_sample_sheet_numeric_defaults
Fix optional numeric column definitions for sample sheets.
2 parents 875278c + 42d42c3 commit d94a088

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)