Module: ExtractsHelper

Defined in:
app/helpers/extracts_helper.rb

Instance Method Summary collapse

Instance Method Details

#extract_autocomplete_tag(extract) ⇒ Object



34
35
36
37
38
39
# File 'app/helpers/extracts_helper.rb', line 34

def extract_autocomplete_tag(extract)
  return nil if extract.nil?
  [simple_identifier_list_tag(extract),
   extract_origin_tags(extract),
  ].join(' ').html_safe
end


20
21
22
23
# File 'app/helpers/extracts_helper.rb', line 20

def extract_link(extract)
  return nil if extract.nil?
  link_to(extract_tag(extract), extract)
end

#extract_made_tag(extract) ⇒ String, nil\ no HTML

Returns String, nil\ no HTML.

Returns:

  • (String, nil\ no HTML)

    String, nil\ no HTML



43
44
45
46
47
# File 'app/helpers/extracts_helper.rb', line 43

def extract_made_tag(extract)
  [extract.year_made,
   extract.month_made,
   extract.day_made].compact.join('-')
end

#extract_origin_labels(extract) ⇒ Object



53
54
55
56
57
# File 'app/helpers/extracts_helper.rb', line 53

def extract_origin_labels(extract)
 a = extract.old_objects.collect{|o| label_for(o)}
 a.unshift 'Origin' if !a.nil?
 a ? a.join(': ') + '.' : nil
end

#extract_origin_tags(extract) ⇒ Object



59
60
61
62
63
# File 'app/helpers/extracts_helper.rb', line 59

def extract_origin_tags(extract)
 a = extract.old_objects.collect{|o| object_tag(o)}
 a.unshift 'Origin' if !a.nil?
 a ? a.join(': ') + '.' : nil
end

#extract_otu_labels(extract) ⇒ Object



49
50
51
# File 'app/helpers/extracts_helper.rb', line 49

def extract_otu_labels(extract)
  extract.referenced_otus.collect{|o| label_for_otu(o)}.join('; ')
end

#extract_tag(extract) ⇒ Object

TODO: reference identifiers/origin objects etc.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/extracts_helper.rb', line 4

def extract_tag(extract)
  return nil if extract.nil?
  e = []

  if extract.old_objects.any?
    e.push ' from: '
    e.push extract.old_objects.collect{|o| object_link(o) }
  else
    "#{extract.id} (no origin)"
  end

  e.push "Extract " + extract.id.to_s if e.empty?

  e.join.html_safe
end

#extracts_search_formObject



65
66
67
# File 'app/helpers/extracts_helper.rb', line 65

def extracts_search_form
  render('/extracts/quick_search_form')
end

#label_for_extract(extract) ⇒ Object



25
26
27
28
29
30
31
32
# File 'app/helpers/extracts_helper.rb', line 25

def label_for_extract(extract)
  return nil if extract.nil?
  [ extract_origin_labels(extract),
  #  extract_otu_labels(extract),
    extract_made_tag(extract),
    identifier_list_labels(extract)
  ].compact.join('; ')
end