Fix for datasource resolution in validation editor drawer

This commit is contained in:
Dean 2024-01-03 15:30:58 +00:00
parent cb63848245
commit 4343c43148
1 changed files with 12 additions and 3 deletions

View File

@ -12,7 +12,10 @@
} from "@budibase/bbui"
import { currentAsset, selectedComponent } from "builderStore"
import { findClosestMatchingComponent } from "builderStore/componentUtils"
import { getSchemaForDatasource } from "builderStore/dataBinding"
import {
getSchemaForDatasource,
getDatasourceForProvider,
} from "builderStore/dataBinding"
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
import { generate } from "shortid"
@ -124,6 +127,12 @@
],
}
const resolveDatasource = (currentAsset, componentInstance, parent) => {
return (
getDatasourceForProvider(currentAsset, parent || componentInstance) || {}
)
}
$: dataSourceSchema = getDataSourceSchema($currentAsset, $selectedComponent)
$: field = fieldName || $selectedComponent?.field
$: schemaRules = parseRulesFromSchema(field, dataSourceSchema || {})
@ -146,8 +155,8 @@
component._component.endsWith("/formblock") ||
component._component.endsWith("/tableblock")
)
return getSchemaForDatasource(asset, formParent?.dataSource)
const dataSource = resolveDatasource(asset, component, formParent)
return getSchemaForDatasource(asset, dataSource)
}
const parseRulesFromSchema = (field, dataSourceSchema) => {