From 21bc541d8439610093e756db563501875a7bc1d3 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Mon, 23 Jan 2012 18:44:00 -0500 Subject: [PATCH] Invoke skull-and-crossbones popup in batch receive for server-side errors 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 Conflicts: Open-ILS/xul/staff_client/server/serial/batch_receive.js Signed-off-by: Dan Wells --- Open-ILS/web/js/dojo/openils/widget/HoldingCode.js | 16 ++++++++-- .../staff_client/server/serial/batch_receive.js | 37 ++++++++++++++++------ 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/widget/HoldingCode.js b/Open-ILS/web/js/dojo/openils/widget/HoldingCode.js index b26cb2bef7..0ee6892d16 100644 --- a/Open-ILS/web/js/dojo/openils/widget/HoldingCode.js +++ b/Open-ILS/web/js/dojo/openils/widget/HoldingCode.js @@ -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(); }, diff --git a/Open-ILS/xul/staff_client/server/serial/batch_receive.js b/Open-ILS/xul/staff_client/server/serial/batch_receive.js index deee3c0274..92d67d538b 100644 --- a/Open-ILS/xul/staff_client/server/serial/batch_receive.js +++ b/Open-ILS/xul/staff_client/server/serial/batch_receive.js @@ -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) { -- 2.11.0