diff --git a/app/assets/javascripts/requests/requests.js b/app/assets/javascripts/requests/requests.js index 9dfefadf4..bc596e0b4 100644 --- a/app/assets/javascripts/requests/requests.js +++ b/app/assets/javascripts/requests/requests.js @@ -1,210 +1,182 @@ // Place all the behaviors and hooks related to the matching controller here. // All this logic will automatically be available in application.js. -$(function() { - function isEmail(email) { - const regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; - return regex.test(email); +$(function () { + function isEmail(email) { + const regex = + /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; + return regex.test(email); + } + + $('form#logins').on('submit', function (event) { + if (!isEmail($('#request_email').val())) { + event.preventDefault(); + $('#request_email').css('background-color', '#f2dede'); + $('span.error-email').css('color', 'red'); + $('span.error-email').text('Please supply a valid email address.'); + } else { + $('#request_email').css('background-color', '#ffffff'); + $('span.error-email').text(''); } + if ($('#request_user_name').val().trim() == '') { + event.preventDefault(); + $('#request_user_name').css('background-color', '#f2dede'); + $('span.error-user_name').css('color', 'red'); + $('span.error-user_name').text('Please supply your full name.'); + } else { + $('#request_user_name').css('background-color', '#ffffff'); + $('span.error-user_name').text(''); + } + }); - $("form#logins").on("submit", function(event) { - if (!isEmail($("#request_email").val())) { - event.preventDefault(); - $("#request_email").css("background-color","#f2dede"); - $("span.error-email").css("color", "red"); - $("span.error-email").text("Please supply a valid email address."); - } else { - $("#request_email").css("background-color","#ffffff"); - $("span.error-email").text(""); - } - if ($.trim($('#request_user_name').val()) == "") - { - event.preventDefault(); - $("#request_user_name").css("background-color","#f2dede"); - $("span.error-user_name").css("color", "red"); - $("span.error-user_name").text("Please supply your full name."); - } else { - $("#request_user_name").css("background-color","#ffffff"); - $("span.error-user_name").text(""); - } - }); - - $("#no_netid").on("click", function(event) { - event.preventDefault(); - $("#no_netid").hide(); - $("#other_user_account_info").show(); - }); - - $('#no_netid').on("keydown", function (e) { - const keyCode = e.keyCode || e.which; + $('#no_netid').on('click', function (event) { + event.preventDefault(); + $('#no_netid').hide(); + $('#other_user_account_info').show(); + }); - if (keyCode == 13) { - $("#no_netid").trigger("click"); - return false; - } - }); + $('#no_netid').on('keydown', function (e) { + const keyCode = e.keyCode || e.which; - $("#go_back").on("click",function(event) { - event.preventDefault(); - $("#no_netid").show(); - $("#other_user_account_info").hide(); - }); - - function activateRequestButton () { - $('#request-submit-button').prop('disabled', false); + if (keyCode == 13) { + $('#no_netid').trigger('click'); + return false; } + }); + + $('#go_back').on('click', function (event) { + event.preventDefault(); + $('#no_netid').show(); + $('#other_user_account_info').hide(); + }); + + function activateRequestButton() { + $('#request-submit-button').prop('disabled', false); + } + + function deactivateRequestButton() { + $('#request-submit-button').prop('disabled', true); + } + + checkRows(); + + function checkRows() { + const rows = document.querySelectorAll('tr[id^=request_]'); + let anyValidRows = false; + rows.forEach((row) => { + if (requestable($(row))) { + anyValidRows = true; + } + }); - function deactivateRequestButton () { - $('#request-submit-button').prop('disabled', true); + if (anyValidRows) { + activateRequestButton(); + } else { + deactivateRequestButton(); } - - function radioOfRadioBtns (radios) { - const radio_checked = document.querySelectorAll('input[type=radio][name^="requestable[][delivery_mode"]:checked'); - - let mode = false; - if (radios && radio_checked.length > 0) { - for (const radio of radio_checked) { - if (radio && radio.dataset['target'].startsWith('#fields-eed')) { - mode = true; - // when it's an edd it should have delivery location true; - } else { - mode = true; - } - } + } + + function requestable(parent) { + const selected = parent + .find('input[type=checkbox][id^="requestable_selected"') + .is(':checked'); + + return selected && deliveryMode(parent) && deliveryLocation(parent); + } + + function deliveryLocation(parent) { + const requestable_pickups = parent.find( + 'select[name^="requestable[][pick_up"] option' + ); + let delivery_location = false; + + if (requestable_pickups.length === 0 || isEed(parent)) { + delivery_location = true; + } else { + requestable_pickups.each(function () { + if ($(this).is(':selected') && $(this).val() !== '') { + delivery_location = true; } - return mode; + }); } - - function deliveryLocation () { - const requestable_pickups_options = document.querySelectorAll('select[name^="requestable[][pick_up"] option'); - - function requestablePickups () { - // If there is only one pickup delivery location the length is 0 - let pickup; - if (requestable_pickups_options.length === 0) { - pickup = true; - } else { - // When there are more than one pickup delivery locations - for (const pickupOption of requestable_pickups_options) { - if (pickupOption.selected == true && pickupOption.value !== '') { - pickup = true; - } - } - } - return pickup; + return delivery_location; + } + + function deliveryMode(parent) { + const radios = parent.find( + 'input[type=radio][name^="requestable[][delivery_mode"]' + ); + let delivery_mode = false; + + if (radios.length === 0) { + delivery_mode = true; + } else { + radios.each(function () { + if ($(this).is(':checked')) { + delivery_mode = true; } - return requestablePickups; + }); } - - function deliveryMode () { - const radios = document.querySelectorAll('input[type=radio][name^="requestable[][delivery_mode"]'); - - function radioButtons () { - let mode; - - if (radios.length === 0) { - const deLocation = deliveryLocation(); - mode = deLocation(); - } else { - mode = radioOfRadioBtns(radios); - } - return mode; + return delivery_mode; + } + + function isEed(parent) { + const radios = parent.find( + 'input[type=radio][name^="requestable[][delivery_mode"]' + ); + let eedRequest = false; + + if (radios.length > 0) { + radios.each(function () { + if ($(this).is(':checked')) { + eedRequest = this.dataset['target'].startsWith('#fields-eed'); } - return radioButtons; + }); } - - const deLocation_ref = deliveryLocation(); - const deMode_ref = deliveryMode(); - - function requestable(el) { - const parent = $(el).closest('[id^="request_"]'); - let selected = parent.find('input[type=checkbox][id^="requestable_selected"').is(':checked'); - let deLocation = deLocation_ref(); - let deMode = deMode_ref(); - - const radio_checked = parent.find('input[type=radio][name^="requestable[][delivery_mode"]:checked'); - const radio = parent.find('input[type=radio][name^="requestable[][delivery_mode"]'); - const requestable_pickups_options = parent.find('select[name^="requestable[][pick_up"] option'); - if (selected) { - selected = true; - } else { - selected = false; - } - - // Special case for edd form. Needs to set delivery location so that the request button is active. - if (radio_checked.length === 1 && radio_checked[0].dataset['target'].startsWith('#fields-eed')) { - deLocation = true; - } - if (selected && requestable_pickups_options.length === 0 && radio.length === 0) { - deMode = true; - } - if (selected && deMode && deLocation) { - activateRequestButton(); - } else { - deactivateRequestButton(); - } - } - - (function () { - const checkbox_nodelist = document.querySelectorAll('[id^="requestable_selected"]'); - let selected; - - if (checkbox_nodelist.length === 1) { - const radio_checked = document.querySelectorAll('input[type=radio][name^="requestable[][delivery_mode"]:checked'); - selected = true; - let deLocation = deLocation_ref(); - const deMode = deMode_ref(); - - // Special case for edd form. Needs to set delivery location so that the request button is active. - if (radio_checked.length === 1 && radio_checked[0].dataset['target'].startsWith('#fields-eed')) { - deLocation = true; - } - if (selected && deMode && deLocation) { - activateRequestButton(); - } else { - deactivateRequestButton(); - } - } else { - deactivateRequestButton(); - requestable(); - } - })(); - - // Enhance the Bootstrap collapse utility to toggle hide/show for other options - $('input[type=radio][name^="requestable[][delivery_mode"]').on('change', function() { - // collapse others - $("input[name='" + this.name + "']").each(function() { - const target = $(this).attr('data-target'); - $(target).collapse('hide'); - }); - // open target + return eedRequest; + } + + // Enhance the Bootstrap collapse utility to toggle hide/show for other options + $('input[type=radio][name^="requestable[][delivery_mode"]').on( + 'change', + function () { + // collapse others + $("input[name='" + this.name + "']").each(function () { const target = $(this).attr('data-target'); - $(target).collapse('show'); - requestable(this); - }); - - $('input[type=text][id^="requestable__edd_art_title_"').on('input', function() { - if ($(this).val() === "") { - $('#request-submit-button').prop('disabled', true); - } else { - requestable(this); - } - }); - - $('select[name^="requestable[][pick_up"]').on('change', function() { - requestable(this); - }); + $(document).find(target).collapse('hide'); + }); + // open target + const target = $(this).attr('data-target'); + $(document).find(target).collapse('show'); + checkRows(this); + } + ); - jQuery(function() { - return $(".tablesorter").DataTable({ - language: { - search: "Search by Enumeration" - }, - ordering: false - }); + $('input[type=text][id^="requestable__edd_art_title_"').on( + 'input', + function () { + if ($(this).val() === '') { + $('#request-submit-button').prop('disabled', true); + } else { + checkRows(this); + } + } + ); + + $('select[name^="requestable[][pick_up"]').on('change', function () { + checkRows(this); + }); + + jQuery(function () { + return $('.tablesorter').DataTable({ + language: { + search: 'Search by Enumeration', + }, + ordering: false, }); + }); - $('.table input[type=checkbox]').on('change', function() { - $(this).closest('tr').toggleClass('selected', $(this).is(':checked')); - requestable(this); - }); + $('.table input[type=checkbox]').on('change', function () { + $(this).closest('tr').toggleClass('selected', $(this).is(':checked')); + checkRows(this); + }); }); diff --git a/spec/cassettes/form_features.yml b/spec/cassettes/form_features.yml index c3065426f..cc0daaef5 100644 --- a/spec/cassettes/form_features.yml +++ b/spec/cassettes/form_features.yml @@ -10199,4 +10199,180 @@ http_interactions: string: '[{"barcode":"","id":"231003662080006421","holding_id":"221003662090006421","copy_number":"","status":"Unavailable","status_label":"Acquisition","status_source":"process_type","process_type":"ACQ","on_reserve":"N","item_type":"Gen","pickup_location_id":"marquand","pickup_location_code":"marquand","location":"marquand$pj","label":"Marquand Library - Remote Storage (ReCAP): Marquand Library Use Only","description":"","enum_display":"","chron_display":"","in_temp_library":false}]' recorded_at: Wed, 03 Jan 2024 21:00:53 GMT -recorded_with: VCR 6.2.0 +- request: + method: get + uri: https://catalog.princeton.edu/catalog/9935076973506421/raw + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Faraday v2.11.0 + 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.25.5 + Date: + - Wed, 18 Sep 2024 15:10:20 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: + - '0' + X-Request-Id: + - fdfdafc1-4974-4da3-a7db-8e1672be0dab + X-Download-Options: + - noopen + X-Ua-Compatible: + - IE=edge,chrome=1 + Etag: + - W/"cb39e643b30fc51ad843edb49d0d2d79" + X-Frame-Options: + - SAMEORIGIN + X-Runtime: + - '0.048266' + X-Content-Type-Options: + - nosniff + X-Powered-By: + - Phusion Passenger(R) 6.0.23 + 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 + Content-Security-Policy: + - frame-ancestors 'self' https://princeton.libwizard.com; + body: + encoding: ASCII-8BIT + string: !binary |- + eyJpZCI6Ijk5MzUwNzY5NzM1MDY0MjEiLCJudW1lcmljX2lkX2IiOnRydWUsImF1dGhvcl9jaXRhdGlvbl9kaXNwbGF5IjpbIkphzIRtacq7YWggYWwtVXJkdW5pzIR5YWgiXSwiYXV0aG9yX3JvbGVzXzFkaXNwbGF5Ijoie1wic2Vjb25kYXJ5X2F1dGhvcnNcIjpbXCJKYcyEbWnKu2FoIGFsLVVyZHVuacyEeWFoXCIsXCLYrNin2YXYudipINin2YTYp9ix2K/ZhtmK2KlcIl0sXCJ0cmFuc2xhdG9yc1wiOltdLFwiZWRpdG9yc1wiOltdLFwiY29tcGlsZXJzXCI6W119IiwiYXV0aG9yX3MiOlsiSmHMhG1pyrthaCBhbC1VcmR1bmnMhHlhaC4gyrtJbWHMhGRhdCBhbC1CYWjMo3RoIGFsLcq7SWxtacyEIiwi2KzYp9mF2LnYqSDYp9mE2KfYsdiv2YbZitipLiDYudmF2KfYr9ipINin2YTYqNit2Ksg2KfZhNi52YTZhdmKIl0sInVuaWZvcm1fdGl0bGVfcyI6WyJEaXJhzIRzYcyEdC4gS2FzaHNoYcyEZiBhbC1zYW5hd2nMhCIsItiv2LHYp9iz2KfYqi4g2YPYtNin2YEg2KfZhNiz2YbZiNmKIl0sInRpdGxlX2Rpc3BsYXkiOiJEaXJhzIRzYcyEdC4gYWwtS2FzaHNoYcyEZiBhbC1zYW5hd2nMhC4iLCJ0aXRsZV92ZXJuX2Rpc3BsYXkiOiLYr9ix2KfYs9in2KouINin2YTZg9i02KfZgSDYp9mE2LPZhtmI2YouIiwidGl0bGVfdCI6W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cImluZGV4ZXNcIjpbbnVsbF19fSIsImxvY2F0aW9uX2NvZGVfcyI6WyJmaXJlc3RvbmUkbmVjIl0sImxvY2F0aW9uIjpbIkZpcmVzdG9uZSBMaWJyYXJ5Il0sImxvY2F0aW9uX2Rpc3BsYXkiOlsiTmVhciBFYXN0IENvbGxlY3Rpb25zIl0sImFkdmFuY2VkX2xvY2F0aW9uX3MiOlsiZmlyZXN0b25lJG5lYyIsIkZpcmVzdG9uZSBMaWJyYXJ5Il0sInVuaWZvcm1fdGl0bGVfMWRpc3BsYXkiOiJbW1wiRGlyYcyEc2HMhHQuXCIsXCJLYXNoc2hhzIRmIGFsLXNhbmF3acyELlwiXSxbXCLYr9ix2KfYs9in2KouXCIsXCLZg9i02KfZgSDYp9mE2LPZhtmI2YouXCJdXSIsImNhbGxfbnVtYmVyX2Rpc3BsYXkiOlsiQVM1OTMuSjM1IEExNzcgSW5kZXgiXSwiY2FsbF9udW1iZXJfYnJvd3NlX3MiOlsiQVM1OTMuSjM1IEExNzcgSW5kZXgiXSwiY2FsbF9udW1iZXJfbG9jYXRvcl9kaXNwbGF5IjpbIkFTNTkzLkozNSBBMTc3IEluZGV4Il0sImhhc2hlZF9pZF9zc2kiOiJiYzYxOTdjMjc3Y2UwYzkwIiwiX3ZlcnNpb25fIjoxODA3MjA3NDU4MzkzODE3MDg4LCJ0aW1lc3RhbXAiOiIyMDI0LTA4LTEyVDE4OjI4OjU3LjM5NloifQ== + recorded_at: Wed, 18 Sep 2024 15:10:20 GMT +- request: + method: get + uri: https://bibdata-staging.lib.princeton.edu/locations/holding_locations/firestone$nec.json + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Faraday v2.11.0 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 18 Sep 2024 15:10:21 GMT + 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/"4689fb0b62ca9d1a2eef9a970e6f6737" + X-Runtime: + - '0.138189' + Access-Control-Request-Method: + - GET + X-Request-Id: + - ffb2837c-0b6d-4523-8008-332b05235962 + body: + encoding: UTF-8 + string: '{"label":"Near East Collections","code":"firestone$nec","aeon_location":false,"recap_electronic_delivery_location":false,"open":true,"requestable":true,"always_requestable":false,"circulates":true,"remote_storage":"","fulfillment_unit":"General","library":{"label":"Firestone + Library","code":"firestone","order":0},"holding_library":null,"delivery_locations":[{"label":"Firestone + Library","address":"One Washington Rd. Princeton, NJ 08544","phone_number":"609-258-1470","contact_email":"fstcirc@princeton.edu","gfa_pickup":"PA","staff_only":false,"pickup_location":true,"digital_location":true,"library":{"label":"Firestone + Library","code":"firestone","order":0}}]}' + recorded_at: Wed, 18 Sep 2024 15:10:21 GMT +- request: + method: get + uri: https://bibdata-staging.lib.princeton.edu/bibliographic/9935076973506421/holdings/22579150960006421/availability.json + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Faraday v2.11.0 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 18 Sep 2024 15:10:29 GMT + 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/"e44ebb2c7574597d674ff4f97343a465" + X-Runtime: + - '8.013627' + Access-Control-Request-Method: + - GET + X-Request-Id: + - b709e4a6-118a-4a3d-b88f-85c06035fcc6 + body: + encoding: UTF-8 + string: '[{"barcode":"32101062590169","id":"23579150920006421","holding_id":"22579150960006421","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":"firestone","pickup_location_code":"firestone","location":"firestone$nec","label":"Firestone + Library - Near East Collections","description":"mujallad 26 1999","enum_display":"mujallad + 26","chron_display":"1999","in_temp_library":false},{"barcode":"32101036867644","id":"23579150930006421","holding_id":"22579150960006421","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":"firestone","pickup_location_code":"firestone","location":"firestone$nec","label":"Firestone + Library - Near East Collections","description":"mujallad 25 1998","enum_display":"mujallad + 25","chron_display":"1998","in_temp_library":false},{"barcode":"32101036867651","id":"23579150940006421","holding_id":"22579150960006421","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":"firestone","pickup_location_code":"firestone","location":"firestone$nec","label":"Firestone + Library - Near East Collections","description":"mujallad 24 1997","enum_display":"mujallad + 24","chron_display":"1997","in_temp_library":false},{"barcode":"32101036867545","id":"23579150950006421","holding_id":"22579150960006421","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":"firestone","pickup_location_code":"firestone","location":"firestone$nec","label":"Firestone + Library - Near East Collections","description":"mujallad 23 1996","enum_display":"mujallad + 23","chron_display":"1996","in_temp_library":false}]' + recorded_at: Wed, 18 Sep 2024 15:10:29 GMT +recorded_with: VCR 6.3.1 diff --git a/spec/features/requests/form_spec.rb b/spec/features/requests/form_spec.rb index 3fb1d56eb..ab5a697e5 100644 --- a/spec/features/requests/form_spec.rb +++ b/spec/features/requests/form_spec.rb @@ -1073,6 +1073,35 @@ select('Firestone Library') expect(page).to have_button('Request this Item', disabled: false) end + it 'does not enable when one item is selected and another has a delivery location' do + visit 'requests/9935076973506421?aeon=false&mfhd=22579150960006421' + expect(page).to have_content 'Dirāsāt' + expect(page).to have_content 'Jāmiʻah al-Urdunīyah' + expect(page).to have_content 'mujallad 26 1999' + choose('requestable__delivery_mode_22579150960006421_print') + expect(page).to have_button('Request Selected Items', disabled: true) + check('requestable_selected_23579150920006421') + expect(page).to have_button('Request Selected Items', disabled: true) + end + it 'unchecking an item when there is another valid item leaves the submit button enabled' do + visit 'requests/9935076973506421?aeon=false&mfhd=22579150960006421' + + first_row = page.all('tr[id^=request_]')[0] + second_row = page.all('tr[id^=request_]')[1] + expect(page).to have_content 'Dirāsāt' + expect(page).to have_content 'Jāmiʻah al-Urdunīyah' + expect(page).to have_content 'mujallad 26 1999' + expect(page).to have_button('Request Selected Items', disabled: true) + first_row.check('requestable_selected') + first_row.choose('requestable__delivery_mode_22579150960006421_print') + second_row.check('requestable_selected_23579150920006421') + second_row.choose('requestable__delivery_mode_23579150920006421_print') + expect(page).to have_button('Request Selected Items', disabled: false) + first_row.uncheck('requestable_selected') + expect(page).to have_button('Request Selected Items', disabled: false) + second_row.uncheck('requestable_selected_23579150920006421') + expect(page).to have_button('Request Selected Items', disabled: true) + end end describe 'Request a temp holding item from Resource Sharing - RES_SHARE$IN_RS_REQ' do