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

pulibrary / orangelight / 0e37073d-109c-440c-949f-49d2aa86311b

18 Aug 2025 09:05PM UTC coverage: 0.482% (-94.9%) from 95.343%
0e37073d-109c-440c-949f-49d2aa86311b

push

circleci

web-flow
Replace per_page_options_for_select with custom component to avoid deprecation issue (#5186)

* Start creating new component to address deprecaton warning

* Replace per_page_options_for_select with custom component to avoid deprecation issue

Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>

---------

Co-authored-by: Ryan Jensen <rj1044@princeton.edu>
Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>

0 of 33 new or added lines in 1 file covered. (0.0%)

9374 existing lines in 213 files now uncovered.

47 of 9753 relevant lines covered (0.48%)

0.01 hits per line

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

0.0
/app/components/orangelight/guided_search_fields_component.rb
1
# frozen_string_literal: true
2

3
# Fill in default from existing search, if present
4
# -- if you are using same search fields for basic
5
# search and advanced, will even fill in properly if existing
6
# search used basic search on same field present in advanced.
UNCOV
7
class Orangelight::GuidedSearchFieldsComponent < Blacklight::Component
×
UNCOV
8
  def label_tag_default_for(key)
×
UNCOV
9
    params_key = params[key]
×
UNCOV
10
    if params_key.present?
×
11
      params_key
×
UNCOV
12
    elsif params['search_field'] == key || guided_context(key)
×
UNCOV
13
      params['q']
×
UNCOV
14
    else
×
UNCOV
15
      param_for_field key
×
UNCOV
16
    end
×
UNCOV
17
  end
×
18

19
  # :reek:FeatureEnvy
UNCOV
20
  def advanced_key_value
×
UNCOV
21
    advanced_search_fields.map do |field|
×
UNCOV
22
      [field[1][:label], field[0]]
×
UNCOV
23
    end
×
UNCOV
24
  end
×
25

26
  # carries over original search field and original guided search fields if user switches to guided search from regular search
UNCOV
27
  def guided_field(field_num, default_val)
×
UNCOV
28
    search_field = params[:search_field]
×
UNCOV
29
    search_field_for_advanced_search = advanced_search_fields[search_field]
×
UNCOV
30
    return search_field_for_advanced_search.key || default_val if first_search_field_selector?(field_num) && no_advanced_search_fields_specified? && search_field && search_field_for_advanced_search
×
UNCOV
31
    params[field_num] || param_for_field(field_num) || default_val
×
UNCOV
32
  end
×
33

34
  # carries over original search query if user switches to guided search from regular search
UNCOV
35
  def guided_context(key)
×
UNCOV
36
    search_field = params[:search_field]
×
UNCOV
37
    first_search_field?(key) &&
×
UNCOV
38
      search_field && advanced_search_fields[search_field]
×
UNCOV
39
  end
×
40

41
  # carries over guided search operations if user switches back to guided search from regular search
42
  # rubocop:disable Naming/PredicateMethod
UNCOV
43
  def guided_radio(op_num, operator)
×
UNCOV
44
    op_num_from_params = params[op_num]
×
UNCOV
45
    if op_num_from_params
×
UNCOV
46
      op_num_from_params == operator
×
UNCOV
47
    else
×
UNCOV
48
      operator == 'AND'
×
UNCOV
49
    end
×
UNCOV
50
  end
×
51
  # rubocop:enable Naming/PredicateMethod
52

53
  # private
54

55
  # :reek:NilCheck
UNCOV
56
  def advanced_search_fields
×
UNCOV
57
    blacklight_config.search_fields.select do |_key, value|
×
UNCOV
58
      include_in_advanced_search = value.include_in_advanced_search
×
UNCOV
59
      include_in_advanced_search || include_in_advanced_search.nil?
×
UNCOV
60
    end
×
UNCOV
61
  end
×
62

63
  # :reek:UtilityFunction
UNCOV
64
  def first_search_field_selector?(key)
×
UNCOV
65
    %i[clause_0_field].include? key
×
UNCOV
66
  end
×
67

UNCOV
68
  def no_advanced_search_fields_specified?
×
UNCOV
69
    %i[clause_0_field clause_1_field clause_2_field].none? do |key|
×
UNCOV
70
      params[key].present?
×
UNCOV
71
    end
×
UNCOV
72
  end
×
73

74
  # :reek:FeatureEnvy
UNCOV
75
  def param_for_field(field_identifier)
×
UNCOV
76
    field_identifier_string = field_identifier.to_s
×
UNCOV
77
    return unless field_identifier_string.start_with? 'clause'
×
UNCOV
78
    components = field_identifier_string.split('_')
×
UNCOV
79
    params.dig(*components)
×
UNCOV
80
  end
×
81

82
  # :reek:UtilityFunction
UNCOV
83
  def first_search_field?(key)
×
UNCOV
84
    %i[q1 clause_0_query].include? key
×
UNCOV
85
  end
×
86

UNCOV
87
  delegate :blacklight_config, to: :helpers
×
UNCOV
88
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