[open-ils-commits] r7867 - in trunk/Open-ILS/xul/staff_client:
chrome/content/main server/cat
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Oct 3 18:59:18 EDT 2007
Author: phasefx
Date: 2007-10-03 18:48:25 -0400 (Wed, 03 Oct 2007)
New Revision: 7867
Modified:
trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js
trunk/Open-ILS/xul/staff_client/server/cat/util.js
Log:
bugfix for barcode renaming, local code and server code. Needs just a little more testing before backporting
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js 2007-10-03 19:03:02 UTC (rev 7866)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js 2007-10-03 22:48:25 UTC (rev 7867)
@@ -101,28 +101,58 @@
JSAN.use('util.network');
var network = new util.network();
- var old_bc = window.prompt('Enter original barcode for the copy:','','Replace Barcode');
+ var old_bc = window.prompt('Enter original barcode for the item:','','Replace Barcode');
if (!old_bc) return;
- var copy = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ old_bc ]);
- if (typeof copy.ilsevent != 'undefined') throw(copy);
- if (!copy) throw(copy);
+ var copy;
+ try {
+ copy = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ old_bc ]);
+ if (typeof copy.ilsevent != 'undefined') throw(copy);
+ if (!copy) throw(copy);
+ } catch(E) {
+ alert('We were unable to retrieve an item with barcode "' + old_bc + '".\n');
+ return;
+ }
// Why did I want to do this twice? Because this copy is more fleshed?
- copy = network.simple_request('FM_ACP_RETRIEVE',[ copy.id() ]);
- if (typeof copy.ilsevent != 'undefined') throw(copy);
- if (!copy) throw(copy);
+ try {
+ copy = network.simple_request('FM_ACP_RETRIEVE',[ copy.id() ]);
+ if (typeof copy.ilsevent != 'undefined') throw(copy);
+ if (!copy) throw(copy);
+ } catch(E) {
+ try { alert('We were unable to retrieve an item with barcode "' + old_bc + '".\n' + (typeof E.ilsevent == 'undefined' ? '' : E.textcode + ' : ' + E.desc)); } catch(F) { alert(E + '\n' + F); }
+ return;
+ }
var new_bc = window.prompt('Enter the replacement barcode for the copy:','','Replace Barcode');
+ new_bc = String( new_bc ).replace(/\s/g,'');
+ if (!new_bc) {
+ alert('Rename aborted. Blank for barcode not allowed.');
+ return;
+ }
- var test = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ ses(), new_bc ]);
+ var test = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ new_bc ]);
if (typeof test.ilsevent == 'undefined') {
- alert('Rename aborted. Another copy has that barcode');
+ alert('Rename aborted. Another copy has barcode "' + new_bc + '".');
return;
+ } else {
+ if (test.ilsevent != 1502 /* ASSET_COPY_NOT_FOUND */) {
+ obj.error.standard_unexpected_error_alert('Error testing replacement barcode "' . new_bc . '".',test);
+ return;
+ }
}
+
copy.barcode(new_bc); copy.ischanged('1');
var r = network.simple_request('FM_ACP_FLESHED_BATCH_UPDATE', [ ses(), [ copy ] ]);
- if (typeof r.ilsevent != 'undefined') { if (r.ilsevent != 0) throw(r); }
+ if (typeof r.ilsevent != 'undefined') {
+ if (r.ilsevent != 0) {
+ if (r.ilsevent == 5000 /* PERM_FAILURE */) {
+ alert('Renamed aborted. Insufficient permission.');
+ } else {
+ obj.error.standard_unexpected_error_alert('Error renaming item.',r);
+ }
+ }
+ }
} catch(E) {
obj.error.standard_unexpected_error_alert('Rename did not likely occur.',copy);
}
Modified: trunk/Open-ILS/xul/staff_client/server/cat/util.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/cat/util.js 2007-10-03 19:03:02 UTC (rev 7866)
+++ trunk/Open-ILS/xul/staff_client/server/cat/util.js 2007-10-03 22:48:25 UTC (rev 7867)
@@ -17,34 +17,63 @@
if (!old_bc) old_bc = window.prompt('Enter original barcode for the copy:','','Replace Barcode');
if (!old_bc) return;
- var copy = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ old_bc ]);
- if (typeof copy.ilsevent != 'undefined') throw(copy);
- if (!copy) throw(copy);
-
+ var copy;
+ try {
+ copy = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ old_bc ]);
+ if (typeof copy.ilsevent != 'undefined') throw(copy);
+ if (!copy) throw(copy);
+ } catch(E) {
+ alert('We were unable to retrieve an item with barcode "' + old_bc + '".\n');
+ return old_bc;
+ }
+
// Why did I want to do this twice? Because this copy is more fleshed?
- copy = network.simple_request('FM_ACP_RETRIEVE',[ copy.id() ]);
- if (typeof copy.ilsevent != 'undefined') throw(copy);
- if (!copy) throw(copy);
-
- var new_bc = window.prompt('Enter the replacement barcode for the copy with barcode ' + old_bc + ':','','Replace Barcode');
+ try {
+ copy = network.simple_request('FM_ACP_RETRIEVE',[ copy.id() ]);
+ if (typeof copy.ilsevent != 'undefined') throw(copy);
+ if (!copy) throw(copy);
+ } catch(E) {
+ try { alert('We were unable to retrieve an item with barcode "' + old_bc + '".\n' + (typeof E.ilsevent == 'undefined' ? '' : E.textcode + ' : ' + E.desc)); } catch(F) { alert(E + '\n' + F); }
+ return old_bc;
+ }
+
+ var new_bc = window.prompt('Enter the replacement barcode for the copy:','','Replace Barcode');
new_bc = String( new_bc ).replace(/\s/g,'');
if (!new_bc) {
alert('Rename aborted. Blank for barcode not allowed.');
return old_bc;
}
-
- var test = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ ses(), new_bc ]);
+
+ var test = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ new_bc ]);
if (typeof test.ilsevent == 'undefined') {
- alert('Rename aborted. Another copy has that barcode');
+ alert('Rename aborted. Another copy has barcode "' + new_bc + '".');
return old_bc;
+ } else {
+ if (test.ilsevent != 1502 /* ASSET_COPY_NOT_FOUND */) {
+ obj.error.standard_unexpected_error_alert('Error testing replacement barcode "' . new_bc . '".',test);
+ return old_bc;
+ }
}
+
copy.barcode(new_bc); copy.ischanged('1');
var r = network.simple_request('FM_ACP_FLESHED_BATCH_UPDATE', [ ses(), [ copy ] ]);
- if (typeof r.ilsevent != 'undefined') { if (r.ilsevent != 0) throw(r); }
+ if (typeof r.ilsevent != 'undefined') {
+ if (r.ilsevent != 0) {
+ if (r.ilsevent == 5000 /* PERM_FAILURE */) {
+ alert('Renamed aborted. Insufficient permission.');
+ return old_bc;
+ } else {
+ obj.error.standard_unexpected_error_alert('Error renaming item.',r);
+ return old_bc;
+ }
+ }
+ }
+
return new_bc;
} catch(E) {
JSAN.use('util.error'); var error = new util.error();
error.standard_unexpected_error_alert('Rename did not likely occur.',E);
+ return old_bc;
}
}
More information about the open-ils-commits
mailing list