Module: TaxonNameClassificationsHelper

Defined in:
app/helpers/taxon_name_classifications_helper.rb

Instance Method Summary collapse

Instance Method Details

#label_for_taxon_name_classification(taxon_name_classification) ⇒ Object



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

def label_for_taxon_name_classification(taxon_name_classification)
  return nil if taxon_name_classification.nil?
  label_for_taxon_name(taxon_name_classification.taxon_name) + ' (' + taxon_name_classification.classification_label + ')'
end


13
14
15
16
# File 'app/helpers/taxon_name_classifications_helper.rb', line 13

def taxon_name_classification_link(taxon_name_classification)
  return nil if taxon_name_classification.nil?
  link_to(taxon_name_classification_tag(taxon_name_classification).html_safe, metamorphosize_if(taxon_name_classification.taxon_name))
end

#taxon_name_classification_options(taxon_name) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/helpers/taxon_name_classifications_helper.rb', line 19

def taxon_name_classification_options(taxon_name)
  o = []

  if taxon_name.rank_class

  case taxon_name.rank_class.nomenclatural_code
    when :icn
      o = ICN_TAXON_NAME_CLASSIFICATION_HASH
    when :iczn
      o =  ICZN_TAXON_NAME_CLASSIFICATION_HASH
    else # should never be hit ...
      o = ICZN_TAXON_NAME_CLASSIFICATION_HASH.merge(ICN_TAXON_NAME_CLASSIFICATION_HASH)
  end

  else # taxon_name is a new record
    o = ICZN_TAXON_NAME_CLASSIFICATION_HASH.merge(ICN_TAXON_NAME_CLASSIFICATION_HASH)
  end

  options_for_select(o)
end

#taxon_name_classification_status_tag(taxon_name) ⇒ String

Returns a span summarizing taxon name classification.

Returns:

  • (String)

    a span summarizing taxon name classification



42
43
44
45
46
47
48
49
50
51
# File 'app/helpers/taxon_name_classifications_helper.rb', line 42

def taxon_name_classification_status_tag(taxon_name)
  if !taxon_name.is_valid? # taxon_name.unavailable_or_invalid?  
    values = TaxonNameClassification.where_taxon_name(taxon_name).with_type_array(ICZN_TAXON_NAME_CLASSIFICATION_NAMES + ICN_TAXON_NAME_CLASSIFICATION_NAMES).collect{|c|
      c.classification_label}.uniq.sort

      (:span, "Is an  #{values.to_sentence} name.", class: [:brief_status], data: [ 'icon-alert' ])  
  else
    (:span, 'Is a valid name.', class: [:brief_status, :passed])  
  end 
end

#taxon_name_classification_tag(taxon_name_classification) ⇒ Object



3
4
5
6
# File 'app/helpers/taxon_name_classifications_helper.rb', line 3

def taxon_name_classification_tag(taxon_name_classification)
  return nil if taxon_name_classification.nil?
  full_taxon_name_tag(taxon_name_classification.taxon_name) + ' (' + taxon_name_classification.classification_label + ')'
end

#taxon_name_classifications_recent_objects_partialTrue

Returns indicates a custom partial should be used, see list_helper.rb.

Returns:

  • (True)

    indicates a custom partial should be used, see list_helper.rb



55
56
57
# File 'app/helpers/taxon_name_classifications_helper.rb', line 55

def taxon_name_classifications_recent_objects_partial
  true 
end