• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / orangelight / 62bad3f1-d46d-40af-822c-403d653da2a8

17 Jun 2025 05:30PM UTC coverage: 0.447% (-94.9%) from 95.337%
62bad3f1-d46d-40af-822c-403d653da2a8

push

circleci

maxkadel
Install chrome & chromedriver for smoke specs

43 of 9610 relevant lines covered (0.45%)

0.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/helpers/holdings_helper.rb
1
# frozen_string_literal: false
2

3
# rubocop:disable Metrics/ModuleLength
4
module HoldingsHelper
×
5
  # Generate the markup block for individual search result items containing holding information
6
  # @param document [SolrDocument] the Solr Document retrieved in the search result set
7
  # @return [String] the markup
8

9
  def holding_block_search(document)
×
10
    block = ''.html_safe
×
11
    holdings_hash = document.holdings_all_display
×
12
    @scsb_multiple = false
×
13

14
    holdings_hash.first(2).each do |id, holding|
×
15
      block << first_two_holdings_block(document, id, holding)
×
16
    end
×
17

18
    block << controller.view_context.render(Holdings::OnlineHoldingsComponent.new(document:))
×
19

20
    if @scsb_multiple == true || holdings_hash.length > 2
×
21
      block << view_record_for_full_avail_li(document)
×
22
    elsif !holdings_hash.empty?
×
23
      block << view_record_for_full_avail_li_two(document)
×
24
    end
×
25

26
    if block.empty?
×
27
      content_tag(:div, t('blacklight.holdings.search_missing'))
×
28
    else
×
29
      content_tag(:ul, block)
×
30
    end
×
31
  end
×
32

33
  # rubocop:disable Metrics/MethodLength
34
  # Currently having trouble breaking up this method further due to the "check_availability" variable
35
  def first_two_holdings_block(document, id, holding)
×
36
    location = holding_location(holding)
×
37
    check_availability = render_availability?
×
38
    accumulator = ''.html_safe
×
39
    if holding['library'] == 'Online'
×
40
      rendered_online_holdings_block = controller.view_context.render(Holdings::OnlineHoldingsComponent.new(document:))
×
41
      return rendered_online_holdings_block if rendered_online_holdings_block.present?
×
42

43
      check_availability = render_availability?
×
44
      accumulator << empty_link_online_holding_block
×
45

46
    else
×
47
      if holding['dspace'] || holding['location_code'] == 'rare$num'
×
48
        check_availability = false
×
49
        accumulator << dspace_or_numismatics_holding_block(location)
×
50
      elsif /^scsb.+/.match? location[:code]
×
51
        check_availability = false
×
52
        unless holding['items'].nil?
×
53
          @scsb_multiple = true unless holding['items'].count == 1
×
54
          accumulator << scsb_item_block(holding)
×
55
        end
×
56
      elsif holding['dspace'].nil?
×
57
        accumulator << dspace_not_defined_block(location)
×
58
      else
×
59
        check_availability = false
×
60
        accumulator << under_embargo_block
×
61
      end
×
62
      accumulator << library_location_div(holding, document, id)
×
63
    end
×
64
    holding_status_li(accumulator, document, check_availability, id, holding)
×
65
  end
×
66
  # rubocop:enable Metrics/MethodLength
67

68
  def empty_link_online_holding_block
×
69
    data = content_tag(
×
70
      :span,
×
71
      'Link Missing',
×
72
      class: 'availability-icon badge bg-secondary'
×
73
    )
×
74
    data << content_tag(
×
75
      :div,
×
76
      'Online access is not currently available.',
×
77
      class: 'library-location'
×
78
    )
×
79
  end
×
80

81
  def onsite_access_span
×
82
    content_tag(
×
83
      :span,
×
84
      'On-site access',
×
85
      class: 'availability-icon badge bg-success'
×
86
    )
×
87
  end
×
88

89
  def dspace_or_numismatics_holding_block(_location)
×
90
    onsite_access_span
×
91
  end
×
92

93
  def scsb_item_block(holding)
×
94
    scsb_supervised_items?(holding) ? scsb_supervised_item : scsb_unsupervised_item(holding)
×
95
  end
×
96

97
  def scsb_supervised_item
×
98
    onsite_access_span
×
99
  end
×
100

101
  def scsb_unsupervised_item(holding)
×
102
    content_tag(
×
103
      :span,
×
104
      '',
×
105
      class: 'availability-icon badge',
×
106
      data: {
×
107
        'scsb-availability': 'true',
×
108
        'scsb-barcode': holding['items'].first['barcode'].to_s
×
109
      }
×
110
    )
×
111
  end
×
112

113
  def dspace_not_defined_block(_location)
×
114
    content_tag(
×
115
      :span,
×
116
      'Loading...',
×
117
      class: 'availability-icon badge bg-secondary'
×
118
    )
×
119
  end
×
120

121
  def under_embargo_block
×
122
    content_tag(
×
123
      :span,
×
124
      'Unavailable',
×
125
      class: 'availability-icon badge bg-danger'
×
126
    )
×
127
  end
×
128

129
  def library_location_div(holding, document, id)
×
130
    content_tag(
×
131
      :div,
×
132
      search_location_display(holding),
×
133
      class: 'library-location',
×
134
      data: {
×
135
        location: true,
×
136
        record_id: document['id'],
×
137
        holding_id: id
×
138
      }
×
139
    )
×
140
  end
×
141

142
  def holding_status_li(accumulator, document, check_availability, id, holding)
×
143
    location = holding_location(holding)
×
144
    content_tag(
×
145
      :li,
×
146
      accumulator,
×
147
      class: 'holding-status',
×
148
      data: {
×
149
        availability_record: check_availability,
×
150
        record_id: document['id'],
×
151
        holding_id: id,
×
152
        temp_location_code: holding['temp_location_code'],
×
153
        aeon: aeon_location?(location),
×
154
        bound_with: document.bound_with?
×
155
      }.compact
×
156
    )
×
157
  end
×
158

159
  def view_record_for_full_avail_li(document)
×
160
    content_tag(
×
161
      :li,
×
162
      link_to(
×
163
        'View Record for Full Availability',
×
164
        solr_document_path(document['id']),
×
165
        class: 'availability-icon badge bg-secondary more-info'
×
166
      )
×
167
    )
×
168
  end
×
169

170
  def view_record_for_full_avail_li_two(document)
×
171
    content_tag(
×
172
      :li,
×
173
      link_to(
×
174
        '',
×
175
        solr_document_path(document['id']),
×
176
        class: 'availability-icon more-info'
×
177
      ),
×
178
      class: 'empty',
×
179
      data: { record_id: document['id'] }
×
180
    )
×
181
  end
×
182
end
×
183
# rubocop:enable Metrics/ModuleLength
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc