Merge pull request #3015 from Budibase/options-text-columns

Allow options picker to be used on text columns
This commit is contained in:
Rory Powell 2021-10-18 12:34:40 +01:00 committed by GitHub
commit 20eb28e286
2 changed files with 13 additions and 5 deletions

View File

@ -20,12 +20,20 @@
$: schema = getSchemaForDatasource($currentAsset, datasource, true).schema
$: options = getOptions(schema, type)
const getOptions = (schema, fieldType) => {
const getOptions = (schema, type) => {
let entries = Object.entries(schema ?? {})
if (fieldType) {
fieldType = fieldType.split("/")[1]
entries = entries.filter(entry => entry[1].type === fieldType)
let types = []
if (type === "field/options") {
// allow options to be used on both options and string fields
types = [type, "field/string"]
} else {
types = [type]
}
types = types.map(type => type.split("/")[1])
entries = entries.filter(entry => types.includes(entry[1].type))
return entries.map(entry => entry[0])
}
</script>

View File

@ -67,7 +67,7 @@
<Placeholder
text="Add the Field setting to start using your component"
/>
{:else if fieldSchema?.type && fieldSchema?.type !== type}
{:else if fieldSchema?.type && fieldSchema?.type !== type && type !== "options"}
<Placeholder
text="This Field setting is the wrong data type for this component"
/>