sanger/sequencescape

View on GitHub
app/views/pipelines/show.html.erb

Summary

Maintainability
Test Coverage

<% add :about, "Use the tabs to view batches for this pipeline with different statuses" %>
<% add :menu, "View all pipeline batches" => url_for(action: "batches", id: @pipeline.id) %>

<% add :back_menu, "Back to all pipelines" => pipelines_url %>

<%= page_title "Pipeline", @pipeline.name %>

<%= render partial: @pipeline.inbox_partial, locals: { pipeline: @pipeline } %>

<%= legacy_javascript_tag do %>
  /*
   * When someone clicks on a request group checkbox we ensure that the count of the number of requests selected is
   * updated and, if the pipeline has a limit, that any group requests that would take us over that limit are disabled.
   */
  (function($, undefined) {
    var batch_size = 0;
    var top_of_the_inbox = $('#pipeline_inbox > tbody'), counter = $('#selection_count');

    /* Handle updating the current size of the batch */
    top_of_the_inbox.delegate('.grouped_checkbox', 'change', function(event) {
      var element = $(this);
      batch_size += (this.checked ? 1 : -1) * parseInt(element.attr('data-count'));
      counter.html('' + (batch_size === 0 ? 'no' : batch_size));
    });

    $('.action_on_request').bind('change',function(){$('.action_on_request').val(this.value)});

  <% if (batch_size = @pipeline.item_limit || @pipeline.max_size).present? %>
      /* Handle disabling the inappropriate grouped requests */
      var maximum_batch_size       = <%= @pipeline.item_limit || @pipeline.max_size %>;
      var updateSelectableRequests = function(event) {
        var remaining = maximum_batch_size - batch_size;
        $('.grouped_checkbox:not(:checked)').each(function(index, value) {
          var checkbox = $(value);
          var parent   = checkbox.parents('tr');
          if (parseInt(checkbox.attr('data-count')) > remaining) {
            checkbox.attr('disabled', 'disabled');
            parent.fadeTo(150, 0.25);
          } else {
            checkbox.removeAttr('disabled');
            parent.fadeTo(150, 1);
          }
        });
      }

      top_of_the_inbox.delegate('.grouped_checkbox', 'change', updateSelectableRequests);
      updateSelectableRequests();
  <% end %>
  })(window.jQuery);
<% end %>