mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-31 10:32:11 +08:00
Drop invalid connections if type_source is unavailable
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import * as Toastr from "libs/toastr";
|
||||
|
||||
function Connector(handle1, handle2) {
|
||||
this.canvas = null;
|
||||
this.dragging = false;
|
||||
@@ -30,8 +32,11 @@ $.extend(Connector.prototype, {
|
||||
}
|
||||
$(this.canvas).remove();
|
||||
},
|
||||
destroyIfInvalid: function() {
|
||||
destroyIfInvalid: function(warn) {
|
||||
if (this.handle1 && this.handle2 && !this.handle2.attachable(this.handle1)) {
|
||||
if (warn) {
|
||||
Toastr.warning("Destroying a connection because collection type has changed.");
|
||||
}
|
||||
this.destroy();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// TODO; tie into Galaxy state?
|
||||
window.workflow_globals = window.workflow_globals || {};
|
||||
import * as Toastr from "libs/toastr";
|
||||
|
||||
function CollectionTypeDescription(collectionType) {
|
||||
this.collectionType = collectionType;
|
||||
@@ -131,7 +130,9 @@ var Terminal = Backbone.Model.extend({
|
||||
if (this.node) {
|
||||
this.node.markChanged();
|
||||
this.resetMappingIfNeeded();
|
||||
this.resetCollectionTypeSource();
|
||||
if (!connector.dragging) {
|
||||
this.resetCollectionTypeSource();
|
||||
}
|
||||
}
|
||||
},
|
||||
redraw: function() {
|
||||
@@ -181,9 +182,8 @@ var Terminal = Backbone.Model.extend({
|
||||
let node = this.node;
|
||||
_.each(node.output_terminals, function(output_terminal) {
|
||||
let type_source = output_terminal.attributes.collection_type_source;
|
||||
if (type_source) {
|
||||
if (type_source && output_terminal.attributes.collection_type) {
|
||||
output_terminal.attributes.collection_type = null;
|
||||
output_terminal.collectionType = ANY_COLLECTION_TYPE_DESCRIPTION;
|
||||
output_terminal.update(output_terminal.attributes);
|
||||
}
|
||||
});
|
||||
@@ -454,7 +454,7 @@ var InputCollectionTerminal = BaseInputTerminal.extend({
|
||||
} else {
|
||||
let node = this.node;
|
||||
_.each(node.output_terminals, function(output_terminal) {
|
||||
if (output_terminal.attributes.collection_type_source) {
|
||||
if (output_terminal.attributes.collection_type_source && !connector.dragging) {
|
||||
output_terminal.attributes.collection_type = other.attributes.collection_type;
|
||||
output_terminal.update(output_terminal.attributes);
|
||||
}
|
||||
@@ -544,14 +544,15 @@ var OutputCollectionTerminal = Terminal.extend({
|
||||
newCollectionType = ANY_COLLECTION_TYPE_DESCRIPTION;
|
||||
}
|
||||
|
||||
if (newCollectionType.collectionType != this.collectionType.collectionType) {
|
||||
_.each(this.connectors, connector => {
|
||||
// TODO: consider checking if connection valid before removing...
|
||||
Toastr.warning("Destroying a connection because collection type has changed.");
|
||||
connector.destroy();
|
||||
let oldCollectionType = this.collectionType;
|
||||
this.collectionType = newCollectionType;
|
||||
// we need to iterate over a copy, as we slice this.connectors in the process of destroying connections
|
||||
var connectors = this.connectors.slice(0);
|
||||
if (newCollectionType.collectionType != oldCollectionType.collectionType) {
|
||||
_.each(connectors, connector => {
|
||||
connector.destroyIfInvalid(true);
|
||||
});
|
||||
}
|
||||
this.collectionType = newCollectionType;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user