From 8f2c8af2b54af690f8e5e74c86f4a9d8accdb15a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 13 May 2021 09:03:52 -0300 Subject: [PATCH] Bug 28273: Add form validation for pickup locations This patch introduces validation on the new pickup locations column. This way, if a selected title doesn't have a pickup location set, it will prevent form submission and a suitable error message will pop-up. To test: 1. Apply this patch 2. Attempt to place multi-title level holds 3. Make sure some selected titles don't have the pickup location set 4. Submit => SUCCESS: Form submission halts, an idiomatic error message shows. 5. Unselect all biblios and repeat 4 => SUCCESS: You are not allowed to proceed, a message is displayed. 6. Have all selected titles set a pickup location, submit => SUCCESS: Holds are placed as they should. 7. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Andrew Fuerste-Henry --- .../prog/en/modules/reserve/request.tt | 33 ++++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index 27861b5093..ca1dd0b88f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -1365,17 +1365,32 @@ } function checkMultiHold() { - var spans = $(".multi_hold_item_checkbox:checked"); - if ($(spans).size() == 0) { - alert(MSG_NO_ITEMS_AVAILABLE); - return false; - } var biblionumbers = ""; - $(spans).each(function() { - var bibnum = $(this).attr("title"); - biblionumbers += bibnum + "/"; - }); + var selected_bibs = $(".multi_hold_item_checkbox:checked"); + if ( selected_bibs.length > 0 ) { + // there are biblios selected in the form! + // verify they have a pickup location selected + + var pickup_not_set = 0; + selected_bibs.each(function() { + if ( $(this).closest('tr').find(".multi_pickup_select").val() === "" ) { + pickup_not_set++; + } + else { + var bibnum = $(this).attr("title"); + biblionumbers += bibnum + "/"; + } + }); + if ( pickup_not_set > 0 ) { + alert( _("Please make sure all selected titles have a pickup location set" + "\n") ); + return false; + } + } + else { + alert( _("Please select at least one title" + "\n") ); + return false; + } var badSpans = $(".not_holdable"); var badBibs = ""; -- 2.11.0