Module: TaxonNameRelationshipsHelper

Defined in:
app/helpers/taxon_name_relationships_helper.rb

Instance Method Summary collapse

Instance Method Details

#label_for_taxon_name_relationship(taxon_name_relationship) ⇒ Object



15
16
17
18
19
20
21
22
# File 'app/helpers/taxon_name_relationships_helper.rb', line 15

def label_for_taxon_name_relationship(taxon_name_relationship)
  return nil if taxon_name_relationship.nil?
  [
    label_for_taxon_name(taxon_name_relationship.subject_taxon_name),
    defined?(taxon_name_relationship.class.inverse_assignment_method) ?  taxon_name_relationship.class.inverse_assignment_method.to_s.humanize : taxon_name_relationship.type,
    label_for_taxon_name(taxon_name_relationship.object_taxon_name)
  ].compact.join(' ')
end

#taxon_name_relationship_for_object_tag(taxon_name_relationship) ⇒ String

Returns relationship_type + object.

Returns:

  • (String)

    relationship_type + object



37
38
39
40
41
42
43
# File 'app/helpers/taxon_name_relationships_helper.rb', line 37

def taxon_name_relationship_for_object_tag(taxon_name_relationship)
  [
    (:span, taxon_name_relationship.object_status_tag, class: :string_emphasis),
    original_taxon_name_link(taxon_name_relationship.subject_taxon_name),
    taxon_name_relationship.subject_taxon_name.cached_author_year
  ].join(' ').html_safe
end

#taxon_name_relationship_for_subject_tag(taxon_name_relationship) ⇒ String

Returns subject + relationship type.

Returns:

  • (String)

    subject + relationship type



26
27
28
29
30
31
32
33
# File 'app/helpers/taxon_name_relationships_helper.rb', line 26

def taxon_name_relationship_for_subject_tag(taxon_name_relationship)
  return nil if taxon_name_relationship.nil?
  [
    (:span, taxon_name_relationship.subject_status_tag , class: :string_emphasis),
    original_taxon_name_link(taxon_name_relationship.object_taxon_name),
    taxon_name_relationship.object_taxon_name.cached_author_year
  ].join(' ').html_safe
end

#taxon_name_relationship_tag(taxon_name_relationship) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/taxon_name_relationships_helper.rb', line 3

def taxon_name_relationship_tag(taxon_name_relationship)
return nil if taxon_name_relationship.nil?
[
  original_taxon_name_link(taxon_name_relationship.subject_taxon_name),
  (:span, ( defined?(taxon_name_relationship.class.inverse_assignment_method) ?
  taxon_name_relationship.class.inverse_assignment_method.to_s.humanize :
  taxon_name_relationship.type ) + taxon_name_relationship.subject_status_connector_to_object.to_s,
  class: :subtle),
    taxon_name_browse_link(taxon_name_relationship.object_taxon_name)
  ].compact.join(' ')
end

#type_taxon_name_relationship_label(taxon_name_relationship, target: :browse_nomenclature_task_path) ⇒ Object



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

def type_taxon_name_relationship_label(taxon_name_relationship, target: :browse_nomenclature_task_path)
  return nil if taxon_name_relationship.nil?
  [ taxon_name_relationship.subject_status,
    original_taxon_name_tag( taxon_name_relationship.subject_taxon_name),
    original_author_year(taxon_name_relationship.subject_taxon_name)
  ].join(' ').html_safe
end

#type_taxon_name_relationship_tag(taxon_name_relationship, target: :browse_nomenclature_task_path) ⇒ Object



45
46
47
48
49
50
51
52
# File 'app/helpers/taxon_name_relationships_helper.rb', line 45

def type_taxon_name_relationship_tag(taxon_name_relationship, target: :browse_nomenclature_task_path)
  return nil if taxon_name_relationship.nil?
  # TODO: add original citation to relationship rendering (conflicts with paper catalog/browse nomenclature use if you do this!)
  (:span, [ taxon_name_relationship.subject_status,
    link_to( original_taxon_name_tag( taxon_name_relationship.subject_taxon_name), send(target, taxon_name_id: taxon_name_relationship.subject_taxon_name.id)),
    original_author_year(taxon_name_relationship.subject_taxon_name)].join(' ').html_safe, class: 'type_information'
  )
end