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