diff --git a/src/client/widgets/common/widget.js b/src/client/widgets/common/widget.js index 37892089..0ffbd91c 100644 --- a/src/client/widgets/common/widget.js +++ b/src/client/widgets/common/widget.js @@ -509,6 +509,11 @@ class Widget extends EventEmitter { jsScope = context || {}, varnumber = 999 + + if (typeof propValue === 'object' && propValue !== null) { + propValue = JSON.stringify(propValue) + } + if (typeof propValue == 'string') { propValue = balancedReplace('@', '{', '}', propValue, (content)=>{ @@ -772,10 +777,6 @@ class Widget extends EventEmitter { } catch (err) {} } - } else if (propValue != null && typeof propValue == 'object') { - for (let k in propValue) { - propValue[k] = this.resolveProp(propName, propValue[k], storeLinks, originalWidget, originalPropName, context) - } } return propValue diff --git a/src/client/widgets/containers/matrix.js b/src/client/widgets/containers/matrix.js index 839b6eb7..4c59d3c1 100644 --- a/src/client/widgets/containers/matrix.js +++ b/src/client/widgets/containers/matrix.js @@ -1,6 +1,6 @@ var Panel = require('./panel'), parser = require('../../parser'), - {deepCopy} = require('../../utils') + {deepCopy, deepEqual} = require('../../utils') class Matrix extends Panel { @@ -64,7 +64,7 @@ class Matrix extends Panel { for (let i = 0; i < this.getProp('quantity'); i++) { - var props = this.resolveProp('props', undefined, false, false, false, {'$':i}) + var props = deepCopy(this.getProp('props')[i]) var data = this.defaultProps(i) if (typeof props === 'object' && props !== null) { @@ -126,7 +126,7 @@ class Matrix extends Panel { for (let i = this.children.length - 1; i >= 0; i--) { - let data = this.resolveProp('props', undefined, false, false, false, {'$': i}) + let data = deepCopy(this.getProp('props')[i]) if (typeof data !== 'object' || data === null || Array.isArray(data)) { data = {} @@ -134,11 +134,11 @@ class Matrix extends Panel { data = JSON.parse(JSON.stringify(data).replace(/(JS|#|OSC|@|VAR)_\{/g, '$1{')) - if (typeof oldPropValue === 'object' && oldPropValue !== null) { + if (typeof oldPropValue[i] === 'object' && oldPropValue[i] !== null) { // if an overridden default props is removed, set it back to default let overriddenDefaults, widgetDefaults - for (var k in oldPropValue) { + for (var k in oldPropValue[i]) { if (data[k] === undefined) { if (Matrix.overriddenDefaults.indexOf(k) !== -1) { overriddenDefaults = overriddenDefaults || this.defaultProps(i) @@ -166,6 +166,24 @@ class Matrix extends Panel { } + resolveProp(propName, propValue, storeLinks, originalWidget, originalPropName, context) { + + if (propName === 'props') { + + var data = [] + for (var i = 0; i < this.getProp('quantity'); i++) { + data[i] = super.resolveProp(propName, propValue, storeLinks, originalWidget, originalPropName, {$: i}) + } + + return data + + } else { + + return super.resolveProp(propName, propValue, storeLinks, originalWidget, originalPropName, context) + + } + + } }