From 5be191fd47e8c6da0b74b389ed29664fc990bec3 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Sat, 23 Feb 2013 01:14:22 -0600 Subject: [PATCH] Implement UI multi batch workflow inputs. --- .../webapps/galaxy/controllers/workflow.py | 18 ++-- static/images/silk/link.png | Bin 0 -> 343 bytes static/images/silk/link_break.png | Bin 0 -> 657 bytes templates/webapps/galaxy/workflow/run.mako | 80 ++++++++++++------ 4 files changed, 63 insertions(+), 35 deletions(-) create mode 100644 static/images/silk/link.png create mode 100644 static/images/silk/link_break.png diff --git a/lib/galaxy/webapps/galaxy/controllers/workflow.py b/lib/galaxy/webapps/galaxy/controllers/workflow.py index e08f3fc194a..9cfbabd94f0 100644 --- a/lib/galaxy/webapps/galaxy/controllers/workflow.py +++ b/lib/galaxy/webapps/galaxy/controllers/workflow.py @@ -2110,7 +2110,6 @@ def _expand_multiple_inputs(kwargs, mode): _split_inputs(kwargs, mode) # Build up every combination of inputs to be run together. - #input_combos = [single_inputs] input_combos = _extend_with_matched_combos(single_inputs, matched_multi_inputs) input_combos = _extend_with_multiplied_combos(input_combos, multiplied_multi_inputs) @@ -2172,17 +2171,18 @@ def _split_inputs(kwargs, mode): """ input_keys = filter(lambda a: a.endswith('|input'), kwargs) single_inputs = {} - multi_inputs = {} + matched_multi_inputs = {} + multiplied_multi_inputs = {} for input_key in input_keys: input_val = kwargs[input_key] if isinstance(input_val, list): - multi_inputs[input_key] = input_val + input_base = input_key[:-len("|input")] + mode_key = "%s|multi_mode" % input_base + mode = kwargs.get(mode_key, "matched") + if mode == "matched": + matched_multi_inputs[input_key] = input_val + else: + multiplied_multi_inputs[input_key] = input_val else: single_inputs[input_key] = input_val - matched_multi_inputs = {} - multiplied_multi_inputs = {} - if mode == "product": - multiplied_multi_inputs = multi_inputs - else: - matched_multi_inputs = multi_inputs return (single_inputs, matched_multi_inputs, multiplied_multi_inputs) diff --git a/static/images/silk/link.png b/static/images/silk/link.png new file mode 100644 index 0000000000000000000000000000000000000000..25eacb7c2524142262d68bf729c5e2b61adfd6d4 GIT binary patch literal 343 zcmV-d0jU0oP)$`dXYaZs9=SbAto%g@>T~?_bH&lTUn@`uo|1bXE{eSR(AO)ESb=V4`uk}mK|39Px&03WLbv~pzk+s7D@lK^ zn+aB+sp)&Y_x-B3>;6ywU--WQNUr<8>TU0P-|L#1U&;A)67w(+> pDf@fM7q9#F25QXo3rUI;002ro52U44e~JJA002ovPDHLkV1l;_q@Mr) literal 0 HcmV?d00001 diff --git a/static/images/silk/link_break.png b/static/images/silk/link_break.png new file mode 100644 index 0000000000000000000000000000000000000000..523575306d53eaf176b4f9b260f0d36852565596 GIT binary patch literal 657 zcmV;C0&e|@P)>>Oks2`oIPl8XEc) z7Z-oHdiCnNh=_=7-rnASQd3j^Pnt9-52PSJKmR|74-yB-uUN6-AxJ$)AIt?^O-)VT zCr_T74pjKb-rk;L@7}!}=gytu04X?h=n%)+wQD(m;%Y$oCm?ko^&ov<19WwDGt<-4 z-%p!1tt2QYXs4s2<1aTixBr2Gf&W1YfV4h{4-yB-gVcf4gYO zty=YV-MV%Er%#{$zp$_nY(Pat1(**K2g!rffz*TafelboQ)31?&%n#e>wZc~%9rfy z?C(JQGdw&z4x}IUyRt?v{0wJ6^R0W@A*Z8= z&I?WjSJx&^y7yBz?2M*SZ18QRLbAs(#0rsh%4F{kwbCf;j=k00000NkvXXu0mjf-HSTy literal 0 HcmV?d00001 diff --git a/templates/webapps/galaxy/workflow/run.mako b/templates/webapps/galaxy/workflow/run.mako index 40852dc7527..72779d655c2 100644 --- a/templates/webapps/galaxy/workflow/run.mako +++ b/templates/webapps/galaxy/workflow/run.mako @@ -33,12 +33,12 @@ } else { select.val($('option:last', select).val()); } + select.siblings('img').hide(); select.removeAttr('multiple').removeAttr('size'); placeholder = 'type to filter'; } else { - // Comment out the following line to multiple batch input workflows in UI. - $('.multiinput').addClass('disabled'); $('.multiinput', select.closest('.form-row')).removeClass('disabled'); + select.siblings('img').show(); select.attr('multiple', 'multiple').attr('size', 8); placeholder = 'type to filter, [enter] to select all'; } @@ -126,6 +126,57 @@ select.after(filter); select.width(new_width); }); + + // Augment hidden fields with icons. + // http://stackoverflow.com/a/2088430 + var imgOn='${h.url_for("/static/images/silk/link.png")}'; + var imgOff='${h.url_for("/static/images/silk/link_break.png")}'; + $(function(){ + $(".multi-mode").each(function(){ + if($(this).val() == "matched") { + $(this).before($(document.createElement("img")) + .attr({src:imgOn,title:'Checkbox', id:$(this).attr("id")}) + .css("display", $(this).css("display")) + .addClass("chkBoxImg")); + } else { + $(this).before($(document.createElement("img")) + .attr({src:imgOff, title:'Checkbox',id:$(this).attr("id")}) + .css("display", $(this).css("display")) + .addClass("chkBoxImg")); + } + }); + $("img.chkBoxImg").click(function(){ + i= $(this).siblings("input[type=hidden]"); + s=$(this).attr("src"); + if(s==imgOn) { + $(this).attr("src",imgOff); + $(i).val("product"); + } else { + $(this).attr("src",imgOn); + $(i).val("matched"); + } + }); + }); + $("#tool_form").submit(function(e) { + var matchLength = -1; + $('span.multiinput_wrap select[name*="|input"]').each(function() { + var value = $(this).val(); + if(value instanceof Array) { + // Multi-value + if($(this).siblings("input[type=hidden]").val() == "matched") { + var length = $(this).val().length; + if(matchLength == -1) { + matchLength = length; + } else if(length != matchLength) { + e.preventDefault(); + alert("Linked inputs must be submitted in equal number."); + return false; + } + } + } + }); + return true; + }); }); @@ -260,6 +311,7 @@ if wf_parms: %if step.type == 'data_input': ##Input Dataset Step, wrap for multiinput. + ${param.get_html_field( t, value, other_values ).get_html( str(step.id) + "|" + prefix )} %else: @@ -340,30 +392,6 @@ if wf_parms:
## - - - - %if wf_parms:
Workflow Parameters