Skip to content

Commit

Permalink
Update view.js (#1285)
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Jul 7, 2024
1 parent 7648424 commit 1ec9c1e
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions source/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1752,17 +1752,17 @@ view.Graph = class extends grapher.Graph {
}

createValue(value) {
const name = value.name;
if (this._values.has(name)) {
const key = value && value.name && !value.initializer ? value.name : value;
if (this._values.has(key)) {
// duplicate argument name
const obj = this._values.get(name);
const obj = this._values.get(key);
this._table.set(value, obj);
} else {
const obj = new view.Value(this, value);
this._values.set(name, obj);
this._values.set(key, obj);
this._table.set(value, obj);
}
return this._values.get(name);
return this._values.get(key);
}

createArgument(value) {
Expand Down Expand Up @@ -1818,6 +1818,8 @@ view.Graph = class extends grapher.Graph {
for (const value of argument.value) {
if (value.name !== '' && !value.initializer) {
this.createValue(value).to.push(viewNode);
} else if (value.initializer) {
this.createValue(value);
}
}
}
Expand Down Expand Up @@ -2248,10 +2250,12 @@ view.Value = class {
}

activate() {
if (this.value && this.from && Array.isArray(this.to)) {
if (this.value && this.from && Array.isArray(this.to) && !this.value.initializer) {
const from = this.from.value;
const to = this.to.map((node) => node.value);
this.context.view.showConnectionProperties(this.value, from, to);
} else if (this.value && this.value.initializer) {
this.context.view.showTensorProperties({ value: [this.value] });
}
}
};
Expand Down Expand Up @@ -2794,13 +2798,7 @@ view.ArgumentView = class extends view.Control {
const item = new view.ValueView(context, value, this._source);
item.on('focus', () => this.emit('focus', target));
item.on('blur', () => this.emit('blur', target));
item.on('activate', () => {
if (emit) {
this.emit('activate', target);
} else {
this._view.showTensorProperties({ value: [value] });
}
});
item.on('activate', () => this.emit('activate', target));
item.on('select', () => this.emit('select', target));
this._items.push(item);
}
Expand Down

0 comments on commit 1ec9c1e

Please sign in to comment.