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, 30 Jan 2019 14:18:29 +0000 (09:18 -0500)
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 7345e3f..c0cad6c 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() {
@@ -75,6 +82,13 @@ function confirmMultipleHolds() {
 function validateHoldForm() {
     var res = validateMethodSelections(document.getElementsByClassName("hold-alert-method"));
     if (res.isValid) {
+        //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);