Review updates
This commit is contained in:
parent
92525e7785
commit
da089a5b7b
|
@ -481,27 +481,13 @@ export const getFrontendStore = () => {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
let dataSourceField = definition.settings.find(
|
// Flattened settings
|
||||||
|
const settings = getComponentSettings(componentName)
|
||||||
|
|
||||||
|
let dataSourceField = settings.find(
|
||||||
setting => setting.type == "dataSource" || setting.type == "table"
|
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
|
let defaultDatasource
|
||||||
if (dataSourceField) {
|
if (dataSourceField) {
|
||||||
const _tables = get(tables)
|
const _tables = get(tables)
|
||||||
|
@ -533,7 +519,6 @@ export const getFrontendStore = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate default props
|
// Generate default props
|
||||||
const settings = getComponentSettings(componentName)
|
|
||||||
let props = { ...presetProps }
|
let props = { ...presetProps }
|
||||||
settings.forEach(setting => {
|
settings.forEach(setting => {
|
||||||
if (setting.defaultValue !== undefined) {
|
if (setting.defaultValue !== undefined) {
|
||||||
|
@ -543,7 +528,7 @@ export const getFrontendStore = () => {
|
||||||
|
|
||||||
// Set a default datasource
|
// Set a default datasource
|
||||||
if (dataSourceField && defaultDatasource) {
|
if (dataSourceField && defaultDatasource) {
|
||||||
props["dataSource"] = {
|
props[dataSourceField.key] = {
|
||||||
label: defaultDatasource.name,
|
label: defaultDatasource.name,
|
||||||
tableId: defaultDatasource._id,
|
tableId: defaultDatasource._id,
|
||||||
type: "table",
|
type: "table",
|
||||||
|
|
Loading…
Reference in New Issue