From 68aeb43ea2c0e58b93ecef837330c0ca59cf178e Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 21 Nov 2022 17:07:00 +0000 Subject: [PATCH] Review updates --- .../src/builderStore/store/frontend.js | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 6c375b871b..dc7264a814 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -481,27 +481,13 @@ export const getFrontendStore = () => { return null } - let dataSourceField = definition.settings.find( + // Flattened settings + const settings = getComponentSettings(componentName) + + let dataSourceField = settings.find( setting => setting.type == "dataSource" || setting.type == "table" ) - if (!dataSourceField) { - // Check other visible sections for datasource/table elements. - const sections = definition.settings.filter( - item => item?.section && item.visible - ) - - for (let section of sections) { - let sectionSourceField = section.settings.find( - setting => setting.type == "dataSource" || setting.type == "table" - ) - if (sectionSourceField) { - dataSourceField = sectionSourceField - break - } - } - } - let defaultDatasource if (dataSourceField) { const _tables = get(tables) @@ -533,7 +519,6 @@ export const getFrontendStore = () => { } // Generate default props - const settings = getComponentSettings(componentName) let props = { ...presetProps } settings.forEach(setting => { if (setting.defaultValue !== undefined) { @@ -543,7 +528,7 @@ export const getFrontendStore = () => { // Set a default datasource if (dataSourceField && defaultDatasource) { - props["dataSource"] = { + props[dataSourceField.key] = { label: defaultDatasource.name, tableId: defaultDatasource._id, type: "table",