Skip to content

Commit

Permalink
allow to use widget oid in bindings
Browse files Browse the repository at this point in the history
- closes #345
  • Loading branch information
foxriver76 committed Mar 1, 2024
1 parent 3bef8c1 commit f9c1e61
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ E.g., if it was used in a menu and the menu is red, the circle would be red.
### **WORK IN PROGRESS**
-->
## Changelog
### **WORK IN PROGRESS**
* (foxriver76) allow to use `widgetOid` in bindings

### 2.9.37 (2024-02-28)
* (foxriver76) TimePicker widget now saves the time instead of date by default, if you want old behavior use checkbox `asDate`

Expand Down
15 changes: 15 additions & 0 deletions src/src/Attributes/Widget/WidgetBindingField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,24 @@ class WidgetBindingField extends Component {
if (!oids) {
return value;
}

// read all states
const stateOids = [];
oids.forEach(oid => {
if (oid.visOid.startsWith('widgetOid.')) {
const newOid = this.props.widget.data.oid;
oid.visOid = oid.visOid.replace(/^widgetOid\./g, `${newOid}.`);
oid.systemOid = newOid;
oid.token = oid.token.replace(/:widgetOid;/g, `:${newOid};`);
oid.format = oid.format.replace(/:widgetOid;/g, `:${newOid};`);
for (const operation of oid.operations) {
for (const arg of operation.arg) {
arg.visOid = arg.visOid.replace(/^widgetOid\./g, `${newOid}.`);
arg.systemOid = newOid;
}
}
}

const parts = oid.visOid.split('.');
if (parts[parts.length - 1] === 'val' || parts[parts.length - 1] === 'ts' || parts[parts.length - 1] === 'lc' || parts[parts.length - 1] === 'ack') {
parts.pop();
Expand Down
3 changes: 2 additions & 1 deletion src/src/Vis/visFormatUtils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,9 @@ class VisFormatUtils {
continue;
}
value = this.getSpecialValues(operation.arg[a].visOid, view, wid, widgetData);

if (value === undefined || value === null) {
value = values[operation.arg[a].visOid];
value = operation.arg[a].visOid.startsWith('widgetOid.') ? values[operation.arg[a].visOid.replace(/^widgetOid\./g, `${widget.data.oid}.`)] : values[operation.arg[a].visOid];
}
if (value === null) {
string += `const ${operation.arg[a].name} = null;`;
Expand Down

0 comments on commit f9c1e61

Please sign in to comment.