From 633bc2534dd9ce0e78a8a18a9122087b6162d713 Mon Sep 17 00:00:00 2001 From: phasefx Date: Tue, 6 Jun 2006 14:51:18 +0000 Subject: [PATCH] start refactoring git-svn-id: svn://svn.open-ils.org/ILS/trunk@4518 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/server/cat/util.js | 75 +++++++++++++++++++ .../staff_client/server/circ/copy_status.js | 56 +------------- Open-ILS/xul/staff_client/server/circ/util.js | 2 +- 3 files changed, 77 insertions(+), 56 deletions(-) create mode 100644 Open-ILS/xul/staff_client/server/cat/util.js diff --git a/Open-ILS/xul/staff_client/server/cat/util.js b/Open-ILS/xul/staff_client/server/cat/util.js new file mode 100644 index 0000000000..76a3d06a65 --- /dev/null +++ b/Open-ILS/xul/staff_client/server/cat/util.js @@ -0,0 +1,75 @@ +dump('entering cat/util.js\n'); + +if (typeof cat == 'undefined') var cat = {}; +cat.util = {}; + +cat.util.EXPORT_OK = [ + 'spawn_copy_editor', +]; +cat.util.EXPORT_TAGS = { ':all' : cat.util.EXPORT_OK }; + +cat.util.spawn_copy_editor = function(list) { + 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 copies = util.functional.map_list( + list, + function (acp_id) { + return obj.network.simple_request('FM_ACP_RETRIEVE',[acp_id]); + } + ); + + var edit = 0; + try { + edit = obj.network.request( + api.PERM_MULTI_ORG_CHECK.app, + api.PERM_MULTI_ORG_CHECK.method, + [ + ses(), + obj.data.list.au[0].id(), + util.functional.map_list( + copies, + function (o) { + return obj.network.simple_request('FM_ACN_RETRIEVE',[o.call_number()]).owning_lib(); + } + ), + [ 'UPDATE_COPY', 'UPDATE_BATCH_COPY' ] + ] + ).length == 0 ? 1 : 0; + } catch(E) { + obj.error.sdump('D_ERROR','batch permission check: ' + E); + } + + var title = list.length == 1 ? 'Copy' : 'Copies'; + + JSAN.use('util.window'); var win = new util.window(); + obj.data.temp = ''; + obj.data.stash('temp'); + var w = win.open( + window.xulG.url_prefix(urls.XUL_COPY_EDITOR) + +'?copy_ids='+window.escape(js2JSON(list)) + +'&edit='+edit, + title, + 'chrome,modal,resizable' + ); + /* FIXME -- need to unique the temp space, and not rely on modalness of window */ + obj.data.stash_retrieve(); + copies = JSON2js( obj.data.temp ); + 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 ] + ); + /* FIXME -- revisit the return value here */ + } catch(E) { + obj.error.standard_unexpected_error_alert('copy update error',E); + } + } +} + +dump('exiting cat/util.js\n'); diff --git a/Open-ILS/xul/staff_client/server/circ/copy_status.js b/Open-ILS/xul/staff_client/server/circ/copy_status.js index 9b926cb982..d4dc321990 100644 --- a/Open-ILS/xul/staff_client/server/circ/copy_status.js +++ b/Open-ILS/xul/staff_client/server/circ/copy_status.js @@ -368,62 +368,8 @@ circ.copy_status.prototype = { } ); - var copies = util.functional.map_list( - list, - function (acp_id) { - return obj.network.simple_request('FM_ACP_RETRIEVE',[acp_id]); - } - ); + JSAN.use('cat.util'); cat.util.spawn_copy_editor(list); - var edit = 0; - try { - edit = obj.network.request( - api.PERM_MULTI_ORG_CHECK.app, - api.PERM_MULTI_ORG_CHECK.method, - [ - ses(), - obj.data.list.au[0].id(), - util.functional.map_list( - copies, - function (o) { - return obj.network.simple_request('FM_ACN_RETRIEVE',[o.call_number()]).owning_lib(); - } - ), - [ 'UPDATE_COPY', 'UPDATE_BATCH_COPY' ] - ] - ).length == 0 ? 1 : 0; - } catch(E) { - obj.error.sdump('D_ERROR','batch permission check: ' + E); - } - - var title = list.length == 1 ? 'Copy' : 'Copies'; - - JSAN.use('util.window'); var win = new util.window(); - obj.data.temp = ''; - obj.data.stash('temp'); - var w = win.open( - window.xulG.url_prefix(urls.XUL_COPY_EDITOR) - +'?copy_ids='+window.escape(js2JSON(list)) - +'&edit='+edit, - title, - 'chrome,modal,resizable' - ); - /* FIXME -- need to unique the temp space, and not rely on modalness of window */ - obj.data.stash_retrieve(); - copies = JSON2js( obj.data.temp ); - obj.error.sdump('D_CAT','in circ/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 ] - ); - /* FIXME -- revisit the return value here */ - } catch(E) { - alert('copy update error: ' + js2JSON(E)); - } - } }, } diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js index 55f928c86e..6cf916f932 100644 --- a/Open-ILS/xul/staff_client/server/circ/util.js +++ b/Open-ILS/xul/staff_client/server/circ/util.js @@ -5,7 +5,7 @@ circ.util = {}; circ.util.EXPORT_OK = [ 'offline_checkout_columns', 'offline_checkin_columns', 'offline_renew_columns', 'offline_inhouse_use_columns', - 'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_column', 'hold_capture_via_copy_barcode' + 'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_column', 'hold_capture_via_copy_barcode', ]; circ.util.EXPORT_TAGS = { ':all' : circ.util.EXPORT_OK }; -- 2.43.2