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

pulibrary / orangelight / 4c391e0e-519a-40cb-8ad3-354445f4ce03

12 Aug 2025 08:47PM UTC coverage: 85.348% (-10.0%) from 95.335%
4c391e0e-519a-40cb-8ad3-354445f4ce03

push

circleci

web-flow
[#5143] Use access restriction note as Aeon ItemInfo1 if available (#5173)

With this commit, if a user visits a record with an access
restrictions note and presses the Reading Room Request
button, they will get to an Aeon form with the 'Restrictions'
field pre-filled with the restriction note.

If the record does not have an access restrictions note,
the field will be pre-filled with 'Reading Room Access Only',
as it has been previously.

Closes #5143

5493 of 6436 relevant lines covered (85.35%)

251.82 hits per line

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

97.73
/app/components/orangelight/process_vocabulary_component.rb
1
# frozen_string_literal: true
2

3
class Orangelight::ProcessVocabularyComponent < Blacklight::MetadataFieldComponent
1✔
4
  def subjectify
1✔
5
    subjects = @field.values
22✔
6
    all_subjects = subjects.map { |subject| subject.split(QUERYSEP) }
65✔
7
    sub_array = subjects.map { |subject| accumulate_subsubjects(subject.split(QUERYSEP)) }
65✔
8
    subject_list = build_subject_list(all_subjects, sub_array)
22✔
9
    build_subject_ul(subject_list)
22✔
10
  end
11

12
private
1✔
13

14
  SEPARATOR = '—'
1✔
15
  QUERYSEP = '—'
1✔
16
  FACET_KEYS = {
1✔
17
    'lc_subject_display' => 'lc_subject_facet',
18
    'aat_s' => 'aat_genre_facet',
19
    'homoit_subject_display' => 'homoit_subject_facet',
20
    'homoit_genre_s' => 'homoit_genre_facet',
21
    'lcgft_s' => 'lcgft_genre_facet',
22
    'local_subject_display' => 'local_subject_facet',
23
    'fast_subject_display' => 'subject_facet',
24
    'rbgenr_s' => 'rbgenr_genre_facet',
25
    'siku_subject_display' => 'siku_subject_facet'
26
  }.freeze
27
  private_constant :SEPARATOR, :QUERYSEP, :FACET_KEYS
1✔
28

29
  def build_subject_ul(subject_list)
1✔
30
    content_tag :ul do
22✔
31
      subject_list.each { |subject| concat(content_tag(:li, subject, dir: subject.dir)) }
65✔
32
    end
33
  end
34

35
  def build_subject_list(all_subjects, sub_array)
1✔
36
    document_field = @field.values
22✔
37
    document_field.each_with_index do |_subject, index|
22✔
38
      sub_array_index = sub_array[index]
43✔
39

40
      lnk = build_search_subject_links(all_subjects[index], sub_array_index)
43✔
41
      lnk += build_browse_subject_link(index, sub_array_index.last).to_s
43✔
42
      # rubocop:disable Rails/OutputSafety
43
      document_field[index] = lnk.html_safe
43✔
44
      # rubocop:enable Rails/OutputSafety
45
    end
46
  end
47

48
  def build_search_subject_links(subjects, sub_array)
1✔
49
    subjects.each_with_index.reduce('') do |accumulator, (subsubject, j)|
43✔
50
      sub_array_j = sub_array[j]
96✔
51
      facet_key = FACET_KEYS[@field.key]
96✔
52
      if j == subjects.length - 1
96✔
53
        accumulator + build_search_subject_link(subsubject, sub_array_j, facet_key)
43✔
54
      else
55
        accumulator + build_search_subject_link(subsubject, sub_array_j, facet_key) + content_tag(:span, SEPARATOR, class: 'subject-level')
53✔
56
      end
57
    end
58
  end
59

60
  def build_search_subject_link(subsubject, sub_array_j, facet_key)
1✔
61
    link_to(subsubject,
96✔
62
            "/?f[#{facet_key}][]=#{CGI.escape StringFunctions.trim_punctuation(sub_array_j)}",
63
            class: 'search-subject',
64
            'data-original-title' => "Search: #{sub_array_j}")
65
  end
66

67
  def build_browse_subject_link(index, full_sub)
1✔
68
    return ' ' if fast_subjects_value?(index)
43✔
69
    facet_key = FACET_KEYS[@field.key]
43✔
70
    " #{build_browse_link(full_sub, facet_key)}"
43✔
71
  end
72

73
  def build_browse_link(full_sub, facet_key)
1✔
74
    link_to("[Browse]",
43✔
75
            "/browse/subjects?q=#{CGI.escape full_sub}&vocab=#{facet_key}",
76
            class: 'browse-subject',
77
            'data-original-title' => "Browse: #{full_sub}",
78
            'aria-label' => "Browse: #{full_sub}",
79
            dir: full_sub.dir.to_s)
80
  end
81

82
  def accumulate_subsubjects(spl_sub)
1✔
83
    spl_sub.reduce([]) do |accumulator, subsubject|
43✔
84
      # accumulator.last ? "#{accumulator.last}#{QUERYSEP}#{subsubject}" : subsubject
85
      accumulator.append([accumulator.last, subsubject].compact.join(QUERYSEP))
96✔
86
    end
87
  end
88

89
  def fast_subjects_value?(index)
1✔
90
    fast_subject_display_field = @field.document["fast_subject_display"]
43✔
91
    return false if fast_subject_display_field.nil?
43✔
92
    fast_subject_display_field.present? && fast_subject_display_field.include?(@field.values[index])
×
93
  end
94
end
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