Module: OtusHelper

Defined in:
app/helpers/otus_helper.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) label_for_otu(otu)



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

def label_for_otu(otu)
  return nil if otu.nil?
  [otu.name, 
   label_for_taxon_name(otu.taxon_name)
  ].compact.join(': ')
end

- (String) otu_autocomplete_selected_tag(otu)

Returns no HTML inside <input>

Returns:

  • (String)

    no HTML inside <input>



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

def otu_autocomplete_selected_tag(otu)
  return nil if otu.nil? || (otu.new_record? && !otu.changed?)
  [otu.name, 
   Utilities::Strings.nil_wrap('[',taxon_name_autocomplete_selected_tag(otu.taxon_name), ']')
  ].compact.join(' ')
end


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

def otu_link(otu)
  return nil if otu.nil?
  link_to(otu_tag(otu).html_safe, otu)
end

- (Object) otu_tag(otu)



3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/otus_helper.rb', line 3

def otu_tag(otu)
  return nil if otu.nil?
  a = (:span, otu.name, class: :otu_tag_otu_name) if otu.name
  b = (:span, full_taxon_name_tag(otu.taxon_name).html_safe, class: :otu_tag_taxon_name) if otu.taxon_name_id
  if otu.taxon_name_id && otu.taxon_name.rank_class.to_s =~ /Genus/
    b += " sp."
    b = b.gsub('"</span> sp.', ' sp."</span>').gsub('</span> sp.', ' sp.</span>')
  end
  (:span, [b,a].compact.join.html_safe, class: :otu_tag)
end


39
40
41
# File 'app/helpers/otus_helper.rb', line 39

def otus_link_list_tag(otus)
  otus.collect { |o| link_to(o.name, o) }.join(',')
end

- (Object) otus_radial(object)



53
54
55
# File 'app/helpers/otus_helper.rb', line 53

def otus_radial(object)
  (:div, '', 'data-global-id' => object.to_global_id.to_s, 'data-otu-radial' => 'true')
end

- (Object) otus_radial_disambiguate(object)



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

def otus_radial_disambiguate(object)
  otu = object.metamorphosize
  (:div, '', 'data-taxon-name' => object_tag(otu), 'data-redirect' => 'false', 'data-taxon-id' => otu.id, 'data-otu-button' => 'true')
end

- (Object) otus_redirect(object)



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

def otus_redirect(object)
  otu = object.metamorphosize
  (:div, '', 'data-taxon-name' => object_tag(otu), 'data-redirect' => 'true', 'data-taxon-id' => otu.id, 'data-otu-button' => 'true')
end

- (Object) otus_search_form



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

def otus_search_form
  render('/otus/quick_search_form')
end