Merge pull request #4750 from Budibase/fix/option-picker-values
Fixes for 409s and option picker values
This commit is contained in:
commit
e58fa37b6e
6 changed files with 29 additions and 8 deletions
|
@ -7,6 +7,7 @@
|
||||||
import RoleSelect from "./PropertyControls/RoleSelect.svelte"
|
import RoleSelect from "./PropertyControls/RoleSelect.svelte"
|
||||||
import ResetFieldsButton from "./PropertyControls/ResetFieldsButton.svelte"
|
import ResetFieldsButton from "./PropertyControls/ResetFieldsButton.svelte"
|
||||||
import { getComponentForSettingType } from "./PropertyControls/componentSettings"
|
import { getComponentForSettingType } from "./PropertyControls/componentSettings"
|
||||||
|
import { Utils } from "@budibase/frontend-core"
|
||||||
|
|
||||||
export let componentDefinition
|
export let componentDefinition
|
||||||
export let componentInstance
|
export let componentInstance
|
||||||
|
@ -40,13 +41,13 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateProp = async (key, value) => {
|
const updateProp = Utils.sequential(async (key, value) => {
|
||||||
try {
|
try {
|
||||||
await store.actions.components.updateProp(key, value)
|
await store.actions.components.updateProp(key, value)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error("Error updating component prop")
|
notifications.error("Error updating component prop")
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
const canRenderControl = setting => {
|
const canRenderControl = setting => {
|
||||||
const control = getComponentForSettingType(setting?.type)
|
const control = getComponentForSettingType(setting?.type)
|
||||||
|
|
|
@ -17,7 +17,7 @@ export const getOptions = (
|
||||||
|
|
||||||
dataProvider?.rows?.forEach(row => {
|
dataProvider?.rows?.forEach(row => {
|
||||||
const value = row?.[valueColumn]
|
const value = row?.[valueColumn]
|
||||||
if (value) {
|
if (value != null) {
|
||||||
const label = row[labelColumn] || value
|
const label = row[labelColumn] || value
|
||||||
optionsSet[value] = { value, label }
|
optionsSet[value] = { value, label }
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ export const getOptions = (
|
||||||
let optionsSet = {}
|
let optionsSet = {}
|
||||||
dataProvider?.rows?.forEach(row => {
|
dataProvider?.rows?.forEach(row => {
|
||||||
const value = row?.[valueColumn]
|
const value = row?.[valueColumn]
|
||||||
if (value) {
|
if (value != null) {
|
||||||
const label = row[labelColumn] || value
|
const label = row[labelColumn] || value
|
||||||
optionsSet[value] = { value, label }
|
optionsSet[value] = { value, label }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
export { createAPIClient } from "./api"
|
export { createAPIClient } from "./api"
|
||||||
export { createLocalStorageStore } from "./stores/localStorage"
|
|
||||||
export { fetchData } from "./fetch/fetchData"
|
export { fetchData } from "./fetch/fetchData"
|
||||||
export * as Constants from "./constants"
|
export * as Constants from "./constants"
|
||||||
export * as LuceneUtils from "./utils/lucene"
|
export * from "./stores"
|
||||||
export * as JSONUtils from "./utils/json"
|
export * from "./utils"
|
||||||
export * as CookieUtils from "./utils/cookies"
|
|
||||||
|
|
1
packages/frontend-core/src/stores/index.js
Normal file
1
packages/frontend-core/src/stores/index.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { createLocalStorageStore } from "./localStorage"
|
4
packages/frontend-core/src/utils/index.js
Normal file
4
packages/frontend-core/src/utils/index.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export * as LuceneUtils from "./lucene"
|
||||||
|
export * as JSONUtils from "./json"
|
||||||
|
export * as CookieUtils from "./cookies"
|
||||||
|
export * as Utils from "./utils"
|
17
packages/frontend-core/src/utils/utils.js
Normal file
17
packages/frontend-core/src/utils/utils.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/**
|
||||||
|
* Utility to wrap an async function and ensure all invocations happen
|
||||||
|
* sequentially.
|
||||||
|
* @param fn the async function to run
|
||||||
|
* @return {Promise} a sequential version of the function
|
||||||
|
*/
|
||||||
|
export const sequential = fn => {
|
||||||
|
let promise
|
||||||
|
return async (...params) => {
|
||||||
|
if (promise) {
|
||||||
|
await promise
|
||||||
|
}
|
||||||
|
promise = fn(...params)
|
||||||
|
await promise
|
||||||
|
promise = null
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue