Module: TaxonNames::CatalogHelper

Defined in:
app/helpers/taxon_names/catalog_helper.rb

Overview

Methods to generate catog entries Each history_ method must generate a span

Instance Method Summary (collapse)

Instance Method Details

- (String) history_author_year(taxon_name, citation)

Returns the name, or citation author year, prioritized by original/new with punctuation

Returns:

  • (String)

    the name, or citation author year, prioritized by original/new with punctuation



55
56
57
58
59
60
# File 'app/helpers/taxon_names/catalog_helper.rb', line 55

def history_author_year(taxon_name, citation) 
  return (:span, ' Source is verbatim, requires parsing', class: :warning) if citation.try(:source).try(:type) == 'Source::Verbatim'
  str =  history_author_year_tag(taxon_name) 
  str.blank? ? nil : 
    (:span, ' ' + str, class: [:history_author_year])
end

- (String?) history_author_year_tag(taxon_name)

Returns variably return the author year for taxon name in question !! NO span, is used in comparison !!

Returns:

  • (String, nil)

    variably return the author year for taxon name in question !! NO span, is used in comparison !!



65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/helpers/taxon_names/catalog_helper.rb', line 65

def history_author_year_tag(taxon_name)
  return nil if taxon_name.nil? || taxon_name.cached_author_year.nil?
 
  body =  case taxon_name.type
  when 'Combination'
    current_author_year(taxon_name)
  when 'Protonym'
    original_author_year(taxon_name)
  else
    'HYBRID NOT YET HANDLED'
  end
end

- (String?) history_citation_notes(citation)

Returns any Notes on the citation in question

Returns:

  • (String, nil)

    any Notes on the citation in question



80
81
82
83
# File 'app/helpers/taxon_names/catalog_helper.rb', line 80

def history_citation_notes(citation)
  return nil if citation.nil? || !citation.notes.any?
  (:span, citation.notes.collect{|n| note_tag(n)}.join.html_safe, class: 'history__citation_notes') 
end

- (String?) history_in(t, c)

Return the citation author/year if differeing from the taxon name author year

Returns:

  • (String, nil)

    return the citation author/year if differeing from the taxon name author year



140
141
142
143
144
145
146
147
148
149
# File 'app/helpers/taxon_names/catalog_helper.rb', line 140

def history_in(t, c)
  if c
    a = history_author_year_tag(t) 
    b = citation_author_year_tag(c)

    if a != b
      return (:span,  ": #{b}", class: [:history__in])
    end
  end
end

- (String?) history_other_name(catalog_item, reference_taxon_name)

Returns a parenthesized line item containing relationship and related name

Returns:

  • (String, nil)

    a parenthesized line item containing relationship and related name



87
88
89
90
91
# File 'app/helpers/taxon_names/catalog_helper.rb', line 87

def history_other_name(catalog_item, reference_taxon_name)
  if catalog_item.from_relationship? 
    (:span, " (#{catalog_item.object.subject_status_tag} #{full_original_taxon_name_tag(catalog_item.other_name)})#{soft_validation_alert_tag(catalog_item.object)}".html_safe, class: [:history__other_name])
  end
end

- (String?) history_pages(citation)

Returns pages from the citation, with prefixed :

Returns:

  • (String, nil)

    pages from the citation, with prefixed :



95
96
97
98
# File 'app/helpers/taxon_names/catalog_helper.rb', line 95

def history_pages(citation)
  return nil if citation.nil?
  (:span, ": #{citation.pages}.", class: 'history__pages') if citation.pages
end

- (String?) history_statuses(i)

Returns A brief summary of the validity of the name (e.g. 'Valid')

... think this has to be refined, it doesn't quite make sense to show multiple status per relationship

Returns:

  • (String, nil)

    A brief summary of the validity of the name (e.g. 'Valid')

    ... think this has to be refined, it doesn't quite make sense to show multiple status per relationship


103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'app/helpers/taxon_names/catalog_helper.rb', line 103

def history_statuses(i)
  s = i.taxon_name.taxon_name_classifications_for_statuses
  return nil if (s.empty? || i.is_subsequent?)
  return nil if !i.from_relationship?

  (:span, class: [:history__statuses]) do
    (' (' +
     s.collect{|tnc|
      (:span, (tnc.classification_label + soft_validation_alert_tag(tnc).to_s).html_safe, class: ['history__status'])
    }.join(', ')
    ).html_safe +
    ')'
  end
end

- (String?) history_subject_original_citation(catalog_item)

Returns the taxon name author year for the citation in question if the same as the author/year for the catalog_item taxon name then this only renders the pages in that citation

Returns:

  • (String, nil)

    the taxon name author year for the citation in question if the same as the author/year for the catalog_item taxon name then this only renders the pages in that citation



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'app/helpers/taxon_names/catalog_helper.rb', line 122

def history_subject_original_citation(catalog_item)
  return nil if !catalog_item.from_relationship? || catalog_item.object.subject_taxon_name.origin_citation.blank?
  t = catalog_item.object.subject_taxon_name
  c = t.origin_citation

  a = history_author_year_tag(t) 
  b = citation_author_year_tag(c)

  body =  [
    (a != b ?  ': ' + citation_author_year_tag(c) : nil),
    history_pages(c)
  ].compact.join.html_safe

  (:span, body, class: :history__subject_original_citation) unless body.blank?
end

- (Object) history_taxon_name(taxon_name, r, c, target = nil)



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/helpers/taxon_names/catalog_helper.rb', line 31

def history_taxon_name(taxon_name, r, c, target = nil)
  name = original_taxon_name_tag(taxon_name)
  body = nil
  css = nil
  soft_validation = nil

  if target
    body = link_to(name, send(target, taxon_name) )
  else
    body = name 
  end

  if taxon_name == r
    css = 'history__reference_taxon_name'
  else
    css = 'history__related_taxon_name' 
    soft_validation = soft_validation_alert_tag(taxon_name)
  end

  (:span, body + soft_validation.to_s, class: [css, original_citation_css(taxon_name, c), :history__taxon_name ]) 
end

- (Object) history_topics(citation)



151
152
153
154
# File 'app/helpers/taxon_names/catalog_helper.rb', line 151

def history_topics(citation)
  return nil if citation.nil?
  (:span, Utilities::Strings.nil_wrap(' [', citation.citation_topics.collect{|t| t.topic.name}.join(", "), ']'), class: 'history__citation_topics')
end

- (Object) history_type_material(entry_item)



156
157
158
159
# File 'app/helpers/taxon_names/catalog_helper.rb', line 156

def history_type_material(entry_item)
  return nil if entry_item.object_class != 'Protonym' || entry_item.is_subsequent?
  (:span, ' '.html_safe + type_taxon_name_relationship_tag(entry_item.taxon_name.type_taxon_name_relationship), class: 'history__type_information')
end

- (Object) nomenclature_catalog_li_tag(nomenclature_catalog_item, reference_taxon_name, target = :browse_nomenclature_task_path)



5
6
7
# File 'app/helpers/taxon_names/catalog_helper.rb', line 5

def nomenclature_catalog_li_tag(nomenclature_catalog_item, reference_taxon_name, target = :browse_nomenclature_task_path)
  (:li, nomenclature_line_tag(nomenclature_catalog_item, reference_taxon_name, target), class: :history__record)
end

- (Object) nomenclature_line_tag(nomenclature_catalog_item, reference_taxon_name, target = :browse_nomenclature_task_path)



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/taxon_names/catalog_helper.rb', line 9

def nomenclature_line_tag(nomenclature_catalog_item, reference_taxon_name, target = :browse_nomenclature_task_path)
  i = nomenclature_catalog_item
  t = i.taxon_name
  c = i.citation
  r = reference_taxon_name

  [  
    history_taxon_name(t, r, c, target),        # the subject, or protonym
    history_author_year(t, c),                  # author year of the subject, or protonym
                                               
    history_subject_original_citation(i),      
    history_statuses(i),                        # TaxonNameClassification summary
    history_other_name(i, r),                   # The TaxonNameRelaltionship
    history_in(t, c),                           #  citation for related name 
    history_pages(c),                           #  pages for citation of related name
    history_citation_notes(c),                  # Notes on the citation 
    history_topics(c),                          # Topics on the citation
#      (i.object.class.name == 'Protonym' ? history_type_material(t, i.is_subsequent?) : nil), # Type material reference 
    history_type_material(i),
  ].compact.join.html_safe
end

- (String?) original_citation_css(taxon_name, citation) (protected)

Returns a computed css class, when provided indicates that the citation is the original citation for the taxon name provided

Returns:

  • (String, nil)

    a computed css class, when provided indicates that the citation is the original citation for the taxon name provided



165
166
167
168
# File 'app/helpers/taxon_names/catalog_helper.rb', line 165

def original_citation_css(taxon_name, citation)
  return nil if citation.nil?
  'history__original_description' if citation.is_original? && taxon_name == citation.citation_object
end