• 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/models/requests/form_decorator.rb
1
# frozen_string_literal: true
UNCOV
2
module Requests
×
3
  # This class is responsible for generating the visual aspects of the Request object for the form
UNCOV
4
  class FormDecorator
×
UNCOV
5
    delegate :patron,
×
UNCOV
6
             :ctx, :system_id, :mfhd, :holdings, :default_pick_ups,
×
UNCOV
7
             :serial?, :any_loanable_copies?, :requestable?, :thesis?, :numismatics?, :eligible_for_library_services?,
×
UNCOV
8
             :user_name, :email, # passed to request as login options on the request form
×
UNCOV
9
             to: :request
×
UNCOV
10
    delegate :content_tag, :hidden_field_tag, :concat, to: :view_context
×
11

UNCOV
12
    alias bib_id system_id
×
13

UNCOV
14
    attr_reader :request, :view_context, :first_filtered_requestable, :non_requestable_message, :back_to_record_url
×
UNCOV
15
    def initialize(request, view_context, back_to_record_url)
×
UNCOV
16
      @request = request
×
UNCOV
17
      @view_context = view_context
×
UNCOV
18
      @requestable_list = request.requestable.map { |req| RequestableDecorator.new(req, view_context) }
×
UNCOV
19
      @first_filtered_requestable = RequestableDecorator.new(request.first_filtered_requestable, view_context)
×
UNCOV
20
      @non_requestable_message = "See Circulation Desk, there are no requestable items for this record"
×
UNCOV
21
      @back_to_record_url = back_to_record_url
×
UNCOV
22
    end
×
23

UNCOV
24
    def requestable
×
UNCOV
25
      @requestable_list
×
UNCOV
26
    end
×
27

28
    # rubocop:disable Rails/OutputSafety
UNCOV
29
    def patron_message
×
UNCOV
30
      return '' if patron.guest?
×
UNCOV
31
      return '' if eligible_for_library_services?
×
UNCOV
32
      "<div class='alert alert-warning'>#{I18n.t('requests.account.cas_user_no_barcode_msg')}</div>".html_safe
×
UNCOV
33
    end
×
34

UNCOV
35
    def hidden_fields
×
UNCOV
36
      hidden_request_tags = ''
×
UNCOV
37
      hidden_request_tags += hidden_field_tag "bib[id]", "", value: bib_id
×
UNCOV
38
      request.hidden_field_metadata.each do |key, value|
×
UNCOV
39
        hidden_request_tags += hidden_field_tag "bib[#{key}]", "", value:
×
UNCOV
40
      end
×
UNCOV
41
      hidden_request_tags.html_safe
×
UNCOV
42
    end
×
43
    # rubocop:enable Rails/OutputSafety
44

UNCOV
45
    def any_will_submit_via_form?
×
UNCOV
46
      return false if requestable.compact_blank.blank? || !eligible_for_library_services?
×
UNCOV
47
      requestable.map(&:will_submit_via_form?).any? || any_fill_in_eligible?
×
UNCOV
48
    end
×
49

UNCOV
50
    def any_fill_in_eligible?
×
UNCOV
51
      return false unless eligible_for_library_services?
×
UNCOV
52
      return false if patron.alma_provider?
×
53

UNCOV
54
      fill_in = false
×
UNCOV
55
      unless requestable.one? && (requestable.first.services & ["on_order", "online"]).present?
×
UNCOV
56
        if requestable.any? do |requestable_decorator|
×
UNCOV
57
          !(requestable_decorator.services & fill_in_services).empty?
×
UNCOV
58
        end
×
UNCOV
59
          if any_items?
×
UNCOV
60
            fill_in = true if any_enumerated?
×
UNCOV
61
          elsif request.too_many_items?
×
UNCOV
62
            fill_in = true
×
UNCOV
63
          else
×
UNCOV
64
            fill_in = any_circulate?
×
UNCOV
65
          end
×
UNCOV
66
        end
×
UNCOV
67
      end
×
UNCOV
68
      fill_in
×
UNCOV
69
    end
×
70

UNCOV
71
    def single_item_request?
×
UNCOV
72
      requestable.size == 1 && !any_fill_in_eligible?
×
UNCOV
73
    end
×
74

UNCOV
75
    def only_aeon?
×
UNCOV
76
      requestable.map(&:aeon?).all?
×
UNCOV
77
    end
×
78

UNCOV
79
    def location_label
×
UNCOV
80
      return "" if holding.blank?
×
UNCOV
81
      first_requestable_item = requestable.first.item if any_items?
×
UNCOV
82
      if any_items? && first_requestable_item.temp_loc_other_than_resource_sharing?
×
UNCOV
83
        current_location_label
×
UNCOV
84
      else
×
UNCOV
85
        permanent_location_label
×
UNCOV
86
      end
×
UNCOV
87
    end
×
88

UNCOV
89
    def current_location_label
×
UNCOV
90
      label = holding["current_library"]
×
UNCOV
91
      current_holding_location = holding['current_location']
×
UNCOV
92
      label += " - #{current_holding_location}" if current_holding_location.present?
×
UNCOV
93
      label
×
UNCOV
94
    end
×
95

UNCOV
96
    def permanent_location_label
×
UNCOV
97
      label = holding["library"]
×
UNCOV
98
      holding_location = holding['location']
×
UNCOV
99
      label += " - #{holding_location}" if holding_location.present?
×
UNCOV
100
      label
×
UNCOV
101
    end
×
102

UNCOV
103
    def holding
×
UNCOV
104
      first_requestable_item = requestable.first.item if any_items?
×
UNCOV
105
      if any_items? && first_requestable_item.temp_loc_other_than_resource_sharing?
×
UNCOV
106
        holdings[first_requestable_item["temp_location_code"]]
×
UNCOV
107
      else
×
UNCOV
108
        holdings[mfhd]
×
UNCOV
109
      end
×
UNCOV
110
    end
×
111

UNCOV
112
    def alma_provider_item_unavailable?
×
UNCOV
113
      patron.alma_provider? && !(any_available? || any_in_process?)
×
UNCOV
114
    end
×
115

UNCOV
116
    private
×
117

UNCOV
118
      def fill_in_services
×
UNCOV
119
        ["annex", "recap_no_items", "on_shelf"]
×
UNCOV
120
      end
×
121

UNCOV
122
      def any_circulate?
×
UNCOV
123
        requestable.any?(&:circulates?)
×
UNCOV
124
      end
×
125

UNCOV
126
      def any_enumerated?
×
UNCOV
127
        requestable.any?(&:enumerated?)
×
UNCOV
128
      end
×
129

UNCOV
130
      def any_items?
×
UNCOV
131
        requestable.any?(&:item_data?)
×
UNCOV
132
      end
×
133

UNCOV
134
      def any_available?
×
UNCOV
135
        requestable.any?(&:available?)
×
UNCOV
136
      end
×
137

UNCOV
138
      def any_in_process?
×
UNCOV
139
        requestable.any?(&:in_process?)
×
UNCOV
140
      end
×
UNCOV
141
  end
×
UNCOV
142
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