From 5242265f0e05650579c42dd032e5fedbae58ea51 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Mon, 18 Oct 2021 11:58:42 +0100 Subject: [PATCH] Code review refactoring --- .../PropertyControls/FormFieldSelect.svelte | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FormFieldSelect.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FormFieldSelect.svelte index 3991390ce6..65b698d779 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FormFieldSelect.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FormFieldSelect.svelte @@ -21,15 +21,18 @@ $: schema = getSchemaForDatasource($currentAsset, datasource, true).schema $: options = getOptions(schema, type, fieldTypes) - const getOptions = (schema, type, fieldTypes) => { + const getOptions = (schema, type) => { let entries = Object.entries(schema ?? {}) - // fallback to using only field/options fields - if (!fieldTypes) { - fieldTypes = [type] + let types = [] + if (type === "field/options") { + // allow options to be used on both options and string fields + types = [type, "field/string"] + } else { + types = [type] } - const types = fieldTypes.map(fieldType => fieldType.split("/")[1]) + types = types.map(type => type.split("/")[1]) entries = entries.filter(entry => types.includes(entry[1].type)) return entries.map(entry => entry[0])