Module: TaxonNames::CatalogHelper
- Defined in:
- app/helpers/taxon_names/catalog_helper.rb
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.
- #taxon_name_synonym_li(syn) ⇒ Object
- #taxon_name_synonyms_list(taxon_name) ⇒ Object
Instance Method Details
#history_author_year(taxon_name, citation) ⇒ String
Returns the name, or citation author year, prioritized by original/new with punctuation.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 78 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 !!.
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 99 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
174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 174 def history_in_taxon_name(t, c, i) if c a = (t) b = (c.source) tn = t.type == 'Combination' ? t.protonyms.last : t in_str = ' in ' if a != b || i.from_relationship? content_tag(:em, in_str) + 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.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 114 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) elsif catalog_item.object.subject_status_tag == 'classified as' other_str = link_to(taxon_name_tag(catalog_item.other_name), browse_nomenclature_task_path(taxon_name_id: catalog_item.other_name.id) ) + ' ' + (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.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 132 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.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 152 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
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 54 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
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 189 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 if type_taxon_name_relationship str = citations_tag(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 else nil end end |
#nomenclature_catalog_entry_item_tag(catalog_entry_item) ⇒ Object
may need reference_object
7 8 9 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 7 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
12 13 14 15 16 17 18 19 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 12 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
22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 22 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
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 34 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 |
#taxon_name_synonym_li(syn) ⇒ Object
210 211 212 213 214 215 216 217 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 210 def taxon_name_synonym_li(syn) label = [ content_tag(:span, "= "), link_to(full_original_taxon_name_tag(syn) || taxon_name_tag(syn), browse_nomenclature_task_path(taxon_name_id: syn.id)) ].compact.join.html_safe content_tag(:li, label) end |
#taxon_name_synonyms_list(taxon_name) ⇒ Object
219 220 221 |
# File 'app/helpers/taxon_names/catalog_helper.rb', line 219 def taxon_name_synonyms_list(taxon_name) synonyms = taxon_name&.synonyms.where(type: 'Protonym').where.not(id: taxon_name.id)&.order(:cached, :cached_author_year).uniq end |