Commit 8eb10f39 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

better handle of choices

parent e67ed994
......@@ -357,7 +357,10 @@ class AbstractParameter(object):
except: self.type = types.StringType
# Set parameter value
self.default = default
if choices != None and default == None:
self.default = choices[0]
else:
self.default = default
def export_to_argparse(self):
if self.type == types.BooleanType and str(self.default).lower() in (False, "false", "f", "0"):
......
......@@ -292,7 +292,7 @@ class Workflow(threading.Thread):
# Retrieve value
if args.has_key(parameter.__getattribute__(key)):
value = args[parameter.__getattribute__(key)]
elif parameter != None:
elif parameter.default != None:
value = parameter.default
else:
value = None
......
......@@ -733,8 +733,7 @@ Handsontable.cellTypes["bootdate"] = Handsontable.BootstrapDateCell;
} else if (params_per_name[param_name].sub_parameters[i].type == "date") {
columns.push({data: params_per_name[param_name].sub_parameters[i].name, type:"bootdate", dateFormat : params_per_name[param_name].sub_parameters[i].format});
} else if (params_per_name[param_name].sub_parameters[i].choices != null) {
var all_choices = $.merge( [""], params_per_name[param_name].sub_parameters[i].choices );
columns.push({data: params_per_name[param_name].sub_parameters[i].name, type:"dropdown", source:all_choices.map(String)});
columns.push({data: params_per_name[param_name].sub_parameters[i].name, type:"dropdown", source:params_per_name[param_name].sub_parameters[i].choices.map(String)});
} else {
// TODO handle file types selection
allTypes[params_per_name[param_name].sub_parameters[i].name] = params_per_name[param_name].sub_parameters[i].type;
......@@ -893,9 +892,10 @@ Handsontable.cellTypes["bootdate"] = Handsontable.BootstrapDateCell;
, i
, ilen = changes.length
, c
, clen = instance.colCount
, clen = instance.countCols()
, rowColumnSeen = {}
, rowsToFill = {};
for (i = 0; i < ilen; i++) {
if (changes[i][2] === null && changes[i][3] !== null) { //if oldVal is empty
if (isEmptyRow(instance, changes[i][0])) {
......@@ -904,15 +904,16 @@ Handsontable.cellTypes["bootdate"] = Handsontable.BootstrapDateCell;
}
}
}
for (var r in rowsToFill) {
for (var r in rowsToFill) {
if (rowsToFill.hasOwnProperty(r)) {
for (c = 0; c < clen; c++) {
if (!rowColumnSeen[r + '/' + c]) { //if it is not provided by user in this change set, take value from template
changes.push([r, c, null, rowTemplate[c]]);
if (!rowColumnSeen[r + '/' + instance.colToProp(c)]) { //if it is not provided by user in this change set, take value from template
changes.push([parseInt(r), instance.colToProp(c), null, rowTemplate[c]]);
}
}
}
}
}
});
});
......@@ -1181,11 +1182,6 @@ Handsontable.cellTypes["bootdate"] = Handsontable.BootstrapDateCell;
'{{else}}', // if it's a single choice parameter, add a simple select
' <select id="${param.name}" name="${param.name}" class="form-control">',
'{{/if}}',
' {{if param.default != null}}',
' <option></option>',
' {{else}}',
' <option selected></option>',
' {{/if}}',
' {{each(j, choice) param.choices}}',
' {{if choice == param.default}}',
' <option selected>${choice}</option>',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment