Skip to content

Commit

Permalink
Merge pull request #5864 from guerler/fix_expansion
Browse files Browse the repository at this point in the history
Fix conditional parameter handling
  • Loading branch information
dannon committed Apr 9, 2018
2 parents 075abee + 4f84b9c commit d9efb4f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 26 deletions.
11 changes: 9 additions & 2 deletions client/galaxy/scripts/mvc/form/form-parameters.js
Expand Up @@ -83,8 +83,14 @@ export default Backbone.Model.extend({
});
}

// identify display type
return new Ui.TextSelect({
// pick selection display
var classes = {
"checkboxes": Ui.Checkbox,
"radio": Ui.Radio,
"radiobutton": Ui.RadioButton
}
var SelectClass = classes[input_def.display] || Ui.Select;
var select = new SelectClass.View({
id: `field-${input_def.id}`,
data: data,
display: input_def.display,
Expand All @@ -96,6 +102,7 @@ export default Backbone.Model.extend({
individual: input_def.individual,
searchable: input_def.flavor !== "workflow"
});
return input_def.textable ? new Ui.TextSelect({select: select}) : select;
},

/** Drill down options field */
Expand Down
23 changes: 11 additions & 12 deletions client/galaxy/scripts/mvc/form/form-section.js
Expand Up @@ -48,11 +48,18 @@ var View = Backbone.View.extend({
_addConditional: function(input_def) {
var self = this;
input_def.test_param.id = input_def.id;
input_def.test_param.textable = false;
this.app.model.get("sustain_conditionals") && (input_def.test_param.disabled = true);
var field = this._addRow(input_def.test_param);

// set onchange event for test parameter
field.model &&
if (field.model) {
// add conditional sub sections
for (var i in input_def.cases) {
var sub_section = new View(this.app, {
inputs: input_def.cases[i].inputs
});
this._append(sub_section.$el.addClass("ui-form-section"), `${input_def.id}-section-${i}`);
}
field.model.set("onchange", value => {
var selectedCase = self.app.data.matchCase(input_def, value);
for (var i in input_def.cases) {
Expand All @@ -73,17 +80,9 @@ var View = Backbone.View.extend({
}
self.app.trigger("change");
});

// add conditional sub sections
for (var i in input_def.cases) {
var sub_section = new View(this.app, {
inputs: input_def.cases[i].inputs
});
this._append(sub_section.$el.addClass("ui-form-section"), `${input_def.id}-section-${i}`);
// trigger refresh on conditional input field after all input elements have been created
field.trigger("change");
}

// trigger refresh on conditional input field after all input elements have been created
field.trigger("change");
},

/** Add a repeat block */
Expand Down
26 changes: 17 additions & 9 deletions client/galaxy/scripts/mvc/ui/ui-misc.js
Expand Up @@ -187,17 +187,25 @@ export var Hidden = Backbone.View.extend({
/** Creates an input element which switches between select and text field */
export var TextSelect = Backbone.View.extend({
initialize: function(options) {
this.text = new Input(options);
var classes = {
"checkboxes": Checkbox,
"radio": Radio,
"radiobutton": RadioButton
}
var SelectClass = classes[options.display] || Select;
this.select = new SelectClass.View(options);
this.select = options.select;
this.model = this.select.model;
this.text = new Input({
onchange: this.model.get("onchange")
});
this.on("change", () => {
if (this.model.get("onchange")) {
this.model.get("onchange")(this.value());
}
});
this.setElement($("<div/>").append(this.select.$el)
.append(this.text.$el));
this.update(options.data);
this.update(this.model.get("data"));
},
wait: function() {
this.select.wait();
},
unwait: function() {
this.select.unwait();
},
value: function(new_val) {
var element = this.textmode ? this.text : this.select;
Expand Down
5 changes: 3 additions & 2 deletions lib/galaxy/tools/parameters/basic.py
Expand Up @@ -781,7 +781,7 @@ class SelectToolParameter(ToolParameter):
>>> print(p.name)
_name
>>> sorted(p.to_dict(trans).items())
[('argument', None), ('display', None), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'SelectToolParameter'), ('multiple', False), ('name', '_name'), ('optional', False), ('options', [('x_label', 'x', False), ('y_label', 'y', True), ('z_label', 'z', False)]), ('refresh_on_change', False), ('type', 'select'), ('value', 'y')]
[('argument', None), ('display', None), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'SelectToolParameter'), ('multiple', False), ('name', '_name'), ('optional', False), ('options', [('x_label', 'x', False), ('y_label', 'y', True), ('z_label', 'z', False)]), ('refresh_on_change', False), ('textable', True), ('type', 'select'), ('value', 'y')]
>>> p = SelectToolParameter(None, XML(
... '''
... <param name="_name" type="select" multiple="true">
Expand All @@ -793,7 +793,7 @@ class SelectToolParameter(ToolParameter):
>>> print(p.name)
_name
>>> sorted(p.to_dict(trans).items())
[('argument', None), ('display', None), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'SelectToolParameter'), ('multiple', True), ('name', '_name'), ('optional', True), ('options', [('x_label', 'x', False), ('y_label', 'y', True), ('z_label', 'z', True)]), ('refresh_on_change', False), ('type', 'select'), ('value', ['y', 'z'])]
[('argument', None), ('display', None), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'SelectToolParameter'), ('multiple', True), ('name', '_name'), ('optional', True), ('options', [('x_label', 'x', False), ('y_label', 'y', True), ('z_label', 'z', True)]), ('refresh_on_change', False), ('textable', True), ('type', 'select'), ('value', ['y', 'z'])]
>>> print(p.to_param_dict_string(["y", "z"]))
y,z
"""
Expand Down Expand Up @@ -971,6 +971,7 @@ def to_dict(self, trans, other_values={}):
d['options'] = options
d['display'] = self.display
d['multiple'] = self.multiple
d['textable'] = True
return d


Expand Down
2 changes: 1 addition & 1 deletion static/style/blue/base.css

Large diffs are not rendered by default.

0 comments on commit d9efb4f

Please sign in to comment.