diff --git a/frontend/src/lib/components/DynamicInput.svelte b/frontend/src/lib/components/DynamicInput.svelte index 23d2912052..289641a94a 100644 --- a/frontend/src/lib/components/DynamicInput.svelte +++ b/frontend/src/lib/components/DynamicInput.svelte @@ -36,14 +36,16 @@ let { value = $bindable(), helperScript, format, otherArgs: otherArgs }: Props = $props() - const [inputType, entrypoint] = format.includes('-') ? format.split('-', 2) : [format, ''] + let [inputType, entrypoint] = $derived(format.includes('-') ? format.split('-', 2) : [format, '']) - const isMultiple = inputType === 'dynmultiselect' - const isSelect = inputType === 'dynselect' || inputType === 'dynmultiselect' + let isMultiple = $derived(inputType === 'dynmultiselect') + let isSelect = $derived(inputType === 'dynselect' || inputType === 'dynmultiselect') - if (isMultiple && value === undefined) { - value = [] - } + $effect(() => { + if (isMultiple && value === undefined) { + value = [] + } + }) let resultJobLoader: JobLoader | undefined = $state() let _items = usePromise(getItemsFromOptions, { clearValueOnRefresh: false }) @@ -97,7 +99,7 @@ $effect(() => { if (_items.value && value !== undefined && isSelect) { - if (isMultiple && Array.isArray(value)) { + if (isMultiple && Array.isArray(value) && Array.isArray(_items.value)) { const availableValues = new Set(_items.value.map((x) => x.value)) const filteredValue = value.filter((v) => availableValues.has(v)) if (filteredValue.length !== value.length) { diff --git a/frontend/src/lib/components/EditableSchemaForm.svelte b/frontend/src/lib/components/EditableSchemaForm.svelte index 9c91888960..a138a6cd1d 100644 --- a/frontend/src/lib/components/EditableSchemaForm.svelte +++ b/frontend/src/lib/components/EditableSchemaForm.svelte @@ -372,6 +372,14 @@ } function updateDynCode(functionName: string, lang: ScriptLang = 'bun') { + if ( + (lang == 'bun' && dynCode?.includes(`function ${functionName}`)) || + (lang == 'python3' && dynCode?.includes(`def ${functionName}`)) + ) { + // Don't add the function if it already exists + return + } + const generateFn = DynamicInput.getGenerateTemplateFn(lang) const code = generateFn(functionName) dynCode = dynCode ? dynCode.concat(code) : code @@ -701,6 +709,15 @@ nullable: undefined, required: undefined } + + if ( + isDynMultiselect && + args && + !Array.isArray(args?.[argName]) + ) { + args[argName] = [] + } + if (isS3) { schema.properties[argName] = { ...emptyProperty,