1
0
Fork 0
mirror of synced 2024-06-27 02:20:35 +12:00

Add more comments to clarify data binding behaviour

This commit is contained in:
Andrew Kingston 2021-12-06 12:14:06 +00:00
parent bd00ab28b4
commit 2a814abd53

View file

@ -404,11 +404,18 @@ export const getSchemaForDatasource = (asset, datasource, isForm = false) => {
// "jsonarray" datasources are arrays inside JSON fields
else if (type === "jsonarray") {
table = tables.find(table => table._id === datasource.tableId)
// We parse the label of the datasource to work out where we are inside
// the structure. We can use this to know which part of the schema
// is available underneath our current position.
const keysToSchema = datasource.label.split(".").slice(2)
let jsonSchema = table?.schema
for (let i = 0; i < keysToSchema.length; i++) {
jsonSchema = jsonSchema[keysToSchema[i]].schema
}
// We need to convert the JSON schema into a more typical looking table
// schema so that it works with the rest of the platform
schema = convertJSONSchemaToTableSchema(jsonSchema, true)
}