commit/galaxy-central: dannon: Workflow outputs logic rewrite. Accounts for old workflows that have no outputs defined but do use HideDatasetActions.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/08fbfeaaf3e1/ changeset: 08fbfeaaf3e1 user: dannon date: 2012-04-17 21:03:38 summary: Workflow outputs logic rewrite. Accounts for old workflows that have no outputs defined but do use HideDatasetActions. Fixes the bug where you couldnt' remove the last HideDatasetAction from a workflow in some situations. affected #: 1 file diff -r 1f1cd76dd19cc19d5e76c0560da3ccedb796b8cf -r 08fbfeaaf3e1d8cf71e9410dfbeac25cb4d8e719 static/scripts/galaxy.workflow_editor.canvas.js --- a/static/scripts/galaxy.workflow_editor.canvas.js +++ b/static/scripts/galaxy.workflow_editor.canvas.js @@ -331,7 +331,7 @@ } var r = $("<div class='form-row dataRow'>" + label + "</div>" ); if (node.type == 'tool'){ - var callout = $("<div class='callout'></div>") + var callout = $("<div class='callout "+label+"'></div>") .css( { display: 'none' } ) .append( $("<div class='buttons'></div>").append( @@ -368,7 +368,7 @@ callout.find('img').attr('src', galaxy_paths.attributes.image_path + '/fugue/asterisk-small-outline.png'); }else{ callout.find('img').attr('src', galaxy_paths.attributes.image_path + '/fugue/asterisk-small.png'); - } + } }); } r.css({ position:'absolute', @@ -477,59 +477,50 @@ }, rectify_workflow_outputs : function() { // Find out if we're using workflow_outputs or not. - var using_workflow_outputs = false; + var using_workflow_outputs, has_existing_pjas = false; $.each( this.nodes, function ( k, node ) { if (node.workflow_outputs && node.workflow_outputs.length > 0){ using_workflow_outputs = true; } + $.each(node.post_job_actions, function(pja_id, pja){ + if (pja.action_type === "HideDatasetAction"){ + has_existing_pjas = true; + } + }); }); - if (using_workflow_outputs == false){ - //We're done, leave PJAs alone. - return true; + if (using_workflow_outputs !== false || has_existing_pjas !== false){ + // Using workflow outputs, or has existing pjas. Remove all PJAs and recreate based on outputs. + $.each(this.nodes, function (k, node ){ + if (node.type === 'tool'){ + node.post_job_actions = {}; + node_changed = true; + if (using_workflow_outputs){ + $.each(node.output_terminals, function(ot_id, ot){ + var create_pja = true; + $.each(node.workflow_outputs, function(i, wo_name){ + if (ot.name === wo_name){ + create_pja = false; + } + }); + if (create_pja === true){ + node_changed = true; + var pja = { + action_type : "HideDatasetAction", + output_name : ot.name, + action_arguments : {} + } + node.post_job_actions['HideDatasetAction'+ot.name] = null; + node.post_job_actions['HideDatasetAction'+ot.name] = pja; + } + }); + } + // lastly, if this is the active node, and we made changes, reload the display at right. + if (workflow.active_node == node && node_changed === true) { + workflow.reload_active_node(); + } + } + }); } - wf = this; - $.each(this.nodes, function (k, node ){ - if (node.type == 'tool'){ - var node_changed = false; - if (node.post_job_actions == null){ - node.post_job_actions = {}; - } - var pjas_to_rem = []; - $.each(node.post_job_actions, function(pja_id, pja){ - if (pja.action_type == "HideDatasetAction"){ - pjas_to_rem.push(pja_id); - } - }); - if (pjas_to_rem.length > 0 && node == workflow.active_node) { - $.each(pjas_to_rem, function(i, pja_name){ - node_changed = true; - delete node.post_job_actions[pja_name]; - }); - } - $.each(node.output_terminals, function(ot_id, ot){ - var create_pja = true; - $.each(node.workflow_outputs, function(i, wo_name){ - if (ot.name == wo_name){ - create_pja = false; - } - }); - if (create_pja == true){ - node_changed = true; - var pja = { - action_type : "HideDatasetAction", - output_name : ot.name, - action_arguments : {} - } - node.post_job_actions['HideDatasetAction'+ot.name] = null; - node.post_job_actions['HideDatasetAction'+ot.name] = pja; - } - }); - // lastly, if this is the active node, and we made changes, reload the display at right. - if (wf.active_node == node && node_changed == true) { - wf.reload_active_node(); - } - } - }); }, to_simple : function () { var nodes = {}; @@ -580,6 +571,7 @@ var max_id = 0; wf.name = data.name; // First pass, nodes + var using_workflow_outputs = false; $.each( data.steps, function( id, step ) { var node = prebuild_node( "tool", step.name, step.tool_id ); node.init_field_data( step ); @@ -589,6 +581,20 @@ node.id = step.id; wf.nodes[ node.id ] = node; max_id = Math.max( max_id, parseInt( id ) ); + // For older workflows, it's possible to have HideDataset PJAs, but not WorkflowOutputs. + // Check for either, and then add outputs in the next pass. + if (!using_workflow_outputs && node.type === 'tool'){ + if (node.workflow_outputs.length > 0){ + using_workflow_outputs = true; + } + else{ + $.each(node.post_job_actions, function(pja_id, pja){ + if (pja.action_type === "HideDatasetAction"){ + using_workflow_outputs = true; + } + }); + } + } }); wf.id_counter = max_id + 1; // Second pass, connections @@ -603,6 +609,17 @@ c.redraw(); } }); + if(using_workflow_outputs && node.type === 'tool'){ + // Ensure that every output terminal has a WorkflowOutput or HideDatasetAction. + $.each(node.output_terminals, function(ot_id, ot){ + if(node.post_job_actions['HideDatasetAction'+ot.name] === undefined){ + node.workflow_outputs.push(ot.name); + callout = $(node.element).find('.callout.'+ot.name); + callout.find('img').attr('src', galaxy_paths.attributes.image_path + '/fugue/asterisk-small.png'); + workflow.has_changes = true; + } + }); + } }); }, check_changes_in_active_form : function() { Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket