LP#1029601: Prevent duplicate holds from double clicks
[Evergreen.git] / Open-ILS / web / js / ui / default / opac / holds-validation.js
index 842366c..688d5da 100644 (file)
@@ -60,13 +60,29 @@ function validateMethodSelections (alertMethodCboxes) {
     return { isValid: isFormOK, culpritNames : culprits };
 }
 
+function confirmMultipleHolds() {
+    var result = true;
+    var numSelect = document.getElementById("num_copies");
+    if (numSelect) {
+        var num = parseInt(numSelect.value);
+        if (num > 1) {
+            result = window.confirm(eg_opac_i18n.EG_MULTIHOLD_MESSAGE.format(num));
+        }
+    }
+    return result;
+}
+
 function validateHoldForm() {
     var res = validateMethodSelections(document.getElementsByClassName("hold-alert-method"));
-    if (res.isValid)
-    {
-        return true;
+    if (res.isValid) {
+        var result = confirmMultipleHolds();
+        if (result) {
+           var submit_element = document.getElementById("place_hold_submit");
+            submit_element.disabled = true;
+        }
+        return result;
     } else {
-        alert ("Please complete hold notification method info.");
+        alert(eg_opac_i18n.EG_MISSING_REQUIRED_INPUT);
         res.culpritNames.forEach(function(n){
             document.getElementsByName(n)[0].style.backgroundColor  = "yellow";
         });