Skip to content

Commit

Permalink
Filling out manual volume allows request (#3422)
Browse files Browse the repository at this point in the history
* Filling out manual volume allows request

---------

Co-authored-by: Ryan Laddusaw <rladdusaw@princeton.edu>
  • Loading branch information
rladdusaw and Ryan Laddusaw committed Feb 16, 2023
1 parent 7ee7a9a commit f255a6a
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 11 deletions.
13 changes: 11 additions & 2 deletions app/assets/javascripts/requests/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ $(document).ready(function() {
checkAllRequestable();
});

$('input[type=text][id^="requestable_user_supplied_enum_"').on('input', function() {
checkAllRequestable();
});

function requestable(changed) {
var parent = $(changed).closest('[id^="request_"]');
var selected = parent.find('input[type=checkbox][id^="requestable_selected"').is(':checked');
var delivery_mode = false;
var radios = parent.find('input[type=radio][name^="requestable[][delivery_mode"]')
var radios = parent.find('input[type=radio][name^="requestable[][delivery_mode"]');
if (radios.length === 0) {
delivery_mode = true;
} else {
Expand All @@ -82,7 +86,12 @@ $(document).ready(function() {
}
});
}
if (selected && delivery_mode) {
var volume_text = parent.find('input[type=text][id^="requestable_user_supplied_enum_"');
var user_supplied = true;
if (volume_text.length > 0 && volume_text.val().length === 0) {
user_supplied = false;
}
if (selected && delivery_mode && user_supplied) {
$('#request-submit-button').prop('disabled', false);
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<tr class='user-supplied-input' id='request_user_supplied_<%= "#{requestable.holding.keys[0]}" %>'>
<td class='request--select'>
<%= hidden_field_tag 'requestable[][selected]', false, id: "hidden_selected" %>
<%= check_box_tag "requestable[][selected]", true, false, class: 'request--select', aria: { label: "Volume not listed"} %>
<%= check_box_tag "requestable[][selected]", true, false, class: 'request--select', aria: { label: "Volume not listed"}, id: "requestable_selected" %>
<%= hidden_fields_item requestable %>
</td>
<td class='request--options' <%= 'colspan="2"'.html_safe unless table_sorter_present?(requestable_list) %>>
Expand All @@ -17,7 +17,7 @@
<% if table_sorter_present?(requestable_list) %>
<td></td>
<% end %>
<td>
<td class="delivery--options">
<% selected = !(requestable.fill_in_pick_up? && requestable.fill_in_digitize?) %>
<% collapse = selected ? "" : "collapse"%>
<% if requestable.fill_in_pick_up? %>
Expand Down
117 changes: 117 additions & 0 deletions spec/cassettes/request_features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9504,4 +9504,121 @@ http_interactions:
1-3 Jan./Feb.-May/June 2006","enum_display":"vol. 98, no. 1-3","chron_display":"Jan./Feb.-May/June
2006","in_temp_library":false}]'
recorded_at: Mon, 12 Dec 2022 19:24:18 GMT
- request:
method: get
uri: https://catalog.princeton.edu/catalog/9931433603506421/raw
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- Faraday v0.17.6
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept:
- "*/*"
response:
status:
code: 200
message: OK
headers:
Server:
- nginx/1.23.2
Date:
- Wed, 15 Feb 2023 18:59:54 GMT
Content-Type:
- application/json; charset=utf-8
Transfer-Encoding:
- chunked
Connection:
- keep-alive
Status:
- 200 OK
Cache-Control:
- max-age=0, private, must-revalidate
Referrer-Policy:
- strict-origin-when-cross-origin
X-Permitted-Cross-Domain-Policies:
- none
X-Xss-Protection:
- 1; mode=block
X-Request-Id:
- 922397cb-a6c5-4368-94b8-f3066d090142
X-Download-Options:
- noopen
X-Ua-Compatible:
- IE=edge,chrome=1
Etag:
- W/"5315e85faac7585eeb2efad15d15c705"
X-Frame-Options:
- SAMEORIGIN
X-Runtime:
- '0.028847'
X-Content-Type-Options:
- nosniff
X-Powered-By:
- Phusion Passenger(R) 6.0.17
Access-Control-Allow-Origin:
- "*"
Access-Control-Allow-Credentials:
- 'true'
Access-Control-Allow-Methods:
- GET, POST, OPTIONS
Access-Control-Allow-Headers:
- DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Origin
body:
encoding: ASCII-8BIT
string: !binary |-
eyJpZCI6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JFYXN0IEFzaWFuIExpYnJhcnkiXSwiY2FsbF9udW1iZXJfZGlzcGxheSI6WyJEUzc5Ni5NMiBBNjIzIl0sImNhbGxfbnVtYmVyX2Jyb3dzZV9zIjpbIkRTNzk2Lk0yIEE2MjMiXSwiY2FsbF9udW1iZXJfbG9jYXRvcl9kaXNwbGF5IjpbIkRTNzk2Lk0yIEE2MjMiXSwiaGFzaGVkX2lkX3NzaSI6Ijg0ZmI3ZjAzMTY3NGU4YzciLCJfdmVyc2lvbl8iOjE3NTU4NjE0NzQ5OTI5Nzk5NjgsInRpbWVzdGFtcCI6IjIwMjMtMDEtMjRUMDA6MjY6MzEuNjY0WiJ9
recorded_at: Wed, 15 Feb 2023 18:59:54 GMT
- request:
method: get
uri: https://bibdata-staging.princeton.edu/bibliographic/9931433603506421/holdings/22542676190006421/availability.json
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- Faraday v0.17.6
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept:
- "*/*"
response:
status:
code: 200
message: OK
headers:
Content-Type:
- application/json; charset=utf-8
Transfer-Encoding:
- chunked
Connection:
- keep-alive
Status:
- 200 OK
Access-Control-Allow-Headers:
- Origin, Content-Type, Accept, Authorization, Token
Cache-Control:
- max-age=0, private, must-revalidate
Access-Control-Allow-Origin:
- "*"
Etag:
- W/"e7a1899a24477af4fff262b0ffb11937"
X-Runtime:
- '6.272279'
Access-Control-Request-Method:
- GET
X-Request-Id:
- 31ced9df-99b1-4017-b8c6-726293d9bc07
body:
encoding: UTF-8
string: '[{"barcode":"32101050509726","id":"23542676160006421","holding_id":"22542676190006421","copy_number":"1","status":"Available","status_label":"Item
in place","status_source":"base_status","process_type":null,"on_reserve":"N","item_type":"Gen","pickup_location_id":"eastasian","pickup_location_code":"eastasian","location":"eastasian$cjk","label":"East
Asian Library","description":"1997","enum_display":"1997","chron_display":"","in_temp_library":false},{"barcode":"32101050509734","id":"23542676170006421","holding_id":"22542676190006421","copy_number":"1","status":"Available","status_label":"Item
in place","status_source":"base_status","process_type":null,"on_reserve":"N","item_type":"Gen","pickup_location_id":"eastasian","pickup_location_code":"eastasian","location":"eastasian$cjk","label":"East
Asian Library","description":"1996","enum_display":"1996","chron_display":"","in_temp_library":false},{"barcode":"32101043800596","id":"23542676180006421","holding_id":"22542676190006421","copy_number":"1","status":"Available","status_label":"Item
in place","status_source":"base_status","process_type":null,"on_reserve":"N","item_type":"Gen","pickup_location_id":"eastasian","pickup_location_code":"eastasian","location":"eastasian$cjk","label":"East
Asian Library","description":"1995","enum_display":"1995","chron_display":"","in_temp_library":false}]'
recorded_at: Wed, 15 Feb 2023 19:00:01 GMT
recorded_with: VCR 6.1.0
26 changes: 19 additions & 7 deletions spec/features/requests/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@
fill_in 'request_email', with: 'name@email.com'
fill_in 'request_user_name', with: 'foobar'
click_button I18n.t('requests.account.other_user_login_btn')
expect(page).to have_field 'requestable__selected', disabled: false
expect(page).to have_field 'requestable_selected', disabled: false
expect(page).to have_field 'requestable_selected_7484608', disabled: true
expect(page).to have_field 'requestable_user_supplied_enum_2576882'
check('requestable__selected', exact: true)
check('requestable_selected', exact: true)
fill_in 'requestable_user_supplied_enum_2576882', with: 'test'
select('Firestone Library', from: 'requestable__pick_up_2576882')
click_button 'Request Selected Items'
Expand Down Expand Up @@ -342,7 +342,7 @@

it 'allows CAS patrons to request a ReCAP record that has no item data' do
visit "/requests/99113283293506421?mfhd=22750642660006421"
check('requestable__selected', exact: true)
check('requestable_selected', exact: true)
fill_in 'requestable[][user_supplied_enum]', with: 'Some Volume'
expect(page).to have_button('Request this Item', disabled: false)
end
Expand Down Expand Up @@ -560,7 +560,7 @@
expect(page).to have_content 't. 2, no 2 (2018 )' # include enumeration and chron
expect(page).to have_content 't. 3, no 2 (2019 )' # include enumeration and chron
within(".user-supplied-input") do
check('requestable__selected')
check('requestable_selected')
end
fill_in "requestable_user_supplied_enum_22547424510006421", with: "ABC ZZZ"
choose('requestable__delivery_mode_22547424510006421_print') # choose the print radio button
Expand Down Expand Up @@ -591,7 +591,7 @@
expect(page).to have_content 'Pick-up location: Firestone Library'
expect(page).to have_content 'If the specific volume does not appear in the list below, please enter it here:'
within(".user-supplied-input") do
check('requestable__selected')
check('requestable_selected')
end
fill_in "requestable_user_supplied_enum_22547424510006421", with: "ABC ZZZ"
choose('requestable__delivery_mode_22547424510006421_edd') # choose the print radio button
Expand Down Expand Up @@ -845,10 +845,10 @@

it 'an annex item with user supplied information creates annex emails' do
visit '/requests/9922868943506421?mfhd=22692156940006421'
expect(page).to have_field 'requestable__selected', disabled: false
expect(page).to have_field 'requestable_selected', disabled: false
expect(page).to have_field 'requestable_user_supplied_enum_22692156940006421'
within('#request_user_supplied_22692156940006421') do
check('requestable__selected', exact: true)
check('requestable_selected', exact: true)
fill_in 'requestable_user_supplied_enum_22692156940006421', with: 'test'
end
expect(page).to have_content 'Physical Item Delivery'
Expand Down Expand Up @@ -1384,6 +1384,18 @@
check('requestable_selected_23641620980006421')
expect(page).to have_button('Request Selected Items', disabled: false)
end
it 'enables and disables for a record with user supplied volume data' do
visit 'requests/9931433603506421?mfhd=22542676190006421'
expect(page).to have_content 'Aomen'
expect(page).to have_content 'East Asian Library DS796.M2 A623'
expect(page).to have_content 'If the specific volume does not appear in the list below, please enter it here'
expect(page).to have_button('Request Selected Items', disabled: true)
check('requestable_selected')
choose('requestable__delivery_mode_22542676190006421_print')
expect(page).to have_button('Request Selected Items', disabled: true)
fill_in(id: 'requestable_user_supplied_enum_22542676190006421', with: 'Volume 1')
expect(page).to have_button('Request Selected Items', disabled: false)
end
end

describe 'Request a temp holding item from Resource Sharing - RES_SHARE$IN_RS_REQ' do
Expand Down

0 comments on commit f255a6a

Please sign in to comment.