Skip to content

Commit

Permalink
clarify binding documentation by providing an example
Browse files Browse the repository at this point in the history
- closes #288
  • Loading branch information
foxriver76 committed Jan 8, 2024
1 parent 5d83a64 commit b4aa4b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions src/src/Vis/visFormatUtils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* (Free for non-commercial use).
*/
import { extractBinding } from './visUtils';
import { deepClone } from '../Utils/utils';

class VisFormatUtils {
constructor(props) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)};`;
}
Expand Down

0 comments on commit b4aa4b8

Please sign in to comment.