Module: TaxonNames::CatalogHelper
- Defined in:
- app/helpers/taxon_names/catalog_helper.rb
Overview
Helpers for catalog rendering. See also helpers/lib/catalog_helper.rb Each history_ method must generate a span
Instance Method Summary collapse
-
#history_author_year(taxon_name, citation) ⇒ String
The name, or citation author year, prioritized by original/new with punctuation.
-
#history_author_year_tag(taxon_name) ⇒ String?
Variably return the author year for taxon name in question !! NO span, is used in comparison !!.
-
#history_in_taxon_name(t, c, i) ⇒ String?
Return the citation author/year if differeing from the taxon name author year.
-
#history_other_name(catalog_item, reference_taxon_name) ⇒ String?
A parenthesized line item containing relationship and related name.
-
#history_statuses(nomenclature_catalog_entry_item) ⇒ String?
A brief summary of the validity of the name (e.g. 'Valid') …
-
#history_subject_original_citation(catalog_item) ⇒ String?
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.
- #history_taxon_name(taxon_name, r, c, target = nil) ⇒ Object
- #history_type_material(entry_item) ⇒ Object
-
#nomenclature_catalog_entry_item_tag(catalog_entry_item) ⇒ Object
may need reference_object.
-
#nomenclature_catalog_li_tag(nomenclature_catalog_item, reference_taxon_name, target = :browse_nomenclature_task_path) ⇒ Object
TODO: rename reference_taxon_name.
-
#nomenclature_catalog_li_tag_data_attributes(nomenclature_catalog_item) ⇒ Object
TODO: move to Catalog json data attributes helper.
-
#nomenclature_line_tag(nomenclature_catalog_entry_item, reference_taxon_name, target = :browse_nomenclature_task_path) ⇒ Object
TODO: rename reference_taxon_name.
Instance Method Details
#history_author_year(taxon_name, citation) ⇒ String
Returns the name, or citation author year, prioritized by original/new with punctuation.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 77 def (taxon_name, citation) return content_tag(:span, 'Source is verbatim, requires parsing', class: 'feedback feedback-thin feedback-warning') if citation.try(:source).try(:type) == 'Source::Verbatim' str = (taxon_name) return nil if str.blank? if citation a = (taxon_name) b = (citation.source) end if citation.blank? || a != b content_tag(:span, ' ' + str, class: [:history_author_year]) else content_tag(:em, ' ') + link_to(content_tag(:span, str, title: citation.source.cached, class: 'history__pages'), send(:nomenclature_by_source_task_path, source_id: citation.source.id) ) end # str.blank? ? nil : # content_tag(:span, ' ' + str, class: [:history_author_year]) end |
#history_author_year_tag(taxon_name) ⇒ String?
Returns variably return the author year for taxon name in question !! NO span, is used in comparison !!.
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 98 def (taxon_name) return nil if taxon_name.nil? || taxon_name..nil? body = case taxon_name.type when 'Combination' (taxon_name) when 'Protonym' (taxon_name) else 'HYBRID NOT YET HANDLED' end end |
#history_in_taxon_name(t, c, i) ⇒ String?
Return the citation author/year if differeing from the taxon name author year
171 172 173 174 175 176 177 178 179 180 181 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 171 def history_in_taxon_name(t, c, i) if c a = (t) b = (c.source) if a != b || i.from_relationship? content_tag(:em, ' in ') + link_to(content_tag(:span, b, title: c.source.cached, class: :history__subject_original_citation), send(:nomenclature_by_source_task_path, source_id: c.source.id) ) # return content_tag(:span, content_tag(:em, ' in ') + b, class: [:history__in]) end end end |
#history_other_name(catalog_item, reference_taxon_name) ⇒ String?
Returns a parenthesized line item containing relationship and related name.
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 113 def history_other_name(catalog_item, reference_taxon_name) if catalog_item.from_relationship? other_str = nil if catalog_item.other_name == reference_taxon_name other_str = full_original_taxon_name_tag(catalog_item.other_name) else other_str = link_to(original_taxon_name_tag(catalog_item.other_name), browse_nomenclature_task_path(taxon_name_id: catalog_item.other_name.id) ) + ' ' + (catalog_item.other_name) end content_tag(:span, " (#{catalog_item.object.subject_status_tag} #{other_str})#{soft_validation_alert_tag(catalog_item.object)}".html_safe, class: [:history__other_name]) end end |
#history_statuses(nomenclature_catalog_entry_item) ⇒ String?
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.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 129 def history_statuses(nomenclature_catalog_entry_item) i = nomenclature_catalog_entry_item s = i.base_object.taxon_name_classifications_for_statuses return nil if (s.empty? || !i.is_first) # is_subsequent? return nil if i.from_relationship? content_tag(:span, class: [:history__statuses]) do (' (' + s.collect{|tnc| content_tag(:span, (tnc.classification_label + soft_validation_alert_tag(tnc).to_s + (tnc.citations.load.any? ? (content_tag(:em, ' in ') + citations_tag(tnc)).html_safe : '') ).html_safe, class: ['history__status']) }.join('; ') ).html_safe + ')' end.to_s end |
#history_subject_original_citation(catalog_item) ⇒ String?
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.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 149 def history_subject_original_citation(catalog_item) return nil if !catalog_item.from_relationship? || catalog_item.object.subject_taxon_name.origin_citation.blank? return nil if catalog_item.from_relationship? t = catalog_item.object.subject_taxon_name c = t.origin_citation a = (t) b = (c.source) body = [ (a != b ? (c.source) : nil) #, #history_pages(c) ].compact.join.html_safe unless body.blank? content_tag(:em, ': ') + link_to(content_tag(:span, body, title: c.source.cached, class: :history__subject_original_citation), send(:nomenclature_by_source_task_path, source_id: c.source.id) ) end # content_tag(:span, body, class: :history__subject_original_citation) unless body.blank? end |
#history_taxon_name(taxon_name, r, c, target = nil) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 53 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_id: taxon_name.id) ) 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 content_tag(:span, body + soft_validation.to_s, class: [css, original_citation_css(taxon_name, c), :history__taxon_name ]) end |
#history_type_material(entry_item) ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 183 def history_type_material(entry_item) return nil if entry_item.object_class != 'Protonym' || !entry_item.is_first # is_subsequent? type_taxon_name_relationship = entry_item.base_object&.type_taxon_name_relationship str = citations_tag(type_taxon_name_relationship) if type_taxon_name_relationship [ content_tag(:span, ' '.html_safe + type_taxon_name_relationship_tag(entry_item.base_object.type_taxon_name_relationship), class: 'history__type_information'), # citations_tag(entry_item.base_object&.type_taxon_name_relationship) # (entry_item.base_object&.type_taxon_name_relationship&.citations&.load&.any? ? (content_tag(:em, ' in ') + citations_tag(entry_item.base_object&.type_taxon_name_relationship)) : '') (type_taxon_name_relationship&.citations&.load&.any? ? (content_tag(:em, ' in ') + link_to(content_tag(:span, str, title: type_taxon_name_relationship&.citations&.first&.source&.cached, class: 'history__pages'), send(:nomenclature_by_source_task_path, source_id: type_taxon_name_relationship&.citations&.first&.source&.id) ) ) : '') # history_in(entry_item.base_object&.type_taxon_name_relationship&.source) ].compact.join.html_safe end |
#nomenclature_catalog_entry_item_tag(catalog_entry_item) ⇒ Object
may need reference_object
6 7 8 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 6 def nomenclature_catalog_entry_item_tag(catalog_entry_item) # may need reference_object nomenclature_line_tag(catalog_entry_item, catalog_entry_item.base_object) # second param might be wrong! end |
#nomenclature_catalog_li_tag(nomenclature_catalog_item, reference_taxon_name, target = :browse_nomenclature_task_path) ⇒ Object
TODO: rename reference_taxon_name
11 12 13 14 15 16 17 18 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 11 def nomenclature_catalog_li_tag(nomenclature_catalog_item, reference_taxon_name, target = :browse_nomenclature_task_path) content_tag( :li, (content_tag(:span, nomenclature_line_tag(nomenclature_catalog_item, reference_taxon_name, target)) + ' ' + radial_annotator(nomenclature_catalog_item.object)).html_safe, class: [:history__record, :middle, :inline], data: nomenclature_catalog_li_tag_data_attributes(nomenclature_catalog_item) ) end |
#nomenclature_catalog_li_tag_data_attributes(nomenclature_catalog_item) ⇒ Object
TODO: move to Catalog json data attributes helper
21 22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 21 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_first), # marks the single current valid name for this record 'history-is-subsequent' => !n.is_first # is_subsequent? } data end |
#nomenclature_line_tag(nomenclature_catalog_entry_item, reference_taxon_name, target = :browse_nomenclature_task_path) ⇒ Object
TODO: rename reference_taxon_name
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 33 def nomenclature_line_tag(nomenclature_catalog_entry_item, reference_taxon_name, target = :browse_nomenclature_task_path) i = nomenclature_catalog_entry_item t = i.base_object # was taxon_name c = i.citation r = reference_taxon_name [ history_taxon_name(t, r, c, target), # the subject, or protonym (t, c), ## author year of the subject, or protonym history_subject_original_citation(i), ## history_other_name(i, r), # The TaxonNameRelaltionship history_in_taxon_name(t, c, i), ## citation for related name history_pages(c), ## pages for citation of related name history_statuses(i), # TaxonNameClassification summary history_citation_notes(c), # Notes on the citation history_topics(c), # Topics on the citation history_type_material(i), ].compact.join.html_safe end |