Browse Source

Ensure data binding generation doesn't crash if no asset is selected

master
Andrew Kingston 5 years ago
parent
commit
0338e8c7b5
  1. 12
      packages/builder/src/builderStore/dataBinding.js

12
packages/builder/src/builderStore/dataBinding.js

@ -32,14 +32,14 @@ export const getBindableProperties = (asset, componentId) => {
const urlBindings = getUrlBindings(asset) const urlBindings = getUrlBindings(asset)
const deviceBindings = getDeviceBindings() const deviceBindings = getDeviceBindings()
const stateBindings = getStateBindings() const stateBindings = getStateBindings()
const rowBindings = getRowBindings(asset) const selectedRowsBindings = getSelectedRowsBindings(asset)
return [ return [
...contextBindings, ...contextBindings,
...urlBindings, ...urlBindings,
...stateBindings, ...stateBindings,
...userBindings, ...userBindings,
...deviceBindings, ...deviceBindings,
...rowBindings, ...selectedRowsBindings,
] ]
} }
@ -318,13 +318,13 @@ const getDeviceBindings = () => {
} }
/** /**
* Gets all row bindings that are globally available. * Gets all selected rows bindings for tables in the current asset.
*/ */
const getRowBindings = asset => { const getSelectedRowsBindings = asset => {
let bindings = [] let bindings = []
if (get(store).clientFeatures?.rowSelection) { if (get(store).clientFeatures?.rowSelection) {
// Add bindings for table components // Add bindings for table components
let tables = findAllMatchingComponents(asset.props, component => let tables = findAllMatchingComponents(asset?.props, component =>
component._component.endsWith("table") component._component.endsWith("table")
) )
const safeState = makePropSafe("rowSelection") const safeState = makePropSafe("rowSelection")
@ -337,7 +337,7 @@ const getRowBindings = asset => {
) )
// Add bindings for table blocks // Add bindings for table blocks
let tableBlocks = findAllMatchingComponents(asset.props, component => let tableBlocks = findAllMatchingComponents(asset?.props, component =>
component._component.endsWith("tableblock") component._component.endsWith("tableblock")
) )
bindings = bindings.concat( bindings = bindings.concat(

Loading…
Cancel
Save