Skip to content
Snippets Groups Projects
Commit b49b1792 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

make available browsefile as type

parent 926ddb1c
No related branches found
No related tags found
No related merge requests found
......@@ -334,7 +334,7 @@ class Workflow(threading.Thread):
# handle upload inputs
try: is_local = os.path.isfile(args[param])
except: is_local = False
if not is_uri and not is_local and kparams[param].type.__name__ == "inputfile":
if not is_uri and not is_local and (kparams[param].type.__name__ == "inputfile" or kparams[param].type.__name__ == "browsefile"):
if args[param].__class__.__name__ == "list":
for i, val in enumerate(args[param]):
if args[param][i]:
......
......@@ -200,9 +200,9 @@ jQuery.validator.addMethod("exclude_required", function(value, element, options)
$this = this;
// before serializing, all inputs have to be abled, otherwise they are not transmitted
$("span[id^=inputfile_]").each(function(){
$("[id^=urlfile_btn_]").each(function(){
var parts = $(this).attr("id").split("_"),
tid = parts.slice(1, parts.lenght).join("_");
tid = parts.slice(2, parts.lenght).join("_");
$("#"+tid).removeAttr('disabled');
// change the name of the val by the file name with the prefix
if ($("#"+tid).val()) {
......@@ -366,6 +366,14 @@ jQuery.validator.addMethod("exclude_required", function(value, element, options)
crule["number"] = true;
} else if (param.type == "date") {
crule["date"] = true;
} else if (param.type == "browsefile") {
crule["remote"] = {
url: server_url + '/validate_field?callback=?',
type: "post",
data: {
type: "str"
}
};
} else if (param.type == "inputfile") {
crule["remote"] = {
url: server_url + '/validate_field?callback=?',
......@@ -468,6 +476,12 @@ jQuery.validator.addMethod("exclude_required", function(value, element, options)
' <button id="urlfile_btn_${param.name}" style="display: none;" class="btn" type="button"><i class="icon-search"></i></button>',
' </div>',
' </div>',
// if param is a browsefile
'{{else param.type == "browsefile"}}',
' <div class="input-append">',
' <input id="${param.name}" name="${param.name}" class="${param.group} ${input_size}" type="text" value="${param.default}" disabled>',
' <button id="urlfile_btn_${param.name}" class="btn" type="button"><i class="icon-search"></i></button>',
' </div>',
// if param is a boolean
'{{else param.type == "bool"}}',
' <label class="checkbox">',
......@@ -542,8 +556,8 @@ jQuery.validator.addMethod("exclude_required", function(value, element, options)
'<form method="post" enctype="multipart/form-data" style="display:none;">',
' {{each(gindex, group) workflow.groups}}',
' {{each(index, param) workflow.parameters_per_groups[group]}}',
// if param is an inputfile
' {{if param.type == "inputfile"}}',
// if param is an inputfile or just a browsefile
' {{if param.type == "inputfile" || param.type == "browsefile"}}',
' <input name="browse_${param.name}" id="browse_${param.name}" class="fileupload" type="file">',
' {{/if}}',
' {{/each}}',
......
......@@ -26,8 +26,8 @@ description = align reads against a reference genome
# .help: a brief description of what the parameter does
# .default [None]: the value produced if the parameter is not provided
# .type [str]: the parameter type that should be tested, this can be:
# str|int|date|inputfile|urlfile|localfile|bool|... all types defined
# in the types.py package)
# str|int|date|inputfile|urlfile|localfile|browsefile|bool|... all types
# defined in the types.py package)
# .choices [None]: a container of the allowable values for the parameter
# .required [False]: whether or not the command-line option may be omitted
# .action [store]: the basic type of action to be taken (store|append)
......
......@@ -29,6 +29,11 @@ from jflow.config_reader import JFlowConfigReader
def date(datestr):
return datetime.datetime.strptime(datestr, '%d/%m/%Y')
def browsefile(file):
# browsefile are not available from command line, considere it as a localfile
# from the gui, this will not been tested this way
return localfile(file)
def localfile(file):
if os.path.isfile(file):
return os.path.abspath(file)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment