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
1 changed files with 10 additions and 4 deletions

View File

@ -10,9 +10,15 @@
let drawer let drawer
let tempValue = value || [] let tempValue = value || []
const saveFilter = async () => { const saveOptions = async () => {
// Filter out incomplete options // Filter out incomplete options, default if needed
tempValue = tempValue.filter(option => option.value && option.label) 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) dispatch("change", tempValue)
drawer.hide() drawer.hide()
} }
@ -23,6 +29,6 @@
<svelte:fragment slot="description"> <svelte:fragment slot="description">
Define the options for this picker. Define the options for this picker.
</svelte:fragment> </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" /> <OptionsDrawer bind:options={tempValue} slot="body" />
</Drawer> </Drawer>