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

12
    alias bib_id system_id
×
13

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

23
    def requestable
×
24
      @requestable_list
×
25
    end
×
26

27
    def catalog_url
×
28
      "/catalog/#{system_id}"
×
29
    end
×
30

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

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

48
    def any_will_submit_via_form?
×
49
      return false if requestable.compact_blank.blank? || !eligible_for_library_services?
×
50
      requestable.map(&:will_submit_via_form?).any? || any_fill_in_eligible?
×
51
    end
×
52

53
    def any_fill_in_eligible?
×
54
      return false unless eligible_for_library_services?
×
55
      return false if patron.alma_provider?
×
56

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

74
    def single_item_request?
×
75
      requestable.size == 1 && !any_fill_in_eligible?
×
76
    end
×
77

78
    def only_aeon?
×
79
      requestable.map(&:aeon?).all?
×
80
    end
×
81

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

92
    def current_location_label
×
93
      label = holding["current_library"]
×
94
      current_holding_location = holding['current_location']
×
95
      label += " - #{current_holding_location}" if current_holding_location.present?
×
96
      label
×
97
    end
×
98

99
    def permanent_location_label
×
100
      label = holding["library"]
×
101
      holding_location = holding['location']
×
102
      label += " - #{holding_location}" if holding_location.present?
×
103
      label
×
104
    end
×
105

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

115
    def alma_provider_item_unavailable?
×
116
      patron.alma_provider? && !(any_available? || any_in_process?)
×
117
    end
×
118

119
    private
×
120

121
      def fill_in_services
×
122
        ["annex", "recap_no_items", "on_shelf"]
×
123
      end
×
124

125
      def any_circulate?
×
126
        requestable.any?(&:circulates?)
×
127
      end
×
128

129
      def any_enumerated?
×
130
        requestable.any?(&:enumerated?)
×
131
      end
×
132

133
      def any_items?
×
134
        requestable.any?(&:item_data?)
×
135
      end
×
136

137
      def any_available?
×
138
        requestable.any?(&:available?)
×
139
      end
×
140

141
      def any_in_process?
×
142
        requestable.any?(&:in_process?)
×
143
      end
×
144
  end
×
145
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