Multifield Input Autoselect All Fields (#8884)
* Multifield Input Autoselect All Fields * PR Feedback * PR Feedback * Linting
This commit is contained in:
parent
ddb515a566
commit
d0d73a8b51
|
@ -25,6 +25,7 @@ import {
|
||||||
DB_TYPE_INTERNAL,
|
DB_TYPE_INTERNAL,
|
||||||
DB_TYPE_EXTERNAL,
|
DB_TYPE_EXTERNAL,
|
||||||
} from "constants/backend"
|
} from "constants/backend"
|
||||||
|
import { getSchemaForDatasource } from "builderStore/dataBinding"
|
||||||
|
|
||||||
const INITIAL_FRONTEND_STATE = {
|
const INITIAL_FRONTEND_STATE = {
|
||||||
apps: [],
|
apps: [],
|
||||||
|
@ -524,7 +525,9 @@ export const getFrontendStore = () => {
|
||||||
// Generate default props
|
// Generate default props
|
||||||
let props = { ...presetProps }
|
let props = { ...presetProps }
|
||||||
settings.forEach(setting => {
|
settings.forEach(setting => {
|
||||||
if (setting.defaultValue !== undefined) {
|
if (setting.type === "multifield" && setting.selectAllFields) {
|
||||||
|
props[setting.key] = Object.keys(defaultDatasource.schema || {})
|
||||||
|
} else if (setting.defaultValue !== undefined) {
|
||||||
props[setting.key] = setting.defaultValue
|
props[setting.key] = setting.defaultValue
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1041,6 +1044,27 @@ export const getFrontendStore = () => {
|
||||||
if (component[name] === value) {
|
if (component[name] === value) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const settings = getComponentSettings(component._component)
|
||||||
|
const updatedSetting = settings.find(setting => setting.key === name)
|
||||||
|
|
||||||
|
if (
|
||||||
|
updatedSetting.type === "dataSource" ||
|
||||||
|
updatedSetting.type === "table"
|
||||||
|
) {
|
||||||
|
const { schema } = getSchemaForDatasource(null, value)
|
||||||
|
const columnNames = Object.keys(schema || {})
|
||||||
|
const multifieldKeysToSelectAll = settings
|
||||||
|
.filter(setting => {
|
||||||
|
return setting.type === "multifield" && setting.selectAllFields
|
||||||
|
})
|
||||||
|
.map(setting => setting.key)
|
||||||
|
|
||||||
|
multifieldKeysToSelectAll.forEach(key => {
|
||||||
|
component[key] = columnNames
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
component[name] = value
|
component[name] = value
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -5118,7 +5118,8 @@
|
||||||
{
|
{
|
||||||
"type": "multifield",
|
"type": "multifield",
|
||||||
"label": "Fields",
|
"label": "Fields",
|
||||||
"key": "fields"
|
"key": "fields",
|
||||||
|
"selectAllFields": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "select",
|
"type": "select",
|
||||||
|
@ -5284,7 +5285,8 @@
|
||||||
"type": "multifield",
|
"type": "multifield",
|
||||||
"label": "Fields",
|
"label": "Fields",
|
||||||
"key": "detailFields",
|
"key": "detailFields",
|
||||||
"nested": true
|
"nested": true,
|
||||||
|
"selectAllFields": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue