From 76a81f849fd2a756a2176af05b9e22d807e3271b Mon Sep 17 00:00:00 2001 From: phasefx Date: Fri, 8 Jan 2010 20:21:58 +0000 Subject: [PATCH] Support for Fast Item Add in MARC Editor for existing records. Removed a speedbump. Clear fast item barcode field after record save. git-svn-id: svn://svn.open-ils.org/ILS/trunk@15286 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../staff_client/chrome/content/cat/opac.js | 93 +++++++++++++++++-- .../chrome/locale/en-US/offline.properties | 5 +- .../xul/staff_client/server/cat/marcedit.js | 1 + 3 files changed, 90 insertions(+), 9 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js index 7875502497..926d12418b 100644 --- a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js +++ b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js @@ -19,9 +19,6 @@ function my_init() { JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'}); XML_HTTP_SERVER = g.data.server_unadorned; - //JSAN.addRepository('http://' + g.data.server_unadorned + '/xul/server/'); - //JSAN._loadJSFromUrl('http://' + g.data.server_unadorned + '/xul/server/cat/util.js'); - JSAN.use('util.network'); g.network = new util.network(); g.cgi = new CGI(); @@ -76,15 +73,96 @@ function set_marc_edit() { var b = {}; var c = { 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid }, - /* // FIXME - disable this until we find a good way of pulling remote JSAN libraries into chrome 'fast_add_item' : function(doc_id,cn_label,cp_barcode) { try { - JSAN.use('cat.util'); return cat.util.fast_item_add(doc_id,cn_label,cp_barcode); + var cat = { util: {} }; /* FIXME: kludge since we can't load remote JSAN libraries into chrome */ + cat.util.spawn_copy_editor = function(params) { + try { + if (!params.copy_ids && !params.copies) return; + if (params.copy_ids && params.copy_ids.length == 0) return; + if (params.copies && params.copies.length == 0) return; + if (params.copy_ids) params.copy_ids = js2JSON(params.copy_ids); // legacy + if (!params.caller_handles_update) params.handle_update = 1; // legacy + + var obj = {}; + JSAN.use('util.network'); obj.network = new util.network(); + JSAN.use('util.error'); obj.error = new util.error(); + + var title = ''; + if (params.copy_ids && params.copy_ids.length > 1 && params.edit == 1) + title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_edit'); + else if(params.copies && params.copies.length > 1 && params.edit == 1) + title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_view'); + else if(params.copy_ids && params.copy_ids.length == 1) + title = $("offlineStrings").getString('staff.cat.util.copy_editor.edit'); + else + title = $("offlineStrings").getString('staff.cat.util.copy_editor.view'); + + JSAN.use('util.window'); var win = new util.window(); + var my_xulG = win.open( + (urls.XUL_COPY_EDITOR), + title, + 'chrome,modal,resizable', + params + ); + if (!my_xulG.copies && params.edit) { + } else { + return my_xulG.copies; + } + return []; + } catch(E) { + JSAN.use('util.error'); var error = new util.error(); + error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.spawn_copy_editor',E); + } + } + cat.util.fast_item_add = function(doc_id,cn_label,cp_barcode) { + var error; + try { + + JSAN.use('util.error'); error = new util.error(); + JSAN.use('util.network'); var network = new util.network(); + + var acn_id = network.simple_request( + 'FM_ACN_FIND_OR_CREATE', + [ ses(), cn_label, doc_id, ses('ws_ou') ] + ); + + if (typeof acn_id.ilsevent != 'undefined') { + error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add', acn_id); + return; + } + + var copy_obj = new acp(); + copy_obj.id( -1 ); + copy_obj.isnew('1'); + copy_obj.barcode( cp_barcode ); + copy_obj.call_number( acn_id ); + copy_obj.circ_lib( ses('ws_ou') ); + /* FIXME -- use constants */ + copy_obj.deposit(0); + copy_obj.price(0); + copy_obj.deposit_amount(0); + copy_obj.fine_level(2); + copy_obj.loan_duration(2); + copy_obj.location(1); + copy_obj.status(0); + copy_obj.circulate(get_db_true()); + copy_obj.holdable(get_db_true()); + copy_obj.opac_visible(get_db_true()); + copy_obj.ref(get_db_false()); + + JSAN.use('util.window'); var win = new util.window(); + return cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] }); + + } catch(E) { + if (error) error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add #2',E); else alert('FIXME: ' + E); + } + } + return cat.util.fast_item_add(doc_id,cn_label,cp_barcode); } catch(E) { - alert(E); + alert('Error in chrome/content/cat/opac.js, set_marc_edit, fast_item_add: ' + E); } }, - */ 'save' : { 'label' : document.getElementById('offlineStrings').getString('cat.save_record'), 'func' : function (new_marcxml) { @@ -96,7 +174,6 @@ function set_marc_edit() { if (typeof r.ilsevent != 'undefined') { throw(r); } else { - alert(document.getElementById('offlineStrings').getString("cat.save.success")); return { 'id' : r.id(), 'oncomplete' : function() {} diff --git a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties index 9ffb6a2e0f..ccecb88b79 100644 --- a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties +++ b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties @@ -36,7 +36,6 @@ cat.opac.record_undeleted.error=Error undeleting record #%1$s : %2$s : %3$s cat.opac.record_marked_for_overlay.record_id.alert=Record with ID %1$s marked for overlay. cat.opac.record_marked_for_overlay.tcn.alert=Record with TCN %1$s marked for overlay. cat.save_record=Save Record -cat.save.success=Record successfully saved. cat.save.failure=Record not likely updated. cat.record.counter=Record %1$s of %2$s cat.preference.error=Preference not likely updated. @@ -245,3 +244,7 @@ menu.local_admin.patrons_due_refunds.tab=Patrons With Negative Balances menu.circulation.staged_patrons.tab=Pending Patrons load_printer_settings_error_description=Printer settings did not load cleanly with this version of Evergreen. You should reconfigure your printer under Printer Settings Editor. load_printer_settings_error_title=Printer Settings +staff.cat.util.copy_editor.batch_edit=Batch Edit +staff.cat.util.copy_editor.batch_view=Batch View +staff.cat.util.copy_editor.edit=Edit +staff.cat.util.copy_editor.view=View diff --git a/Open-ILS/xul/staff_client/server/cat/marcedit.js b/Open-ILS/xul/staff_client/server/cat/marcedit.js index efe3bd79a9..15441cb1ac 100644 --- a/Open-ILS/xul/staff_client/server/cat/marcedit.js +++ b/Open-ILS/xul/staff_client/server/cat/marcedit.js @@ -1306,6 +1306,7 @@ function fastItemAdd_attempt(doc_id) { if (!document.getElementById('fastItemAdd_callnumber').value) { return; } if (!document.getElementById('fastItemAdd_barcode').value) { return; } window.xulG.fast_add_item( doc_id, document.getElementById('fastItemAdd_callnumber').value, document.getElementById('fastItemAdd_barcode').value ); + document.getElementById('fastItemAdd_barcode').value = ''; } catch(E) { alert('fastItemAdd_attempt: ' + E); } -- 2.43.2