From 7356c8b161f0fe44db3675dcdf0736ed976da6ea Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 16 Nov 2022 15:03:45 +0000 Subject: [PATCH] Ensure 'table' type sources are updated with a default datasource. Search visible settings sections for other elements IF a source is not already set. --- .../src/builderStore/store/frontend.js | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 9814bcfc74..6c375b871b 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -481,10 +481,27 @@ export const getFrontendStore = () => { return null } - const dataSourceField = definition.settings.find( - setting => setting.type == "dataSource" + let dataSourceField = definition.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)