Fix table row selection bindings not being generated, add row selection bindings for table blocks, update readable text for row selection bindings

This commit is contained in:
Andrew Kingston 2022-02-24 09:17:27 +00:00
parent 6573835c13
commit e38cc1c079
1 changed files with 25 additions and 14 deletions

View File

@ -32,7 +32,7 @@ export const getBindableProperties = (asset, componentId) => {
const urlBindings = getUrlBindings(asset)
const deviceBindings = getDeviceBindings()
const stateBindings = getStateBindings()
const rowBindings = getRowBindings(asset, componentId)
const rowBindings = getRowBindings(asset)
return [
...contextBindings,
...urlBindings,
@ -320,22 +320,33 @@ const getDeviceBindings = () => {
/**
* Gets all row bindings that are globally available.
*/
const getRowBindings = () => {
let tables = []
getAllAssets().forEach(asset => {
tables = findAllMatchingComponents(asset.props, component =>
component._component.endsWith("table")
)
})
const getRowBindings = asset => {
let bindings = []
if (get(store).clientFeatures?.rowSelection) {
// Add bindings for table components
let tables = findAllMatchingComponents(asset.props, component =>
component._component.endsWith("table")
)
const safeState = makePropSafe("rowSelection")
bindings = tables.map(table => ({
type: "context",
runtimeBinding: `${safeState}.${makePropSafe(table._id)}`,
readableBinding: `${table._instanceName}.Rows`,
}))
bindings = bindings.concat(
tables.map(table => ({
type: "context",
runtimeBinding: `${safeState}.${makePropSafe(table._id)}`,
readableBinding: `${table._instanceName}.Selected rows`,
}))
)
// Add bindings for table blocks
let tableBlocks = findAllMatchingComponents(asset.props, component =>
component._component.endsWith("tableblock")
)
bindings = bindings.concat(
tableBlocks.map(block => ({
type: "context",
runtimeBinding: `${safeState}.${makePropSafe(block._id + "-table")}`,
readableBinding: `${block._instanceName}.Selected rows`,
}))
)
}
return bindings
}