diff --git a/frontend/src/lib/common.ts b/frontend/src/lib/common.ts index 3d829003b2..2a7830eaa4 100644 --- a/frontend/src/lib/common.ts +++ b/frontend/src/lib/common.ts @@ -28,10 +28,41 @@ export interface SchemaProperty { contentEncoding?: 'base64' enum?: string[] } + customErrorMessage?: string properties?: { [name: string]: SchemaProperty } required?: string[] } +export interface ModalSchemaProperty { + selectedType?: string + description: string + name: string + required: boolean + format?: string + pattern?: string + enum_?: string[] + default?: any + items?: { type?: 'string' | 'number' } + contentEncoding?: 'base64' | 'binary' + schema?: Schema + customErrorMessage?: string +} + +export function modalToSchema(schema: ModalSchemaProperty): SchemaProperty { + return { + type: schema.selectedType, + description: schema.description, + pattern: schema.pattern, + default: schema.default, + enum: schema.enum_, + items: schema.items, + contentEncoding: schema.contentEncoding, + format: schema.format, + customErrorMessage: schema.customErrorMessage, + properties: schema.schema?.properties, + required: schema.schema?.required + } +} export type Schema = { $schema: string | undefined type: string diff --git a/frontend/src/lib/components/ArgInput.svelte b/frontend/src/lib/components/ArgInput.svelte index 3ea5436a8e..ff67e061f6 100644 --- a/frontend/src/lib/components/ArgInput.svelte +++ b/frontend/src/lib/components/ArgInput.svelte @@ -1,6 +1,6 @@ @@ -209,47 +214,51 @@ {:else if inputCat == 'list'}
- {#each value ?? [] as v, i} -
- {#if itemsType?.type == 'number'} - - {:else if itemsType?.type == 'string' && itemsType?.contentEncoding == 'base64'} - fileChanged(x, (val) => (value[i] = val))} - multiple={false} - /> - {:else if Array.isArray(itemsType?.enum)} - + {:else if itemsType?.type == 'string' && itemsType?.contentEncoding == 'base64'} + fileChanged(x, (val) => (value[i] = val))} + multiple={false} + /> + {:else if Array.isArray(itemsType?.enum)} + + {:else} + + {/if} + -
- {/each} + + +
+ {/each} + {:else} + List is not an array + {/if}
- {(value ?? []).length} item{(value ?? []).length > 1 ? 's' : ''} + {(value ?? []).length} item{(value ?? []).length != 1 ? 's' : ''} {:else if inputCat == 'resource-object'} @@ -312,12 +321,16 @@ {:else if inputCat == 'date'} {:else if inputCat == 'base64'} - fileChanged(x, (val) => (value = val))} - multiple={false} - /> +
+ fileChanged(x, (val) => (value = val))} + multiple={false} + /> + {#if value?.length} +
File length: {value.length} base64 chars
+ {/if} +
{:else if inputCat == 'resource-string'}
+ {:else if inputCat == 'email'} + {:else if inputCat == 'string'}
diff --git a/frontend/src/lib/components/LightweightSchemaForm.svelte b/frontend/src/lib/components/LightweightSchemaForm.svelte index fdaceff84e..be9ae2ff18 100644 --- a/frontend/src/lib/components/LightweightSchemaForm.svelte +++ b/frontend/src/lib/components/LightweightSchemaForm.svelte @@ -75,6 +75,7 @@ enum_={schema.properties[argName].enum} format={schema.properties[argName].format} contentEncoding={schema.properties[argName].contentEncoding} + customErrorMessage={schema.properties[argName].customErrorMessage} properties={schema.properties[argName].properties} nestedRequired={schema.properties[argName].required} itemsType={schema.properties[argName].items} diff --git a/frontend/src/lib/components/SchemaEditor.svelte b/frontend/src/lib/components/SchemaEditor.svelte index ea2598ae1d..f0c1eca492 100644 --- a/frontend/src/lib/components/SchemaEditor.svelte +++ b/frontend/src/lib/components/SchemaEditor.svelte @@ -1,9 +1,14 @@