Browse Source

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

Allow options picker to be used on text columns
master
Rory Powell 5 years ago
committed by GitHub
parent
commit
5288fb5256
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      packages/builder/src/components/design/PropertiesPanel/PropertyControls/FormFieldSelect.svelte
  2. 2
      packages/client/src/components/app/forms/Field.svelte

16
packages/builder/src/components/design/PropertiesPanel/PropertyControls/FormFieldSelect.svelte

@ -20,12 +20,20 @@
$: schema = getSchemaForDatasource($currentAsset, datasource, true).schema $: schema = getSchemaForDatasource($currentAsset, datasource, true).schema
$: options = getOptions(schema, type) $: options = getOptions(schema, type)
const getOptions = (schema, fieldType) => { const getOptions = (schema, type) => {
let entries = Object.entries(schema ?? {}) let entries = Object.entries(schema ?? {})
if (fieldType) {
fieldType = fieldType.split("/")[1] let types = []
entries = entries.filter(entry => entry[1].type === fieldType) 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]) return entries.map(entry => entry[0])
} }
</script> </script>

2
packages/client/src/components/app/forms/Field.svelte

@ -67,7 +67,7 @@
<Placeholder <Placeholder
text="Add the Field setting to start using your component" 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 <Placeholder
text="This Field setting is the wrong data type for this component" text="This Field setting is the wrong data type for this component"
/> />

Loading…
Cancel
Save