Merge branch 'develop' of github.com:Budibase/budibase into fix/3721
This commit is contained in:
commit
ec95d20b21
|
@ -22,6 +22,7 @@
|
|||
export let error = null
|
||||
export let fileTags = []
|
||||
export let maximum = null
|
||||
export let extensions = "*"
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
const imageExtensions = [
|
||||
|
@ -207,6 +208,7 @@
|
|||
{disabled}
|
||||
type="file"
|
||||
multiple
|
||||
accept={extensions}
|
||||
on:change={handleFile}
|
||||
/>
|
||||
<svg
|
||||
|
|
|
@ -39,4 +39,4 @@ context("Add Multi-Option Datatype", () => {
|
|||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ Cypress.Commands.add("createApp", name => {
|
|||
}
|
||||
})
|
||||
cy.contains(/Start from scratch/).dblclick()
|
||||
cy.wait(2000)
|
||||
cy.get(".spectrum-Modal").within(() => {
|
||||
cy.get("input").eq(0).type(name).should("have.value", name).blur()
|
||||
cy.get(".spectrum-ButtonGroup").contains("Create app").click()
|
||||
|
|
|
@ -2236,7 +2236,7 @@
|
|||
"setting": "optionsSource",
|
||||
"value": "provider"
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
"type": "options",
|
||||
"key": "customOptions",
|
||||
|
@ -2419,6 +2419,11 @@
|
|||
"label": "Label",
|
||||
"key": "label"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"label": "Extensions",
|
||||
"key": "extensions"
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"label": "Disabled",
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
export let label
|
||||
export let disabled = false
|
||||
export let validation
|
||||
export let extensions
|
||||
|
||||
let fieldState
|
||||
let fieldApi
|
||||
|
@ -52,6 +53,7 @@
|
|||
}}
|
||||
{processFiles}
|
||||
{handleFileTooLarge}
|
||||
{extensions}
|
||||
/>
|
||||
{/if}
|
||||
</Field>
|
||||
|
|
|
@ -141,8 +141,18 @@
|
|||
return
|
||||
}
|
||||
|
||||
// Create validation function based on field schema
|
||||
const schemaConstraints = schema?.[field]?.constraints
|
||||
const validator = createValidatorFromConstraints(
|
||||
schemaConstraints,
|
||||
validationRules,
|
||||
field,
|
||||
table
|
||||
)
|
||||
|
||||
// If we've already registered this field then keep some existing state
|
||||
let initialValue = deepGet(initialValues, field) ?? defaultValue
|
||||
let initialError = null
|
||||
let fieldId = `id-${generateID()}`
|
||||
const existingField = getField(field)
|
||||
if (existingField) {
|
||||
|
@ -156,20 +166,17 @@
|
|||
} else {
|
||||
initialValue = fieldState.value ?? initialValue
|
||||
}
|
||||
|
||||
// If this field has already been registered and we previously had an
|
||||
// error set, then re-run the validator to see if we can unset it
|
||||
if (fieldState.error) {
|
||||
initialError = validator(initialValue)
|
||||
}
|
||||
}
|
||||
|
||||
// Auto columns are always disabled
|
||||
const isAutoColumn = !!schema?.[field]?.autocolumn
|
||||
|
||||
// Create validation function based on field schema
|
||||
const schemaConstraints = schema?.[field]?.constraints
|
||||
const validator = createValidatorFromConstraints(
|
||||
schemaConstraints,
|
||||
validationRules,
|
||||
field,
|
||||
table
|
||||
)
|
||||
|
||||
// Construct field info
|
||||
const fieldInfo = writable({
|
||||
name: field,
|
||||
|
@ -178,7 +185,7 @@
|
|||
fieldState: {
|
||||
fieldId,
|
||||
value: initialValue,
|
||||
error: null,
|
||||
error: initialError,
|
||||
disabled: disabled || fieldDisabled || isAutoColumn,
|
||||
defaultValue,
|
||||
validator,
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
let fieldSchema
|
||||
|
||||
$: flatOptions = optionsSource == null || optionsSource === "schema"
|
||||
$: expandedDefaultValue = expand(defaultValue)
|
||||
$: options = getOptions(
|
||||
optionsSource,
|
||||
fieldSchema,
|
||||
|
@ -28,6 +29,18 @@
|
|||
valueColumn,
|
||||
customOptions
|
||||
)
|
||||
|
||||
const expand = values => {
|
||||
if (!values) {
|
||||
return []
|
||||
}
|
||||
|
||||
if (Array.isArray(values)) {
|
||||
return values
|
||||
}
|
||||
|
||||
return values.split(",").map(value => value.trim())
|
||||
}
|
||||
</script>
|
||||
|
||||
<Field
|
||||
|
@ -35,7 +48,7 @@
|
|||
{label}
|
||||
{disabled}
|
||||
{validation}
|
||||
{defaultValue}
|
||||
defaultValue={expandedDefaultValue}
|
||||
type="array"
|
||||
bind:fieldState
|
||||
bind:fieldApi
|
||||
|
|
Loading…
Reference in New Issue