Skip to content

Commit

Permalink
Merge pull request #12598 from guerler/fix_outputs_21.09.002
Browse files Browse the repository at this point in the history
[21.09] Sync reset mapping with Node component map-over state
  • Loading branch information
jdavcs committed Oct 1, 2021
2 parents 5d59042 + 2a73d9d commit 8d6191b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 21 deletions.
3 changes: 0 additions & 3 deletions client/src/components/Workflow/Editor/Node.vue
Expand Up @@ -251,9 +251,6 @@ export default {
this.onRedraw();
},
onAddOutput(output, terminal) {
if (this.mapOver) {
terminal.setMapOver(this.mapOver);
}
this.outputTerminals[output.name] = terminal;
this.onRedraw();
},
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Workflow/Editor/NodeInput.vue
Expand Up @@ -103,7 +103,7 @@ export default {
return terminal;
},
onChange() {
this.isMultiple = this.terminal.mapOver && this.terminal.mapOver.isCollection;
this.isMultiple = this.terminal.isMappedOver();
this.$emit("onChange");
},
onRemove() {
Expand Down
28 changes: 13 additions & 15 deletions client/src/components/Workflow/Editor/NodeOutput.vue
Expand Up @@ -78,18 +78,17 @@ export default {
} else {
// create new terminal, connect like old terminal, destroy old terminal
this.$emit("onRemove", this.output);
const newTerminal = this.createTerminal(newOutput);
newTerminal.connectors = this.terminal.connectors.map((c) => {
return new Connector(this.getManager(), newTerminal, c.inputHandle);
this.createTerminal(newOutput);
this.terminal.connectors = oldTerminal.connectors.map((c) => {
return new Connector(this.getManager(), this.terminal, c.inputHandle);
});
newTerminal.destroyInvalidConnections();
this.terminal = newTerminal;
this.terminal.destroyInvalidConnections();
oldTerminal.destroy();
}
},
},
mounted() {
this.terminal = this.createTerminal(this.output);
this.createTerminal(this.output);
},
methods: {
terminalClassForOutput(output) {
Expand All @@ -102,7 +101,6 @@ export default {
return terminalClass;
},
createTerminal(output) {
let terminal;
const terminalClass = this.terminalClassForOutput(output);
const parameters = {
node: this.getNode(),
Expand All @@ -113,33 +111,33 @@ export default {
if (output.collection) {
const collection_type = output.collection_type;
const collection_type_source = output.collection_type_source;
terminal = new terminalClass({
this.terminal = new terminalClass({
...parameters,
collection_type: collection_type,
collection_type_source: collection_type_source,
datatypes: output.extensions,
});
} else if (output.parameter) {
terminal = new terminalClass({
this.terminal = new terminalClass({
...parameters,
type: output.type,
});
} else {
terminal = new terminalClass({
this.terminal = new terminalClass({
...parameters,
datatypes: output.extensions,
});
}
terminal.on("change", this.onChange.bind(this));
new OutputDragging(this.getManager(), {
el: this.$refs.terminal,
terminal: terminal,
terminal: this.terminal,
});
this.$emit("onAdd", this.output, terminal);
return terminal;
this.terminal.on("change", this.onChange.bind(this));
this.terminal.emit("change");
this.$emit("onAdd", this.output, this.terminal);
},
onChange() {
this.isMultiple = this.terminal.mapOver && this.terminal.mapOver.isCollection;
this.isMultiple = this.terminal.isMappedOver();
this.$emit("onChange");
},
onToggle() {
Expand Down
4 changes: 4 additions & 0 deletions client/src/components/Workflow/Editor/modules/terminals.js
Expand Up @@ -169,6 +169,7 @@ class Terminal extends EventEmitter {
}
resetMapping() {
this.mapOver = NULL_COLLECTION_TYPE_DESCRIPTION;
this.node.mapOver = undefined;
this.emit("change");
}
resetCollectionTypeSource() {
Expand Down Expand Up @@ -590,6 +591,9 @@ class BaseOutputTerminal extends Terminal {
super(attr);
this.datatypes = attr.datatypes;
this.optional = attr.optional;
if (this.node.mapOver) {
this.setMapOver(this.node.mapOver);
}
}
get force_datatype() {
const changeOutputDatatype = this.node.postJobActions["ChangeDatatypeAction" + this.name];
Expand Down
29 changes: 27 additions & 2 deletions client/tests/qunit/tests/workflow_editor_tests.js
Expand Up @@ -326,6 +326,7 @@ QUnit.test("Collection output can connect to same collection input type", functi
const outputTerminal = new Terminals.OutputCollectionTerminal({
datatypes: "txt",
collection_type: "list",
node: {},
});
outputTerminal.node = {postJobActions: {}};
assert.ok(
Expand All @@ -340,6 +341,7 @@ QUnit.test("Optional collection output can not connect to required collection in
datatypes: "txt",
collection_type: "list",
optional: true,
node: {},
});
outputTerminal.node = {};
assert.ok(!inputTerminal.canAccept(outputTerminal).canAccept);
Expand All @@ -350,6 +352,7 @@ QUnit.test("Collection output cannot connect to different collection input type"
const outputTerminal = new Terminals.OutputCollectionTerminal({
datatypes: "txt",
collection_type: "paired",
node: {},
});
outputTerminal.node = {};
assert.ok(!inputTerminal.canAccept(outputTerminal).canAccept);
Expand Down Expand Up @@ -542,6 +545,7 @@ QUnit.module("Node view", {
datatypes: [outputType],
mapOver: Terminals.NULL_COLLECTION_TYPE_DESCRIPTION,
element: inputEl,
node: {},
});
outputTerminal.node = {
markChanged: function () {},
Expand Down Expand Up @@ -572,6 +576,7 @@ QUnit.module("Node view", {
datatypes: ["txt"],
mapOver: new Terminals.CollectionTypeDescription("list"),
element: inputEl,
node: {},
});
outputTerminal.node = {
markChanged: function () {},
Expand All @@ -598,6 +603,7 @@ QUnit.module("Node view", {
datatypes: ["txt"],
mapOver: new Terminals.CollectionTypeDescription("list"),
element: inputEl,
node: {},
});
outputTerminal.node = {
markChanged: function () {},
Expand Down Expand Up @@ -832,7 +838,10 @@ QUnit.test("equal", function (assert) {
});

QUnit.test("default constructor", function (assert) {
const terminal = new Terminals.InputTerminal({ input: {} });
const terminal = new Terminals.InputTerminal({
input: {},
node: {},
});
assert.ok(terminal.mapOver === Terminals.NULL_COLLECTION_TYPE_DESCRIPTION);
});

Expand Down Expand Up @@ -902,7 +911,11 @@ QUnit.module("terminal mapping logic", {
output["extensions"] = ["data"];
}
const outputEl = $("<div>")[0];
const outputTerminal = new Terminals.OutputTerminal({ element: outputEl, datatypes: output.extensions });
const outputTerminal = new Terminals.OutputTerminal({
element: outputEl,
datatypes: output.extensions,
node: {},
});
outputTerminal.node = node;
if (mapOver) {
outputTerminal.setMapOver(new Terminals.CollectionTypeDescription(mapOver));
Expand All @@ -921,6 +934,7 @@ QUnit.module("terminal mapping logic", {
element: outputEl,
datatypes: output.extensions,
collection_type: collectionType,
node: {},
});
outputTerminal.node = node;
if (mapOver) {
Expand Down Expand Up @@ -1265,3 +1279,14 @@ QUnit.test("simple mapping over collection outputs works correctly", function (a
const testTerminal1 = this.newInputTerminal("list:list:list");
this.verifyNotAttachable(assert, testTerminal1, connectedOutput);
});

QUnit.test("node mapping state over collection outputs works correctly", function (assert) {
const inputTerminal1 = this.newInputTerminal();
const outputCollectionTerminal1 = this.newOutputCollectionTerminal("list");
assert.ok(!inputTerminal1.node.mapOver);
const connector = new Connector({}, outputCollectionTerminal1, inputTerminal1);
outputCollectionTerminal1.connect(connector);
assert.ok(inputTerminal1.node.mapOver);
inputTerminal1.disconnect(connector);
assert.ok(!inputTerminal1.node.mapOver);
});

0 comments on commit 8d6191b

Please sign in to comment.