mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-30 18:13:23 +08:00
add support for the 'conditional' input type
This commit is contained in:
@@ -12,6 +12,7 @@ class TourGenerator(object):
|
||||
self._trans = trans
|
||||
self._tool = self._trans.app.toolbox.get_tool(tool_id)
|
||||
|
||||
self._use_datasets = True
|
||||
self._tour = {}
|
||||
self._hids = {}
|
||||
self._errors = []
|
||||
@@ -36,7 +37,9 @@ class TourGenerator(object):
|
||||
]
|
||||
|
||||
if not input_datasets:
|
||||
raise ValueError('Test data is missing.')
|
||||
self._use_datasets = False
|
||||
return
|
||||
# raise ValueError('Test data is missing.')
|
||||
|
||||
# Upload all test datasets
|
||||
for i, input in enumerate(input_datasets):
|
||||
@@ -115,9 +118,9 @@ class TourGenerator(object):
|
||||
text_param = self._test.inputs[name]
|
||||
step['content'] = 'Enter parameter(s): <b>%s</b>' % text_param
|
||||
|
||||
elif input.type == 'integer':
|
||||
integer_param = self._test.inputs[name][0]
|
||||
step['content'] = 'Enter parameter: <b>%s</b>' % integer_param
|
||||
elif input.type == 'integer' or input.type == 'float':
|
||||
num_param = self._test.inputs[name][0]
|
||||
step['content'] = 'Enter parameter: <b>%s</b>' % num_param
|
||||
|
||||
elif input.type == 'boolean':
|
||||
choice = 'Yes' if self._test.inputs[name][0] is True else 'No'
|
||||
@@ -133,9 +136,8 @@ class TourGenerator(object):
|
||||
params.append(option[0])
|
||||
if params:
|
||||
select_param = ', '.join(params)
|
||||
step[
|
||||
'content'] = 'Select parameter(s): <b>%s</b>' % \
|
||||
select_param
|
||||
step['content'] = 'Select parameter(s): <b>%s</b>' % \
|
||||
select_param
|
||||
|
||||
elif input.type == 'data':
|
||||
hid = self._hids[name]
|
||||
@@ -149,8 +151,23 @@ class TourGenerator(object):
|
||||
# step['content'] = 'Select parameter <b>%s</b>' % input.title
|
||||
|
||||
elif input.type == 'conditional':
|
||||
# TODO@me: deal with this input type
|
||||
pass
|
||||
param_id = '%s|%s' % (input.name, input.test_param.name)
|
||||
step['element'] = '[tour_id="%s"]' % param_id
|
||||
cond_param = input.label
|
||||
params = []
|
||||
for option in input.test_param.static_options:
|
||||
if param_id in self._test.inputs.keys():
|
||||
for test_option in self._test.inputs[param_id]:
|
||||
if test_option == option[1]:
|
||||
params.append(option[0])
|
||||
if params:
|
||||
cond_param = ', '.join(params)
|
||||
step['content'] = 'Select parameter(s): <b>%s</b>' % \
|
||||
cond_param
|
||||
|
||||
elif input.type == 'data_column':
|
||||
column_param = self._test.inputs[name][0]
|
||||
step['content'] = 'Select <b>Column: %s</b>' % column_param
|
||||
|
||||
else:
|
||||
step['content'] = 'Select parameter <b>%s</b>' % input.label
|
||||
@@ -178,7 +195,11 @@ class TourGenerator(object):
|
||||
Return a dictionary with the uploaded datasets' history ids and
|
||||
the generated tour.
|
||||
"""
|
||||
return {'hids': list(self._hids.values()), 'tour': self._tour}
|
||||
return {
|
||||
'useDatasets': self._use_datasets,
|
||||
'hids': list(self._hids.values()),
|
||||
'tour': self._tour
|
||||
}
|
||||
|
||||
|
||||
def main(trans, webhook, params):
|
||||
|
||||
@@ -14,32 +14,37 @@ $(document).ready(function() {
|
||||
tool_id: this.toolId
|
||||
}, function(obj) {
|
||||
if (obj.success) {
|
||||
$('#history-refresh-button').click(); // Refresh history panel
|
||||
if (obj.data.useDatasets) {
|
||||
$('#history-refresh-button').click(); // Refresh history panel
|
||||
|
||||
// Add a delay because of the history panel refreshing
|
||||
setTimeout(function() {
|
||||
var datasets = [],
|
||||
numUploadedDatasets = 0;
|
||||
// TODO@me: sometimes doesn't work, find a better solution (e.g. catch a redraw event)
|
||||
// Add a delay because of the history panel refreshing
|
||||
setTimeout(function () {
|
||||
var datasets = [],
|
||||
numUploadedDatasets = 0;
|
||||
|
||||
_.each(obj.data.hids, function(hid) {
|
||||
var dataset = Galaxy.currHistoryPanel.collection.where({
|
||||
hid: hid
|
||||
})[0];
|
||||
if (dataset) datasets.push(dataset);
|
||||
});
|
||||
|
||||
if (datasets.length === obj.data.hids.length) {
|
||||
_.each(datasets, function(dataset) {
|
||||
dataset.on('change:state', function(model) {
|
||||
if (model.get('state') === 'ok') numUploadedDatasets++;
|
||||
// Make sure that all test datasets have been successfully uploaded
|
||||
if (numUploadedDatasets === datasets.length) me._main(obj.data);
|
||||
});
|
||||
_.each(obj.data.hids, function (hid) {
|
||||
var dataset = Galaxy.currHistoryPanel.collection.where({
|
||||
hid: hid
|
||||
})[0];
|
||||
if (dataset) datasets.push(dataset);
|
||||
});
|
||||
} else {
|
||||
Toastr.error('Some of the test datasets cannot be found in the history.');
|
||||
}
|
||||
}, 500);
|
||||
|
||||
if (datasets.length === obj.data.hids.length) {
|
||||
_.each(datasets, function (dataset) {
|
||||
dataset.on('change:state', function (model) {
|
||||
if (model.get('state') === 'ok') numUploadedDatasets++;
|
||||
// Make sure that all test datasets have been successfully uploaded
|
||||
if (numUploadedDatasets === datasets.length) me._main(obj.data);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Toastr.error('Some of the test datasets cannot be found in the history.');
|
||||
}
|
||||
}, 500);
|
||||
} else {
|
||||
me._main(obj.data);
|
||||
}
|
||||
} else {
|
||||
Toastr.error(obj.error);
|
||||
console.error('Tour Generator: ' + obj.error);
|
||||
|
||||
Reference in New Issue
Block a user