Module: WorkflowsHelper

Defined in:
app/helpers/workflows_helper.rb

Overview

A few helpers used in pipeline workflows

Instance Method Summary collapse

Instance Method Details

#batch_tag_indexObject


28
29
30
31
32
33
# File 'app/helpers/workflows_helper.rb', line 28

def batch_tag_index
  @tag_hash ||= Hash[
    Tag.joins(:aliquots)
       .where(aliquots: { receptacle_id: @batch.requests.map(&:asset_id) })
       .pluck(:receptacle_id, :map_id)].tap { |th| th.default = '-' }
end

#descriptor_value(descriptor) ⇒ Object

Returns descriptor from params, if it's not there try the @study. If @study's not set or it doesn't hold the descriptor, return a blank string…


8
9
10
11
12
# File 'app/helpers/workflows_helper.rb', line 8

def descriptor_value(descriptor)
  # Refactored to remove reliance on @values
  params[:values].try(:[], descriptor.name) ||
    @study.try(:descriptor_value, descriptor.name) || ''
end

#gel_qc_select_box(request, status, html_options = {}) ⇒ Object


40
41
42
43
44
# File 'app/helpers/workflows_helper.rb', line 40

def gel_qc_select_box(request, status, html_options = {})
  html_options.delete(:generate_blank)
  status = 'OK' if status.blank? || status == 'Pass'
  select_tag("wells[#{request.id}][qc_state]", options_for_select({ 'Pass' => 'OK', 'Fail' => 'Fail', 'Weak' => 'Weak', 'No Band' => 'Band Not Visible', 'Degraded' => 'Degraded' }, status), html_options)
end

Returns a link to any available request comments with “None” as a default value.


16
17
18
19
20
21
22
# File 'app/helpers/workflows_helper.rb', line 16

def link_to_comments(request)
  link_to_if(
    request.comments.present?,
    pluralize(request.comments.size, 'comment'),
    request_comments_url(request)
  ) { 'None' }
end

#qc_select_box(request, status, html_options = {}) ⇒ Object


35
36
37
38
# File 'app/helpers/workflows_helper.rb', line 35

def qc_select_box(request, status, html_options = {})
  select_options = %w[pass fail]
  select_tag("#{request.id}[qc_state]", options_for_select(select_options, status), html_options.merge(class: 'qc_state'))
end

#tag_index_for(request) ⇒ Object


24
25
26
# File 'app/helpers/workflows_helper.rb', line 24

def tag_index_for(request)
  batch_tag_index[request.asset_id]
end