Skip to content

Commit

Permalink
WIP: add StepParameter inputs to workflow editor
Browse files Browse the repository at this point in the history
In the current state when a text, integer, float, boolean or
boolean parameter is set as "Set at Runtime" a new connectable
input appears for the tool node, to which a Parameter can be properly
dragged and connected.

This still needs a little more separation from data inputs/outputs,
and the new connection isn't persisted in a meaningful way.
  • Loading branch information
mvdbeek authored and jmchilton committed Nov 6, 2018
1 parent 638b1b7 commit c09d1bc
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 1 deletion.
17 changes: 17 additions & 0 deletions client/galaxy/scripts/mvc/workflow/workflow-node.js
Expand Up @@ -6,6 +6,14 @@ import NodeView from "mvc/workflow/workflow-view-node";
/* global $ */
/* global Galaxy */

var StepParameterTypes = [
'text',
'integer',
'float',
'boolean',
'color',
]

var Node = Backbone.Model.extend({
initialize: function(app, attr) {
this.app = app;
Expand Down Expand Up @@ -217,12 +225,21 @@ var Node = Backbone.Model.extend({
$.each(data.data_inputs, (i, input) => {
nodeView.addDataInput(input);
});
$.each(node.config_form.inputs, (i, input) => {
if (input.value.__class__ == 'RuntimeValue' && StepParameterTypes.includes(input.type)){
console.log('Adding Parameter Input');
nodeView.addParameterInput(input);
}
});
if (data.data_inputs.length > 0 && data.data_outputs.length > 0) {
nodeView.addRule();
}
$.each(data.data_outputs, (i, output) => {
nodeView.addDataOutput(output);
});
$.each(data.input_parameters, (i, input_parameter) => {
nodeView.addParameterOutput(input_parameter);
});
nodeView.render();
this.app.workflow.node_changed(this, true);
},
Expand Down
17 changes: 17 additions & 0 deletions client/galaxy/scripts/mvc/workflow/workflow-terminals.js
Expand Up @@ -431,6 +431,18 @@ var InputTerminal = BaseInputTerminal.extend({
}
});

var InputParameterTerminal = BaseInputTerminal.extend({
update: function(input) {
this.type = input.type;
},
connect: function(connector) {
BaseInputTerminal.prototype.connect.call(this, connector);
},
attachable: function(other) {
return this.type == other.attributes.type;
},
});

var InputCollectionTerminal = BaseInputTerminal.extend({
update: function(input) {
this.multiple = false;
Expand Down Expand Up @@ -566,9 +578,14 @@ var OutputCollectionTerminal = Terminal.extend({
}
});

var OutputParameterTerminal = Terminal.extend({
});

export default {
InputTerminal: InputTerminal,
InputParameterTerminal: InputParameterTerminal,
OutputTerminal: OutputTerminal,
OutputParameterTerminal: OutputParameterTerminal,
InputCollectionTerminal: InputCollectionTerminal,
OutputCollectionTerminal: OutputCollectionTerminal,
TerminalMapping: TerminalMapping,
Expand Down
58 changes: 57 additions & 1 deletion client/galaxy/scripts/mvc/workflow/workflow-view-data.js
Expand Up @@ -90,6 +90,61 @@ var DataOutputView = Backbone.View.extend({
}
});

var ParameterOutputView = Backbone.View.extend({
className: "form-row dataRow",

initialize: function(options) {
this.output = options.output;
this.terminalElement = options.terminalElement;
this.nodeView = options.nodeView;

var output = this.output;
var label = output.label || output.name;
var node = this.nodeView.node;

this.$el.html(label);
this.calloutView = null;
if (["tool", "subworkflow"].indexOf(node.type) >= 0) {
var calloutView = new OutputCalloutView({
label: label,
output: output,
node: node
});
this.calloutView = calloutView;
this.$el.append(calloutView.el);
this.$el.hover(
() => {
calloutView.hoverImage();
},
() => {
calloutView.resetImage();
}
);
}
this.$el.css({
position: "absolute",
left: -1000,
top: -1000,
display: "none"
});
$("body").append(this.el);
this.nodeView.updateMaxWidth(this.$el.outerWidth() + 17);
this.$el
.css({
position: "",
left: "",
top: "",
display: ""
})
.detach();
},
redrawWorkflowOutput: function() {
if (this.calloutView) {
this.calloutView.resetImage();
}
}
});

var OutputCalloutView = Backbone.View.extend({
tagName: "div",

Expand Down Expand Up @@ -153,5 +208,6 @@ var OutputCalloutView = Backbone.View.extend({

export default {
DataInputView: DataInputView,
DataOutputView: DataOutputView
DataOutputView: DataOutputView,
ParameterOutputView: ParameterOutputView,
};
52 changes: 52 additions & 0 deletions client/galaxy/scripts/mvc/workflow/workflow-view-node.js
Expand Up @@ -79,6 +79,43 @@ export default Backbone.View.extend({
return terminalView;
},

addParameterInput: function(input, body) {
var skipResize = true;
if (!body) {
body = this.$(".inputs");
// initial addition to node - resize input to help calculate node
// width.
skipResize = false;
}
var terminalView = this.terminalViews[input.name];
var terminalViewClass = TerminalViews.InputParameterTerminalView;
if (terminalView && !(terminalView instanceof terminalViewClass)) {
terminalView.el.terminal.destroy();
terminalView = null;
}
if (!terminalView) {
terminalView = new terminalViewClass({
node: this.node,
input: input
});
} else {
var terminal = terminalView.el.terminal;
terminal.update(input);
terminal.destroyInvalidConnections();
}
this.terminalViews[input.name] = terminalView;
var terminalElement = terminalView.el;
var inputView = new DataViews.DataInputView({
terminalElement: terminalElement,
input: input,
nodeView: this,
skipResize: skipResize
});
var ib = inputView.$el;
body.append(ib.prepend(terminalView.terminalElements()));
return terminalView;
},

addDataOutput: function(output) {
var terminalViewClass = output.collection
? TerminalViews.OutputCollectionTerminalView
Expand All @@ -96,6 +133,21 @@ export default Backbone.View.extend({
this.tool_body.append(outputView.$el.append(terminalView.terminalElements()));
},

addParameterOutput: function(input_parameter) {
var terminalViewClass = TerminalViews.OutputParameterTerminalView;
var terminalView = new terminalViewClass({
node: this.node,
output: input_parameter,
});
var parameterView = new DataViews.ParameterOutputView({
output: input_parameter,
terminalElement: terminalView.el,
nodeView: this
});
this.outputViews[input_parameter.name] = parameterView;
this.tool_body.append(parameterView.$el.append(terminalView.terminalElements()));
},

redrawWorkflowOutputs: function() {
_.each(this.outputViews, outputView => {
outputView.redrawWorkflowOutput();
Expand Down
27 changes: 27 additions & 0 deletions client/galaxy/scripts/mvc/workflow/workflow-view-terminals.js
Expand Up @@ -161,6 +161,17 @@ var InputTerminalView = BaseInputTerminalView.extend({
}
});

var InputParameterTerminalView = BaseInputTerminalView.extend({
terminalMappingClass: Terminals.TerminalMapping,
terminalMappingViewClass: InputTerminalMappingView,
terminalForInput: function(input) {
return new Terminals.InputParameterTerminal({
element: this.el,
input: input
});
}
});

var InputCollectionTerminalView = BaseInputTerminalView.extend({
terminalMappingClass: Terminals.TerminalMapping,
terminalMappingViewClass: InputTerminalMappingView,
Expand Down Expand Up @@ -278,9 +289,25 @@ var OutputCollectionTerminalView = BaseOutputTerminalView.extend({
}
});

var OutputParameterTerminalView = BaseOutputTerminalView.extend({
terminalMappingClass: Terminals.TerminalMapping,
terminalMappingViewClass: TerminalMappingView,
terminalForOutput: function(output) {
var collection_type = output.collection_type;
var collection_type_source = output.collection_type_source;
var terminal = new Terminals.OutputCollectionTerminal({
element: this.el,
type: output.type,
});
return terminal;
}
});

export default {
InputTerminalView: InputTerminalView,
InputParameterTerminalView: InputParameterTerminalView,
OutputTerminalView: OutputTerminalView,
OutputParameterTerminalView: OutputParameterTerminalView,
InputCollectionTerminalView: InputCollectionTerminalView,
OutputCollectionTerminalView: OutputCollectionTerminalView
};
1 change: 1 addition & 0 deletions lib/galaxy/managers/workflows.py
Expand Up @@ -573,6 +573,7 @@ def _workflow_to_dict_editor(self, trans, stored, workflow, tooltip=True):
'errors': module.get_errors(),
'data_inputs': module.get_data_inputs(),
'data_outputs': module.get_data_outputs(),
'input_parameters': module.get_input_parameters(),
'config_form': config_form,
'annotation': annotation_str,
'post_job_actions': {},
Expand Down
6 changes: 6 additions & 0 deletions lib/galaxy/workflow/modules.py
Expand Up @@ -158,6 +158,9 @@ def get_data_inputs(self):
def get_data_outputs(self):
return []

def get_input_parameters(self):
return []

def get_post_job_actions(self, incoming):
return []

Expand Down Expand Up @@ -638,6 +641,9 @@ def get_runtime_state(self):
def get_data_inputs(self):
return []

def get_input_parameters(self):
return [dict(name=self.name, label=self.label, type=self.parameter_type)]

def execute(self, trans, progress, invocation_step, use_cached_job=False):
step = invocation_step.workflow_step
step_outputs = dict(output=step.state.inputs['input'])
Expand Down

0 comments on commit c09d1bc

Please sign in to comment.