Module: IdentifiersHelper

Defined in:
app/helpers/identifiers_helper.rb

Instance Method Summary collapse

Instance Method Details



77
78
79
80
81
82
# File 'app/helpers/identifiers_helper.rb', line 77

def add_identifier_link(object: nil)
  link_to('Add identifier', new_identifier_path(
    identifier: {
      identifier_object_type: object.class.base_class.name,
      identifier_object_id: object.id})) if object.has_identifiers?
end

#identifier_annotation_tag(identifier) ⇒ String?

Returns:

  • (String, nil)


17
18
19
20
# File 'app/helpers/identifiers_helper.rb', line 17

def identifier_annotation_tag(identifier)
  return nil if identifier.nil?
  (:span, identifier.cached, class: [:annotation__identifier])
end

#identifier_autocomplete_tag(identifier) ⇒ String?

Returns:

  • (String, nil)


23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/identifiers_helper.rb', line 23

def identifier_autocomplete_tag(identifier)
  return nil if identifier.nil?
  (:span, class: :annotation__identifier) do
    [
      object_tag(identifier.annotated_object.metamorphosize),
      (:span, identifier.identifier_object_type, class: [:feedback, 'feedback-thin', 'feedback-primary']),
      (:span, identifier.type, class: [:feedback, 'feedback-thin', 'feedback-secondary']),
    ].join(' ').html_safe
  end
end

#identifier_label(identifier) ⇒ Object



46
47
48
49
# File 'app/helpers/identifiers_helper.rb', line 46

def identifier_label(identifier)
  return nil if identifier.nil?
  identifier.cached
end

Returns link to GET idnetifiers/:id

Returns:

  • (String, nil)

    link to GET idnetifiers/:id



11
12
13
14
# File 'app/helpers/identifiers_helper.rb', line 11

def identifier_link(identifier)
  return nil if identifier.nil?
  link_to(identifier_tag(identifier).html_safe, identifier.identifier_object.metamorphosize)
end

#identifier_list_tag(object) ⇒ String

Returns assumes the display context is on the object in question

Returns:

  • (String)

    assumes the display context is on the object in question



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

def identifier_list_tag(object)
  return nil unless object.has_identifiers? && object.identifiers.any?
  (:h3, 'Identifiers') +
    (:ul, class: 'annotations_identifier_list') do
    object.identifiers.collect{|a| (:li, identifier_annotation_tag(a)) }.join.html_safe 
  end
end

#identifier_recent_objects_partialTrue

Returns indicates a custom partial should be used, see list_helper.rb

Returns:

  • (True)

    indicates a custom partial should be used, see list_helper.rb



96
97
98
# File 'app/helpers/identifiers_helper.rb', line 96

def identifier_recent_objects_partial
  true 
end

#identifier_short_tag(identifier) ⇒ String?

Returns:

  • (String, nil)


41
42
43
44
# File 'app/helpers/identifiers_helper.rb', line 41

def identifier_short_tag(identifier)
  return nil if identifier.nil?
  (:span, identifier.cached, class: [:feedback, 'feedback-thin', 'feedback-primary'])
end

#identifier_tag(identifier) ⇒ String?

Returns:

  • (String, nil)


4
5
6
7
# File 'app/helpers/identifiers_helper.rb', line 4

def identifier_tag(identifier)
  return nil if identifier.nil? || identifier.new_record?
  "#{identifier.cached} (#{identifier.type.demodulize.titleize.humanize})".html_safe
end

#identifier_type_select_optionsObject



100
101
102
103
104
105
106
# File 'app/helpers/identifiers_helper.rb', line 100

def identifier_type_select_options
  a = []
  %I{global local unknown}.each do |t|
    a += IDENTIFIERS_JSON[t][:all].collect{|b,c| [c[:label], b]}
  end
  a
end

#identifier_type_tag(identifier) ⇒ String?

Returns:

  • (String, nil)


35
36
37
38
# File 'app/helpers/identifiers_helper.rb', line 35

def identifier_type_tag(identifier)
  return nil if identifier.nil?
  identifier.class.name.demodulize.underscore.humanize.downcase
end

#identifiers_partialTrue

Returns indicates a custom partial should be used, see list_helper.rb

Returns:

  • (True)

    indicates a custom partial should be used, see list_helper.rb



90
91
92
# File 'app/helpers/identifiers_helper.rb', line 90

def identifiers_partial
  true 
end

#identifiers_search_formObject



84
85
86
# File 'app/helpers/identifiers_helper.rb', line 84

def identifiers_search_form
  render('/identifiers/quick_search_form')
end

#identifiers_tag(object) ⇒ String?

Returns identifiers for object with HTML

Returns:

  • (String, nil)

    identifiers for object with HTML



70
71
72
73
74
75
# File 'app/helpers/identifiers_helper.rb', line 70

def identifiers_tag(object)
  if object.identifiers.any?
    return object.identifiers.collect{|a| (:span, identifier_tag(a))}.join('; ').html_safe
  end
  nil
end

#simple_identifier_list_tag(object) ⇒ String?

Returns a list of identifiers without HTML

Returns:

  • (String, nil)

    a list of identifiers without HTML



63
64
65
66
# File 'app/helpers/identifiers_helper.rb', line 63

def simple_identifier_list_tag(object)
  return nil if !object.identifiers.any?
  object.identifiers.collect{|a| (:span, identifier_annotation_tag(a)) }.join.html_safe
end