1
0
Fork 0
mirror of synced 2024-07-13 18:26:06 +12:00

Merge pull request #5325 from Budibase/bug/sev3/require-option-values

Added validation for options editor
This commit is contained in:
melohagan 2022-04-13 11:31:04 +01:00 committed by GitHub
commit 776761fcb3

View file

@ -10,9 +10,15 @@
let drawer
let tempValue = value || []
const saveFilter = async () => {
// Filter out incomplete options
tempValue = tempValue.filter(option => option.value && option.label)
const saveOptions = async () => {
// Filter out incomplete options, default if needed
tempValue = tempValue.filter(option => option.value || option.label)
for (let i = 0; i < tempValue.length; i++) {
let option = tempValue[i]
option.label = option.label ? option.label : option.value
option.value = option.value ? option.value : option.label
tempValue[i] = option
}
dispatch("change", tempValue)
drawer.hide()
}
@ -23,6 +29,6 @@
<svelte:fragment slot="description">
Define the options for this picker.
</svelte:fragment>
<Button cta slot="buttons" on:click={saveFilter}>Save</Button>
<Button cta slot="buttons" on:click={saveOptions}>Save</Button>
<OptionsDrawer bind:options={tempValue} slot="body" />
</Drawer>