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



59
60
61
62
63
64
# File 'app/helpers/taxon_names/catalog_helper.rb', line 59

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 !!



69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/helpers/taxon_names/catalog_helper.rb', line 69

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



84
85
86
87
# File 'app/helpers/taxon_names/catalog_helper.rb', line 84

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



144
145
146
147
148
149
150
151
152
153
# File 'app/helpers/taxon_names/catalog_helper.rb', line 144

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

- (Object) history_origin(i)



31
32
33
# File 'app/helpers/taxon_names/catalog_helper.rb', line 31

def history_origin(i)
  (:span, i.origin.humanize, class: ['history__origin', i.origin ])
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



91
92
93
94
95
# File 'app/helpers/taxon_names/catalog_helper.rb', line 91

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 :



99
100
101
102
# File 'app/helpers/taxon_names/catalog_helper.rb', line 99

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


107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'app/helpers/taxon_names/catalog_helper.rb', line 107

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



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'app/helpers/taxon_names/catalog_helper.rb', line 126

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)



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/helpers/taxon_names/catalog_helper.rb', line 35

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)



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

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)



160
161
162
163
# File 'app/helpers/taxon_names/catalog_helper.rb', line 160

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_origin(i), 
    history_taxon_name(t, r, c, target),        # the subject, or protonym
    history_statuses(i),                        # TaxonNameClassification summary
    history_author_year(t, c),                  # author year of the subject, or protonym
    history_subject_original_citation(i),
    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



169
170
171
172
# File 'app/helpers/taxon_names/catalog_helper.rb', line 169

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