mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 10:24:38 +08:00
Workflow Editor: Rework InputTerminal to implement/use an update method (w/tests).
This will enable replacing terminals instead of recreating them and reconnecting in subsequent changesets.
This commit is contained in:
@@ -38,8 +38,11 @@ var OutputTerminal = Terminal.extend( {
|
||||
var InputTerminal = Terminal.extend( {
|
||||
initialize: function( attr ) {
|
||||
Terminal.prototype.initialize.call( this, attr );
|
||||
this.datatypes = attr.datatypes;
|
||||
this.multiple = attr.multiple;
|
||||
this.update( attr.input );
|
||||
},
|
||||
update: function( input ) {
|
||||
this.datatypes = input.extensions;
|
||||
this.multiple = input.multiple;
|
||||
},
|
||||
canAccept: function ( other ) {
|
||||
if( this._inputFilled() ) {
|
||||
@@ -981,13 +984,9 @@ var InputTerminalView = Backbone.View.extend( {
|
||||
var input = options.input;
|
||||
|
||||
var name = input.name;
|
||||
var types = input.extensions;
|
||||
var multiple = input.multiple;
|
||||
|
||||
var terminal = this.el.terminal = new InputTerminal( { element: this.el, datatypes: types, multiple: multiple } );
|
||||
var terminal = this.el.terminal = new InputTerminal( { element: this.el, input: input } );
|
||||
terminal.node = node;
|
||||
terminal.name = name;
|
||||
|
||||
node.input_terminals[name] = terminal;
|
||||
},
|
||||
|
||||
|
||||
@@ -63,7 +63,8 @@ define([
|
||||
setup: function() {
|
||||
this.node = { };
|
||||
this.element = $( "<div>" );
|
||||
this.input_terminal = new InputTerminal( { element: this.element, datatypes: [ "txt" ] } );
|
||||
var input = { extensions: [ "txt" ], multiple: false };
|
||||
this.input_terminal = new InputTerminal( { element: this.element, input: input } );
|
||||
this.input_terminal.node = this.node;
|
||||
},
|
||||
test_connector: function( attr ) {
|
||||
@@ -90,6 +91,16 @@ define([
|
||||
}
|
||||
} );
|
||||
|
||||
test( "test update", function() {
|
||||
deepEqual( this.input_terminal.datatypes, [ 'txt' ] );
|
||||
equal( this.input_terminal.multiple, false );
|
||||
|
||||
this.input_terminal.update( { extensions: [ 'bam' ], multiple: true } );
|
||||
|
||||
deepEqual( this.input_terminal.datatypes, [ 'bam' ] );
|
||||
equal( this.input_terminal.multiple, true );
|
||||
} );
|
||||
|
||||
test( "test connect", function() {
|
||||
this.node.markChanged = sinon.spy();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user