Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarify binding documentation by providing an example #293

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading