Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow switching tool versions in workflow editor #4373

Merged
merged 15 commits into from Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion client/galaxy/scripts/mvc/tool/tool-form-base.js
Expand Up @@ -156,7 +156,13 @@ define( [ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view
// queue model request
self.deferred.reset();
self.deferred.execute( function( process ) {
self._buildModel( process, { id : id, version : version } )
if ( options.hasOwnProperty( "workflow" ) ) {
Copy link
Contributor

@guerler guerler Aug 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved out of the base class. I can help with this tho. Is this PR already functional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely, I'm still struggling with getting the connections right when the number and type of output changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guerler I think this is fully functional now, but I'm sure there are some optimizations to do. Feel free to push to this branch if you want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guerler Do you object to me merging as is so you can follow up with that change - or do you want this change made first?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mvdbeek. Yeah I can make those changes later.

// this is needed for notifying the workflow editor form
options.version = version;
self.model.get( 'postchange' )( process, self );
} else {
self._buildModel( process, { id : id, version : version } );
};
});
}
});
Expand Down
1 change: 0 additions & 1 deletion client/galaxy/scripts/mvc/workflow/workflow-forms.js
Expand Up @@ -37,7 +37,6 @@ define( [ 'utils/utils', 'mvc/form/form-view', 'mvc/tool/tool-form-base' ], func
text_disable : 'Set at Runtime',
narrow : true,
initial_errors : true,
sustain_version : true,
cls : 'ui-portlet-narrow',
postchange : function( process, form ) {
var options = form.model.attributes;
Expand Down
13 changes: 7 additions & 6 deletions client/galaxy/scripts/mvc/workflow/workflow-manager.js
Expand Up @@ -182,15 +182,16 @@ function( Connector, Toastr ) {
id : node.id,
type : node.type,
content_id : node.content_id,
tool_version : node.config_form.version,
tool_state : node.tool_state,
errors : node.errors,
input_connections : input_connections,
position : $(node.element).position(),
annotation: node.annotation,
post_job_actions: node.post_job_actions,
uuid: node.uuid,
label: node.label,
workflow_outputs: node.workflow_outputs
annotation : node.annotation,
post_job_actions : node.post_job_actions,
uuid : node.uuid,
label : node.label,
workflow_outputs : node.workflow_outputs
};
nodes[ node.id ] = node_data;
});
Expand Down Expand Up @@ -308,7 +309,7 @@ function( Connector, Toastr ) {
if ( this.active_node == node && force ) {
// Force changes to be saved even on new connection (previously dumped)
this.check_changes_in_active_form();
this.app.showForm( node.config_form, node );
this.app.showForm( node.config_form, node, force );
}
this.app.showWorkflowParameters();
},
Expand Down
48 changes: 46 additions & 2 deletions client/galaxy/scripts/mvc/workflow/workflow-node.js
Expand Up @@ -154,6 +154,7 @@ define(['mvc/workflow/workflow-view-node'], function( NodeView ) {
}
this.name = data.name;
this.config_form = data.config_form;
this.tool_version = this.config_form && this.config_form.version;
this.tool_state = data.tool_state;
this.errors = data.errors;
this.tooltip = data.tooltip ? data.tooltip : "";
Expand Down Expand Up @@ -183,8 +184,51 @@ define(['mvc/workflow/workflow-view-node'], function( NodeView ) {
update_field_data : function( data ) {
var node = this;
var nodeView = node.nodeView;
// remove unused output views and remove pre-existing output views from data.data_outputs,
// so that these are not added twice.
var unused_outputs = [];
// nodeView.outputViews contains pre-existing outputs,
// while data.data_output contains what should be displayed.
// Now we gather the unused outputs
$.each(nodeView.outputViews, function(i, output_view) {
var cur_name = output_view.output.name;
var data_names = data.data_outputs;
var cur_name_in_data_outputs = false;
_.each(data_names, function(data_name) {
if (data_name.name == cur_name) {
cur_name_in_data_outputs = true;
}
});
if (cur_name_in_data_outputs === false) {
unused_outputs.push(cur_name)
}
});

// Remove the unused outputs
_.each(unused_outputs, function(unused_output) {
_.each(nodeView.outputViews[unused_output].terminalElement.terminal.connectors, function(x) {
if (x) {
x.destroy(); // Removes the noodle connectors
}
});
nodeView.outputViews[unused_output].remove(); // removes the rendered output
delete nodeView.outputViews[unused_output]; // removes the reference to the output
delete node.output_terminals[unused_output]; // removes the output terminal
});
$.each( node.workflow_outputs, function(i, wf_output){
if (wf_output && !node.output_terminals[wf_output.output_name]) {
node.workflow_outputs.splice(i, 1); // removes output from list of workflow outputs
}
});
$.each( data.data_outputs, function( i, output ) {
if (!nodeView.outputViews[output.name]) {
nodeView.addDataOutput(output); // add data output if it does not yet exist
}
});
this.tool_state = data.tool_state;
this.config_form = data.config_form;
this.force_refresh = this.config_form && this.tool_version !== this.config_form.version;
this.tool_version = this.config_form && this.config_form.version;
this.errors = data.errors;
this.annotation = data['annotation'];
this.label = data.label;
Expand Down Expand Up @@ -233,8 +277,8 @@ define(['mvc/workflow/workflow-view-node'], function( NodeView ) {
this.app.workflow.node_changed( this );
},
markChanged: function() {
this.app.workflow.node_changed( this );
this.app.workflow.node_changed( this, this.force_refresh );
}
});
return Node;
});
});
6 changes: 5 additions & 1 deletion client/galaxy/scripts/mvc/workflow/workflow-view.js
Expand Up @@ -653,11 +653,15 @@ define([
$( '#edit-attributes' ).show();
},

showForm: function ( content, node ) {
showForm: function ( content, node, force ) {
var self = this;
var cls = 'right-content';
var id = cls + '-' + node.id;
var $container = $( '#' + cls );
if (force) {
$container.find( '#' + id ).remove();
$( '<div id="' + id + '" class="' + cls + '"/>').remove();
}
if ( content && $container.find( '#' + id ).length == 0 ) {
var $el = $( '<div id="' + id + '" class="' + cls + '"/>' );
var form_wrapper = null;
Expand Down