Module: IdentifiersHelper

Defined in:
app/helpers/identifiers_helper.rb

Instance Method Summary (collapse)

Instance Method Details



58
59
60
61
62
63
# File 'app/helpers/identifiers_helper.rb', line 58

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

- (String?) identifier_annotation_tag(identifier)

Returns:

  • (String, nil)


21
22
23
24
# File 'app/helpers/identifiers_helper.rb', line 21

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

Returns link to GET idnetifiers/:id

Returns:

  • (String, nil)

    link to GET idnetifiers/:id



15
16
17
18
# File 'app/helpers/identifiers_helper.rb', line 15

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

- (String) identifier_list_tag(object)

Returns assumes the display context is on the object in question

Returns:

  • (String)

    assumes the display context is on the object in question



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

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

- (True) identifier_recent_objects_partial

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



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

def identifier_recent_objects_partial
  true 
end

- (String?) identifier_tag(identifier)

Returns:

  • (String, nil)


4
5
6
7
8
9
10
11
# File 'app/helpers/identifiers_helper.rb', line 4

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

- (Object) identifier_type_select_options



81
82
83
84
85
86
87
# File 'app/helpers/identifiers_helper.rb', line 81

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

- (String?) identifier_type_tag(identifier)

Returns:

  • (String, nil)


27
28
29
30
# File 'app/helpers/identifiers_helper.rb', line 27

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

- (True) identifiers_partial

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



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

def identifiers_partial
  true 
end

- (Object) identifiers_search_form



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

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

- (String?) identifiers_tag(object)

Returns identifiers for object with HTML

Returns:

  • (String, nil)

    identifiers for object with HTML



51
52
53
54
55
56
# File 'app/helpers/identifiers_helper.rb', line 51

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

- (String?) simple_identifier_list_tag(object)

Returns a list of identifiers without HTML

Returns:

  • (String, nil)

    a list of identifiers without HTML



44
45
46
47
# File 'app/helpers/identifiers_helper.rb', line 44

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