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



75
76
77
78
79
80
# File 'app/helpers/taxon_names/catalog_helper.rb', line 75

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



85
86
87
88
89
90
91
92
93
94
95
96
# File 'app/helpers/taxon_names/catalog_helper.rb', line 85

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



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

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



160
161
162
163
164
165
166
167
168
169
# File 'app/helpers/taxon_names/catalog_helper.rb', line 160

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



107
108
109
110
111
# File 'app/helpers/taxon_names/catalog_helper.rb', line 107

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 :



115
116
117
118
# File 'app/helpers/taxon_names/catalog_helper.rb', line 115

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


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

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.to_s
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



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

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)

def history_origin(i)

(:span, i.origin.humanize, class: ['history__origin', i.origin ])

end



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/helpers/taxon_names/catalog_helper.rb', line 51

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)



171
172
173
174
# File 'app/helpers/taxon_names/catalog_helper.rb', line 171

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)



176
177
178
179
# File 'app/helpers/taxon_names/catalog_helper.rb', line 176

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
8
9
10
11
12
# 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).html_safe, 
    class: [:history__record],
    data: nomenclature_catalog_li_tag_data_attributes(nomenclature_catalog_item)
  ) 
end

- (Object) nomenclature_catalog_li_tag_data_attributes(nomenclature_catalog_item)



14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/taxon_names/catalog_helper.rb', line 14

def nomenclature_catalog_li_tag_data_attributes(nomenclature_catalog_item)
  n = nomenclature_catalog_item
  data = {
    'history-origin' => n.origin,
    'history-object-id' => n.object.id,
    'history-valid-name' => n.is_valid_name? && !n.is_subsequent?,
    'history-is-subsequent' => n.is_subsequent?
  }
  data
end

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



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/helpers/taxon_names/catalog_helper.rb', line 25

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("\n").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



185
186
187
188
# File 'app/helpers/taxon_names/catalog_helper.rb', line 185

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