From 346f1d652b6046e280119391c7803ad8488f28f5 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Thu, 14 Oct 2021 16:36:45 +0100 Subject: [PATCH] Allow options picker to be used on text columns --- .../ComponentSettingsSection.svelte | 1 + .../PropertyControls/FormFieldSelect.svelte | 16 +++++++++++----- .../PropertyControls/PropertyControl.svelte | 2 ++ packages/client/manifest.json | 1 + .../client/src/components/app/forms/Field.svelte | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/components/design/PropertiesPanel/ComponentSettingsSection.svelte b/packages/builder/src/components/design/PropertiesPanel/ComponentSettingsSection.svelte index f047e9316b..ca6f0d24d1 100644 --- a/packages/builder/src/components/design/PropertiesPanel/ComponentSettingsSection.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/ComponentSettingsSection.svelte @@ -75,6 +75,7 @@ {#if canRenderControl(setting)} { + const getOptions = (schema, type, fieldTypes) => { let entries = Object.entries(schema ?? {}) - if (fieldType) { - fieldType = fieldType.split("/")[1] - entries = entries.filter(entry => entry[1].type === fieldType) + + // fallback to using only field/options fields + if (!fieldTypes) { + fieldTypes = [type] } + + const types = fieldTypes.map(fieldType => fieldType.split("/")[1]) + entries = entries.filter(entry => types.includes(entry[1].type)) + return entries.map(entry => entry[0]) } diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/PropertyControl.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/PropertyControl.svelte index 4ca7d9fc12..193174fb52 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/PropertyControl.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/PropertyControl.svelte @@ -13,6 +13,7 @@ export let control = null export let key = "" export let type = "" + export let fieldTypes = [] export let value = null export let props = {} export let onChange = () => {} @@ -82,6 +83,7 @@ name={key} text={label} {type} + {fieldTypes} {...props} /> {#if bindable && !key.startsWith("_") && type === "text"} diff --git a/packages/client/manifest.json b/packages/client/manifest.json index 2e64b1fb4c..f377a3ede4 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -1950,6 +1950,7 @@ "settings": [ { "type": "field/options", + "fieldTypes": ["field/options", "field/string"], "label": "Field", "key": "field" }, diff --git a/packages/client/src/components/app/forms/Field.svelte b/packages/client/src/components/app/forms/Field.svelte index 3eb52420e5..ca607e7315 100644 --- a/packages/client/src/components/app/forms/Field.svelte +++ b/packages/client/src/components/app/forms/Field.svelte @@ -67,7 +67,7 @@ - {:else if fieldSchema?.type && fieldSchema?.type !== type} + {:else if fieldSchema?.type && fieldSchema?.type !== type && type !== "options"}