From b4aa4b8f0504124afe089c55be576fac6b18d341 Mon Sep 17 00:00:00 2001 From: foxriver76 Date: Mon, 8 Jan 2024 10:05:32 +0100 Subject: [PATCH] clarify binding documentation by providing an example - closes #288 --- README.md | 2 +- src/src/Vis/visFormatUtils.jsx | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1bc299a0a..f74a35f59 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Additionally, you need a license to use the adapter. The following license editi Normally, most of the widgets have ObjectID attribute and this attribute can be bound with some value of object ID. But there is another option for how to bind *any* attribute of widget to some ObjectID. -Just write into attribute `{object.id}` and it will be bound to this object's value. +Just write into attribute `{object.id}` e.g. `{hm-rpc.0.OEQ1880105.4.ACTUAL_TEMPERATURE}` and it will be bound to this object's value. If you use the special format, you can even make some simple operations with it, e.g., multiplying or formatting. E.g., to calculate the hypotenuse of a triangle: diff --git a/src/src/Vis/visFormatUtils.jsx b/src/src/Vis/visFormatUtils.jsx index 4145f33ae..1296d608b 100644 --- a/src/src/Vis/visFormatUtils.jsx +++ b/src/src/Vis/visFormatUtils.jsx @@ -13,6 +13,7 @@ * (Free for non-commercial use). */ import { extractBinding } from './visUtils'; +import { deepClone } from '../Utils/utils'; class VisFormatUtils { constructor(props) { @@ -265,14 +266,14 @@ class VisFormatUtils { return null; } if (!this.vis.editMode && this.bindingsCache[format]) { - return JSON.parse(JSON.stringify(this.bindingsCache[format])); + return deepClone(this.bindingsCache[format]); } const result = extractBinding(format); // cache bindings if (result && this.bindingsCache && !this.vis.editMode) { - this.bindingsCache[format] = JSON.parse(JSON.stringify(result)); + this.bindingsCache[format] = deepClone(result); } return result; @@ -348,7 +349,7 @@ class VisFormatUtils { const { formula } = operation; if (formula && formula.includes('widget.')) { - const w = JSON.parse(JSON.stringify(widget)); + const w = deepClone(widget); w.data = widgetData; string += `const widget = ${JSON.stringify(w)};`; }