Invoke skull-and-crossbones popup in batch receive for server-side errors
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 23 Jan 2012 23:44:00 +0000 (18:44 -0500)
committerDan Wells <dbw2@calvin.edu>
Wed, 21 Aug 2013 22:37:25 +0000 (18:37 -0400)
And introduce a minor bumper rail to guide serials users who might try
to hand-edit a holding code.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Conflicts:
    Open-ILS/xul/staff_client/server/serial/batch_receive.js

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/web/js/dojo/openils/widget/HoldingCode.js
Open-ILS/xul/staff_client/server/serial/batch_receive.js

index b26cb2b..0ee6892 100644 (file)
@@ -119,7 +119,7 @@ if (!dojo._hasResource["openils.widget.HoldingCode"]) {
 
         new dijit.form.Button(
             {
-                "label": "Compile",
+                "label": "Create Holding Code",
                 "onClick": function() {
                     inputs.forEach(
                         function(input) {
@@ -200,9 +200,21 @@ if (!dojo._hasResource["openils.widget.HoldingCode"]) {
                     dojo.create("span", null, dialog_div)
                 );
 
-                this.code_text_box = new dijit.form.TextBox(
+                this.code_text_box = new dijit.form.ValidationTextBox(
                     {}, dojo.create("div", null, this.domNode)
                 );
+
+                /* This by no means will fully validate plausible holding codes,
+                 * but it will perhaps help users who experiment with typing
+                 * the holding code in here freehand (a little). */
+                this.code_text_box.validator = function(value) {
+                    try {
+                        return dojo.isArray(dojo.fromJson(value));
+                    } catch(E) {
+                        return false;
+                    }
+                };
+
                 this.code_text_box.startup();
             },
 
index deee3c0..92d67d5 100644 (file)
@@ -7,8 +7,18 @@ dojo.require("openils.CGI");
 dojo.require("openils.XUL");
 dojo.require("openils.PermaCrud");
 
+JSAN.use("util.error");
+var _error = new util.error();
 var batch_receiver;
 
+function _generic_onmethoderror(r, stat, stat_text) {
+    _error.standard_unexpected_error_alert(
+        dojo.byId("commonStrings").getString("common.error"),
+        stat + ":" + stat_text
+    );
+    busy(false);
+}
+
 function S(k) {
     return dojo.byId("serialStrings").getString("batch_receive." + k).
         replace("\\n", "\n");
@@ -147,7 +157,8 @@ function BatchReceiver() {
                     "onresponse": function(r) {
                         if (r = openils.Util.readResponse(r))
                             issuances.push(r);
-                    }
+                    },
+                    "onmethoderror": _generic_onmethoderror
                 }
             );
         } catch (E) {
@@ -191,7 +202,8 @@ function BatchReceiver() {
                                 }
                             );
                         }
-                    }
+                    },
+                    "onmethoderror": _generic_onmethoderror
                 }
             );
             if (!mods.length) {
@@ -248,7 +260,8 @@ function BatchReceiver() {
                     "onresponse": function(r) {
                         if (locs = openils.Util.readResponse(r))
                             self._location_by_lib[lib] = locs;
-                    }
+                    },
+                    "onmethoderror": _generic_onmethoderror
                 }
             );
         }
@@ -341,7 +354,8 @@ function BatchReceiver() {
                             }
                         );
                     }
-                }
+                },
+                "onmethoderror": _generic_onmethoderror
             }
         );
 
@@ -568,7 +582,8 @@ function BatchReceiver() {
                             }, true /* wrap_in_browser */
                         );
                     }
-                }
+                },
+                "onmethoderror": _generic_onmethoderror
             }
         );
     };
@@ -628,7 +643,8 @@ function BatchReceiver() {
                             dojo.byId("bib_search_term").focus();
                         }
                     }
-                }
+                },
+                "onmethoderror": _generic_onmethoderror
             }
         );
     };
@@ -814,7 +830,8 @@ function BatchReceiver() {
                             else self.init();
                         }
                     }
-                }
+                },
+                "onmethoderror": _generic_onmethoderror
             }
         );
     };
@@ -1068,7 +1085,8 @@ function BatchReceiver() {
                     } catch(E) {
                         (dump ? dump : console.log)(E);
                     }
-                }
+                },
+                "onmethoderror": _generic_onmethoderror
             }
         );
     };
@@ -1108,7 +1126,8 @@ function BatchReceiver() {
                                         row._has_autogen_barcode = true;
                                     }
                                 }
-                            }
+                            },
+                            "onmethoderror": _generic_onmethoderror
                         }
                     );
                 } catch (E) {