Module: RecordHelper

Included in:
Record, SolrResults
Defined in:
public/app/helpers/record_helper.rb

Instance Method Summary collapse

Instance Method Details

#badge_for_type(primary_type) ⇒ Object



87
88
89
90
91
# File 'public/app/helpers/record_helper.rb', line 87

def badge_for_type(primary_type)
  "<span class='record-type-badge #{primary_type}' aria-hidden='true'> \
    <i class='#{icon_for_type(primary_type)}'></i> \
  </span>".html_safe
end

#icon_for_type(primary_type) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'public/app/helpers/record_helper.rb', line 50

def icon_for_type(primary_type)
  'fa ' + case primary_type
          when 'repository'
            'fa-home'
          when 'resource'
            'fa-archive'
          when 'archival_object'
            'fa-file-o'
          when 'digital_object'
            'fa-file-image-o'
          when 'digital_object_component'
            'fa-file-image-o'
          when 'accession'
            'fa-file-text-o'
          when 'subject'
            'fa-tag'
          when 'agent'
            'fa-pencil'
          when 'agent_person'
            'fa-user'
          when 'agent_corporate_entity'
            'fa-university'
          when 'agent_family'
            'fa-users'
          when 'classification'
            'fa-share-alt'
          when 'classification_term'
            'fa-tag'
          when 'top_container'
            'fa-archive'
          when 'record'
            'fa-folder'
          else
            'fa-cog'
          end
end

#record_class_for_type(type) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'public/app/helpers/record_helper.rb', line 9

def record_class_for_type(type)
  case type
  when 'resource'
    Resource
  when 'resource_ordered_records'
    ResourceOrderedRecords
  when 'archival_object'
    ArchivalObject
  when 'accession'
    Accession
  when 'digital_object'
    DigitalObject
  when 'digital_object_component'
    DigitalObjectComponent
  when 'classification'
    Classification
  when 'classification_term'
    ClassificationTerm
  when 'subject'
    Subject
  when 'top_container'
    Container
  when 'agent_person'
    AgentPerson
  when 'agent_family'
    AgentFamily
  when 'agent_corporate_entity'
    AgentCorporateEntity
  else
    Record
  end
end

#record_for_type(result, full = false) ⇒ Object



3
4
5
6
# File 'public/app/helpers/record_helper.rb', line 3

def record_for_type(result, full = false)
  klass = record_class_for_type(result.fetch('primary_type'))
  klass.new(result, full)
end

#record_from_resolved_json(json, full = false) ⇒ Object



42
43
44
45
46
47
48
# File 'public/app/helpers/record_helper.rb', line 42

def record_from_resolved_json(json, full = false)
  record_for_type({
                    'json' => json,
                    'primary_type' => json.fetch('jsonmodel_type'),
                    'uri' => json.fetch('uri')
                  }, full)
end