commit/galaxy-central: 3 new changesets
3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/26f7825cc871/ changeset: 26f7825cc871 user: jmchilton date: 2013-02-23 08:14:22 summary: Refactor code related to expanding multi inputs to more easily allow for switching between matched and product mode in the same workflow execution. affected #: 1 file diff -r 1c2e1625dd8a419aa1d335ddc19ba34857c05fc4 -r 26f7825cc871c752d1e79bbe8984857d67f1eb0e lib/galaxy/webapps/galaxy/controllers/workflow.py --- a/lib/galaxy/webapps/galaxy/controllers/workflow.py +++ b/lib/galaxy/webapps/galaxy/controllers/workflow.py @@ -2106,22 +2106,27 @@ def _expand_multiple_inputs(kwargs, mode): - (input_combos, multi_inputs) = _build_input_combos(kwargs, mode) + (single_inputs, matched_multi_inputs, multiplied_multi_inputs) = \ + _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) + + # Input name that are multiply specified + multi_input_keys = \ + matched_multi_inputs.keys() + multiplied_multi_inputs.keys() + for input_combo in input_combos: for key, value in input_combo.iteritems(): kwargs[key] = value - yield (kwargs, multi_inputs.keys()) + yield (kwargs, multi_input_keys) -def _build_input_combos(kwargs, mode): - if mode == "product": - return _build_input_combos_product(kwargs) - else: # mode == "matched" - return _build_input_combos_matched(kwargs) -def _build_input_combos_matched(kwargs): - (single_inputs, multi_inputs) = _split_inputs(kwargs) +def _extend_with_matched_combos(single_inputs, multi_inputs): if len(multi_inputs) == 0: - return ([{}], {}) + return [single_inputs] matched_multi_inputs = [] @@ -2139,11 +2144,12 @@ raise Exception("Failed to match up multi-select inputs, must select equal number of data files in each multiselect") for index, value in enumerate(multi_input_values): matched_multi_inputs[index][multi_input_key] = value - return (matched_multi_inputs, multi_inputs) + return matched_multi_inputs -def _build_input_combos_product(kwargs): - (single_inputs, multi_inputs) = _split_inputs(kwargs) - combos = [single_inputs] + +def _extend_with_multiplied_combos(input_combos, multi_inputs): + combos = input_combos + for multi_input_key, multi_input_value in multi_inputs.iteritems(): iter_combos = [] @@ -2152,14 +2158,18 @@ iter_combos.append(_copy_and_extend_inputs(combo, multi_input_key, input_value)) combos = iter_combos - return (combos, multi_inputs) + return combos + def _copy_and_extend_inputs(inputs, key, value): new_inputs = dict(inputs) new_inputs[key] = value return new_inputs -def _split_inputs(kwargs): + +def _split_inputs(kwargs, mode): + """ + """ input_keys = filter(lambda a: a.endswith('|input'), kwargs) single_inputs = {} multi_inputs = {} @@ -2169,4 +2179,10 @@ multi_inputs[input_key] = input_val else: single_inputs[input_key] = input_val - return (single_inputs, multi_inputs) + 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) https://bitbucket.org/galaxy/galaxy-central/commits/6f30725d5973/ changeset: 6f30725d5973 user: jmchilton date: 2013-02-23 08:14:22 summary: Implement UI multi batch workflow inputs. affected #: 4 files diff -r 26f7825cc871c752d1e79bbe8984857d67f1eb0e -r 6f30725d59732a351ca9b4f6fd7bc14f43c8a4a1 lib/galaxy/webapps/galaxy/controllers/workflow.py --- a/lib/galaxy/webapps/galaxy/controllers/workflow.py +++ b/lib/galaxy/webapps/galaxy/controllers/workflow.py @@ -2110,7 +2110,6 @@ _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 @@ """ 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 -r 26f7825cc871c752d1e79bbe8984857d67f1eb0e -r 6f30725d59732a351ca9b4f6fd7bc14f43c8a4a1 static/images/silk/link.png Binary file static/images/silk/link.png has changed diff -r 26f7825cc871c752d1e79bbe8984857d67f1eb0e -r 6f30725d59732a351ca9b4f6fd7bc14f43c8a4a1 static/images/silk/link_break.png Binary file static/images/silk/link_break.png has changed diff -r 26f7825cc871c752d1e79bbe8984857d67f1eb0e -r 6f30725d59732a351ca9b4f6fd7bc14f43c8a4a1 templates/webapps/galaxy/workflow/run.mako --- 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; + }); }); </script></%def> @@ -260,6 +311,7 @@ %if step.type == 'data_input': ##Input Dataset Step, wrap for multiinput. <span class='multiinput_wrap'> + <input class="multi-mode" type="hidden" name="${str(step.id)}|multi_mode" id="${str(step.id)}|multi_mode" value="matched" /> ${param.get_html_field( t, value, other_values ).get_html( str(step.id) + "|" + prefix )} </span> %else: @@ -340,30 +392,6 @@ <form id="tool_form" name="tool_form" method="POST"> ## <input type="hidden" name="workflow_name" value="${h.to_unicode( workflow.name ) | h}" /> -<!-- TODO: Implement UI for selecting between product and matched mode - for batch workflows in multiple inputs are selected for 2 or more - params. - - 1) Delete this line above: $('.multiinput').addClass('disabled'); - 2) Allow user to select between product and matched mode. - - If user selected 5 inputs for one param and 5 inputs for another - in matched mode that will be run the workflow 5 times matching - each input and in product mode it will run the workflow 25 times - with every combination of input pairs. If user selects 6 inputs - for one param and 4 for another, in product mode 24 workflows - will run and in matched mode the submission will fail. - - In matched mode the inputs are matched from top to bottom - regardless of the order they are actually select in. This - behavior is I assume the desired behavior but I have only tested - it in chrome, care should be taken to test behavior on other - browsers and augment UI to ensure numbers of inputs matches - up. ---> -<input type="hidden" name="multiple_input_mode" value="matched" /><!-- product or matched --> - - %if wf_parms: <div class="metadataForm"><div class="metadataFormTitle">Workflow Parameters</div> https://bitbucket.org/galaxy/galaxy-central/commits/fa34924860aa/ changeset: fa34924860aa user: jmchilton date: 2013-02-23 08:14:22 summary: Touch up UI related to multi input batch mode - move icon up by the multi document icon, switch from icon to CSS span, cleanup variable names. affected #: 1 file diff -r 6f30725d59732a351ca9b4f6fd7bc14f43c8a4a1 -r fa34924860aaa282fe3c3021a257f2523848a6e6 templates/webapps/galaxy/workflow/run.mako --- a/templates/webapps/galaxy/workflow/run.mako +++ b/templates/webapps/galaxy/workflow/run.mako @@ -1,5 +1,11 @@ <%inherit file="/base.mako"/> +<style> +/* TODO: Move this block into base.less? base.css? Someone more familiar with GUI should move this. */ +.icon-button.link {background:url(../images/silk/link.png) no-repeat;cursor:pointer;float:none;display:inline-block;margin-left:10px;} +.icon-button.link-broken {background:url(../images/silk/link_break.png) no-repeat;cursor:pointer;float:none;display:inline-block;margin-left:10px;} +</style> + <%def name="javascripts()"> ${parent.javascripts()} ${h.js( "libs/jquery/jquery.autocomplete" )} @@ -33,12 +39,12 @@ } else { select.val($('option:last', select).val()); } - select.siblings('img').hide(); + select.closest('.form-row').children('label').children('span.mode-icon').hide(); select.removeAttr('multiple').removeAttr('size'); placeholder = 'type to filter'; } else { $('.multiinput', select.closest('.form-row')).removeClass('disabled'); - select.siblings('img').show(); + select.closest('.form-row').children('label').children('span.mode-icon').show(); select.attr('multiple', 'multiple').attr('size', 8); placeholder = 'type to filter, [enter] to select all'; } @@ -129,30 +135,25 @@ // 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")); + $(this).closest('.form-row').children('label').append($('<span class="icon-button link mode-icon"></span>') + .attr({id:$(this).attr("id")}) + .css("display", $(this).css("display"))); } else { - $(this).before($(document.createElement("img")) - .attr({src:imgOff, title:'Checkbox',id:$(this).attr("id")}) - .css("display", $(this).css("display")) - .addClass("chkBoxImg")); + $(this).closest('.form-row').children('label').append($('<span class="icon-button link-broken mode-icon"></span>') + .attr({id:$(this).attr("id")}) + .css("display", $(this).css("display"))); } }); - $("img.chkBoxImg").click(function(){ - i= $(this).siblings("input[type=hidden]"); - s=$(this).attr("src"); - if(s==imgOn) { - $(this).attr("src",imgOff); + $("span.mode-icon").click(function(){ + i= $(this).closest('.form-row').find("input[type=hidden]"); + if($(this).hasClass("link")) { + $(this).removeClass("link").addClass("link-broken"); $(i).val("product"); } else { - $(this).attr("src",imgOn); + $(this).removeClass("link-broken").addClass("link"); $(i).val("matched"); } }); Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org