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