Merge pull request #10227 from Budibase/fix/10155

Fixing #10155 - some options errors were being swallowed and in gener…
This commit is contained in:
Michael Drury 2023-04-11 14:35:11 +01:00 committed by GitHub
commit 3eafda506f
2 changed files with 18 additions and 14 deletions

View File

@ -42,7 +42,13 @@
</script>
{#if type === "options" && meta.constraints.inclusion.length !== 0}
<Select {label} bind:value options={meta.constraints.inclusion} sort />
<Select
{label}
bind:value
options={meta.constraints.inclusion}
sort
{error}
/>
{:else if type === "datetime"}
<DatePicker
{error}

View File

@ -27,21 +27,19 @@
notifications.success("Row saved successfully")
dispatch("updaterows")
} catch (error) {
if (error.handled) {
const response = error.json
if (response?.errors) {
errors = response.errors
} else if (response?.validationErrors) {
const mappedErrors = {}
for (let field in response.validationErrors) {
mappedErrors[
field
] = `${field} ${response.validationErrors[field][0]}`
}
errors = mappedErrors
const response = error.json
if (error.handled && response?.errors) {
errors = response.errors
} else if (error.handled && response?.validationErrors) {
const mappedErrors = {}
for (let field in response.validationErrors) {
mappedErrors[
field
] = `${field} ${response.validationErrors[field][0]}`
}
errors = mappedErrors
} else {
notifications.error("Failed to save row")
notifications.error(`Failed to save row - ${error.message}`)
}
// Prevent modal closing if there were errors
return false