PINES Customization: Alert when no hold notification options
authorTerran McCanna <tmccanna@georgialibraries.org>
Mon, 10 Dec 2018 19:17:42 +0000 (14:17 -0500)
committerChris Sharp <csharp@georgialibraries.org>
Wed, 16 Oct 2019 18:45:00 +0000 (14:45 -0400)
Present an alert if no notification options are selected in
both the OPAC and web staff client.

Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Open-ILS/web/js/ui/default/opac/holds-validation.js

index 688d5da..17f349f 100644 (file)
@@ -22,10 +22,15 @@ function validateMethodSelections (alertMethodCboxes) {
     var inputNames = { e: "email_address", ph: "phone_notify", sms: "sms_notify", carrier: "sms_carrier"};
     resetBackgrounds(inputNames);
 
+    //PINES variable:
+    var anyCheckbox = 0;
+
     //Array.from(alertMethodCboxes).forEach(function(cbox){
     for (var i = 0; i < alertMethodCboxes.length; i++){
         var cbox = alertMethodCboxes[i];
         if (cbox.checked && !cbox.disabled) {
+            //PINES check
+            anyCheckbox = anyCheckbox + 1;
             switch(cbox.id){
                 case "email_notify_checkbox":
                     needsEmail = true;
@@ -57,7 +62,9 @@ function validateMethodSelections (alertMethodCboxes) {
     }
     
     var isFormOK = emailOK && phoneOK && smsOK;
-    return { isValid: isFormOK, culpritNames : culprits };
+    //PINES customization
+    //return { isValid: isFormOK, culpritNames : culprits };
+    return { isValid: isFormOK, culpritNames : culprits, anyCheckbox : anyCheckbox };
 }
 
 function confirmMultipleHolds() {
@@ -81,6 +88,14 @@ function validateHoldForm() {
             submit_element.disabled = true;
         }
         return result;
+        //PINES custom check for notification options
+        if (res.anyCheckbox == 0) {
+            var anyCheckboxResponse = confirm("    No notification options are selected.    \n     Are you sure you want to continue?");
+            if (anyCheckboxResponse == false) {
+                return false;
+            }
+        }
+        return confirmMultipleHolds();
     } else {
         alert(eg_opac_i18n.EG_MISSING_REQUIRED_INPUT);
         res.culpritNames.forEach(function(n){