Module: IdentifiersHelper

Defined in:
app/helpers/identifiers_helper.rb

Instance Method Summary (collapse)

Instance Method Details



18
19
20
21
22
23
# File 'app/helpers/identifiers_helper.rb', line 18

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


25
26
27
28
# File 'app/helpers/identifiers_helper.rb', line 25

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

- (Object) identifier_list_tag(object)



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

def identifier_list_tag(object)
  if object.identifiers.any?
    (:h3, 'Identifiers') +
    (:ul, class: 'identifier_list') do
      object.identifiers.collect{|a| (:li, identifier_tag(a)) }.join.html_safe 
    end
  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



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

def identifier_recent_objects_partial
  true 
end

- (Object) identifier_tag(identifier)



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

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

SHORT_NAMES =

doi:   Identifier::Global::Doi,
isbn:  Identifier::Global::Isbn,
issn:  Identifier::Global::Issn,
lccn:  Identifier::Global::Lccn,
orcid: Identifier::Global::Orcid,
uri:   Identifier::Global::Uri,
uuid:  Identifier::Global::Uuid,
catalog_number: Identifier::Local::CatalogNumber,
trip_code: Identifier::Local::TripCode,
import: Identifier::Local::Import,
otu_utility: Identifier::Local::OtuUtility,
accession_code: Identifier::Local::AccessionCode,
unknown: Identifier::Unknown



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

def identifier_type_select_options
  Identifier::SHORT_NAMES.collect { |k, v| [k.to_s.humanize, v.name] }
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



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

def identifiers_partial
  true 
end

- (Object) identifiers_search_form



30
31
32
# File 'app/helpers/identifiers_helper.rb', line 30

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

- (Object) identifiers_tag(object)



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

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