From 16ec0278ff795d241fcf6ab9339d0264f439956b Mon Sep 17 00:00:00 2001 From: pines Date: Wed, 8 Nov 2006 21:16:00 +0000 Subject: [PATCH] in preparation of owning lib dropdown, refactored volume/copy creation and copy editing and am now using Bill's volume find_or_create method during volume/copy creation, which has the benefit of sidestepping the VOLUME_LABEL_EXISTS event. This fixes bug 244, and helpdesk tickets 3258, 3597, and 3631. git-svn-id: svn://svn.open-ils.org/ILS/trunk@6572 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../staff_client/chrome/content/main/constants.js | 1 + .../xul/staff_client/server/cat/copy_editor.js | 3 +- Open-ILS/xul/staff_client/server/cat/util.js | 76 ++++++++------------ .../staff_client/server/cat/volume_copy_creator.js | 82 ++++++++-------------- 4 files changed, 61 insertions(+), 101 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 411c8a8098..cb8f448c7c 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -37,6 +37,7 @@ const api = { 'FM_ACN_TREE_UPDATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.volume.fleshed.batch.update' }, 'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.copy_tree.retrieve' }, 'FM_ACN_TRANSFER' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.volume.batch.transfer' }, + 'FM_ACN_FIND_OR_CREATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.call_number.find_or_create' }, 'FM_ACP_DETAILS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_details.retrieve' }, //'FM_ACP_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed.retrieve' }, 'FM_ACP_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed2.retrieve' }, diff --git a/Open-ILS/xul/staff_client/server/cat/copy_editor.js b/Open-ILS/xul/staff_client/server/cat/copy_editor.js index 75748b295c..fe82aa7ce9 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_editor.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_editor.js @@ -953,9 +953,10 @@ g.stash_and_close = function() { api.FM_ACP_FLESHED_BATCH_UPDATE.method, [ ses(), g.copies, true ] ); - alert('pause'); if (typeof r.ilsevent != 'undefined') { g.error.standard_unexpected_error_alert('copy update',r); + } else { + alert('Items added/modified.'); } /* FIXME -- revisit the return value here */ } catch(E) { diff --git a/Open-ILS/xul/staff_client/server/cat/util.js b/Open-ILS/xul/staff_client/server/cat/util.js index d3e22b271a..933b14f30b 100644 --- a/Open-ILS/xul/staff_client/server/cat/util.js +++ b/Open-ILS/xul/staff_client/server/cat/util.js @@ -188,53 +188,37 @@ cat.util.add_copies_to_bucket = function(selection_list) { cat.util.spawn_copy_editor = function(list,edit) { try { - var obj = {}; - JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'}); - JSAN.use('util.network'); obj.network = new util.network(); - JSAN.use('util.error'); obj.error = new util.error(); - - var title = list.length == 1 ? '' : 'Batch '; - title += edit == 1 ? 'Edit' : 'View'; - title += ' Copy Attributes'; - - JSAN.use('util.window'); var win = new util.window(); - obj.data.temp_copies = undefined; obj.data.stash('temp_copies'); - obj.data.temp_callnumbers = undefined; obj.data.stash('temp_callnumbers'); - obj.data.temp_copy_ids = js2JSON(list); - obj.data.stash('temp_copy_ids'); - var w = win.open( - window.xulG.url_prefix(urls.XUL_COPY_EDITOR) - +'?edit='+edit, - title, - 'chrome,modal,resizable' - ); - /* FIXME -- need to unique the temp space, and not rely on modalness of window */ - obj.data.stash_retrieve(); - if (!obj.data.temp_copies) return; - var copies = JSON2js( obj.data.temp_copies ); - obj.data.temp_copies = undefined; obj.data.stash('temp_copies'); - obj.data.temp_callnumbers = undefined; obj.data.stash('temp_callnumbers'); - obj.data.temp_copy_ids = undefined; obj.data.stash('temp_copy_ids'); - obj.error.sdump('D_CAT','in cat/copy_status, copy editor, copies =\n<<' + copies + '>>'); - if (edit=='1' && copies!='' && typeof copies != 'undefined') { - try { - var r = obj.network.request( - api.FM_ACP_FLESHED_BATCH_UPDATE.app, - api.FM_ACP_FLESHED_BATCH_UPDATE.method, - [ ses(), copies, true ] - ); - if (typeof r.ilsevent != 'undefined') { - if (r.ilsevent != 0) throw(r); - } - alert('Copies modified.'); - } catch(E) { - obj.error.standard_unexpected_error_alert('copy update error',E); - } - } else { - if (edit=='1') alert('Copies not modified.'); - } + var obj = {}; + JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'}); + JSAN.use('util.network'); obj.network = new util.network(); + JSAN.use('util.error'); obj.error = new util.error(); + + if (list.length == 0) return; + + var title = list.length == 1 ? '' : 'Batch '; + title += edit == 1 ? 'Edit' : 'View'; + title += ' Copy Attributes'; + + JSAN.use('util.window'); var win = new util.window(); + obj.data.temp_copies = undefined; obj.data.stash('temp_copies'); + obj.data.temp_callnumbers = undefined; obj.data.stash('temp_callnumbers'); + obj.data.temp_copy_ids = js2JSON(list); + obj.data.stash('temp_copy_ids'); + var w = win.open( + window.xulG.url_prefix(urls.XUL_COPY_EDITOR) + +'?handle_update=1&edit='+edit, + title, + 'chrome,modal,resizable' + ); + /* FIXME -- need to unique the temp space, and not rely on modalness of window */ + obj.data.stash_retrieve(); + if (!obj.data.temp_copies) alert('Copies not modified.'); + obj.data.temp_copies = undefined; obj.data.stash('temp_copies'); + obj.data.temp_callnumbers = undefined; obj.data.stash('temp_callnumbers'); + obj.data.temp_copy_ids = undefined; obj.data.stash('temp_copy_ids'); } catch(E) { - alert(E); + JSAN.use('util.error'); var error = new util.error(); + error.standard_unexpected_error_alert('error in cat.util.spawn_copy_editor',E); } } diff --git a/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js b/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js index e0beb8a34d..ec268e4d9a 100644 --- a/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js +++ b/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js @@ -331,20 +331,16 @@ g.stash_and_close = function() { for (var ou_id in volumes_hash) { for (var cn in volumes_hash[ou_id]) { - var volume = new acn(); - var acn_id; - if (!g.copy_shortcut) { - acn_id = g.new_node_id--; - volume.isnew('1'); - } else { - acn_id = g.copy_shortcut[ou_id][cn]; + + var acn_id = g.network.simple_request( + 'FM_ACN_FIND_OR_CREATE', + [ ses(), cn, g.doc_id, ou_id ] + ); + + if (typeof acn_id.ilsevent != 'undefined') { + g.error.standard_unexpected_error_alert('Problem finding or creating ' + cn + '. We will skip item creation for this volume.',anc_id); + continue; } - volume.id( acn_id ); - volume.record(g.doc_id); - volume.label(cn); - volume.owning_lib(ou_id); - volume.copies( [] ); - volumes.push( volume ); volume_labels[ acn_id ] = { 'label' : cn, 'owning_lib' : ou_id }; @@ -379,7 +375,7 @@ g.stash_and_close = function() { g.data.temp_callnumbers = js2JSON(volume_labels); g.data.stash('temp_callnumbers'); var w = win.open( urls.XUL_COPY_EDITOR - +'?edit=1&docid='+window.escape(g.doc_id), + +'?edit=1&handle_update=1&docid='+window.escape(g.doc_id), title, 'chrome,modal,resizable' ); @@ -392,51 +388,29 @@ g.stash_and_close = function() { if (!copies) { alert('Items were not created.'); return; - } - } - - for (var i = 0; i < copies.length; i++) { - var copy = copies[i]; - var volume = util.functional.find_id_object_in_list( volumes, copy.call_number() ); - var temp = volume.copies(); - temp.push( copy ); - volume.copies( temp ); - } - - try { - var r = g.network.request( - api.FM_ACN_TREE_UPDATE.app, - api.FM_ACN_TREE_UPDATE.method, - [ ses(), volumes, true ] - ); - if (typeof r.ilsevent != 'undefined') { - switch(r.ilsevent) { - case 1706 /* ITEM_BARCODE_EXISTS */ : - alert('Some of these barcodes are or have been in use. Please change them.'); - return; - break; - default: g.error.standard_unexpected_error_alert('volume tree update',r); break; - } } else { - alert('Copies added.'); - if (copies.length > 0 && $('print_labels').checked) { - JSAN.use('util.functional'); - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve(); - data.temp_barcodes_for_labels = util.functional.map_list( copies, function(o){return o.barcode();}) ; - data.stash('temp_barcodes_for_labels'); - var w = win.open( - urls.XUL_SPINE_LABEL, - 'spine_labels', - 'chrome,resizable,width=750,height=550' - ); + try { + //case 1706 /* ITEM_BARCODE_EXISTS */ : + if (copies.length > 0 && $('print_labels').checked) { + JSAN.use('util.functional'); + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve(); + data.temp_barcodes_for_labels = util.functional.map_list( copies, function(o){return o.barcode();}) ; + data.stash('temp_barcodes_for_labels'); + var w = win.open( + urls.XUL_SPINE_LABEL, + 'spine_labels', + 'chrome,resizable,width=750,height=550' + ); + } + } catch(E) { + g.error.standard_unexpected_error_alert('volume tree update 2',E); } + + if (typeof window.refresh == 'function') window.refresh(); + } - } catch(E) { - g.error.standard_unexpected_error_alert('volume tree update 2',E); } - if (typeof window.refresh == 'function') window.refresh(); - window.close(); } catch(E) { -- 2.11.0