From 0ba9597d947c107e454874ce78bde4103a48c927 Mon Sep 17 00:00:00 2001 From: phasefx Date: Sun, 26 Sep 2010 10:02:38 +0000 Subject: [PATCH] make the MARC editor optional with Z39.50 git-svn-id: svn://svn.open-ils.org/ILS/trunk@18005 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/locale/en-US/lang.dtd | 6 +- Open-ILS/xul/staff_client/server/cat/z3950.js | 401 +++++++++++---------- Open-ILS/xul/staff_client/server/cat/z3950.xul | 1 + .../server/locale/en-US/cat.properties | 1 + 4 files changed, 213 insertions(+), 196 deletions(-) diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 398e0e6fad..d1a0a0980a 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -2751,9 +2751,11 @@ - + + + - + diff --git a/Open-ILS/xul/staff_client/server/cat/z3950.js b/Open-ILS/xul/staff_client/server/cat/z3950.js index 45fce2c753..eba4ca044b 100644 --- a/Open-ILS/xul/staff_client/server/cat/z3950.js +++ b/Open-ILS/xul/staff_client/server/cat/z3950.js @@ -718,119 +718,126 @@ cat.z3950.prototype = { 'spawn_marc_editor' : function(my_marcxml,biblio_source) { var obj = this; - xulG.new_tab( - xulG.url_prefix(urls.XUL_MARC_EDIT), - { 'tab_name' : 'MARC Editor' }, - { - 'record' : { 'marc' : my_marcxml, "rtype": "bre" }, - '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); - } catch(E) { - alert(E); - } - }, - 'save' : { - 'label' : 'Import Record', - 'func' : function (new_marcxml) { - try { - var r = obj.network.simple_request('MARC_XML_RECORD_IMPORT', [ ses(), new_marcxml, biblio_source ]); - if (typeof r.ilsevent != 'undefined') { - switch(Number(r.ilsevent)) { - case 1704 /* TCN_EXISTS */ : - var msg = $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor.same_tcn', [r.payload.tcn]); - var title = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.title'); - var btn1 = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.btn1_overlay'); - var btn2 = typeof r.payload.new_tcn == 'undefined' ? null : $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor.btn2_import', [r.payload.new_tcn]); - if (btn2) { - obj.data.init({'via':'stash'}); - var robj = obj.network.simple_request( - 'PERM_CHECK',[ - ses(), - obj.data.list.au[0].id(), - obj.data.list.au[0].ws_ou(), - [ 'ALLOW_ALT_TCN' ] - ] - ); - if (typeof robj.ilsevent != 'undefined') { - obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.permission_error'),E); - } - if (robj.length != 0) btn2 = null; - } - var btn3 = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.btn3_cancel_import'); - var p = obj.error.yns_alert(msg,title,btn1,btn2,btn3,$("catStrings").getString('staff.cat.z3950.spawn_marc_editor.confirm_action')); - obj.error.sdump('D_ERROR','option ' + p + 'chosen'); - switch(p) { - case 0: - var r3 = obj.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), r.payload.dup_record, new_marcxml, biblio_source ]); - if (typeof r3.ilsevent != 'undefined') { - throw(r3); - } else { - alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_overlay')); - return { - 'id' : r3.id(), - 'on_complete' : function() { - try { - obj.replace_tab_with_opac(r3.id()); - } catch(E) { - alert(E); - } - } - }; + + function save_marc (new_marcxml) { + try { + var r = obj.network.simple_request('MARC_XML_RECORD_IMPORT', [ ses(), new_marcxml, biblio_source ]); + if (typeof r.ilsevent != 'undefined') { + switch(Number(r.ilsevent)) { + case 1704 /* TCN_EXISTS */ : + var msg = $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor.same_tcn', [r.payload.tcn]); + var title = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.title'); + var btn1 = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.btn1_overlay'); + var btn2 = typeof r.payload.new_tcn == 'undefined' ? null : $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor.btn2_import', [r.payload.new_tcn]); + if (btn2) { + obj.data.init({'via':'stash'}); + var robj = obj.network.simple_request( + 'PERM_CHECK',[ + ses(), + obj.data.list.au[0].id(), + obj.data.list.au[0].ws_ou(), + [ 'ALLOW_ALT_TCN' ] + ] + ); + if (typeof robj.ilsevent != 'undefined') { + obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.permission_error'),E); + } + if (robj.length != 0) btn2 = null; + } + var btn3 = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.btn3_cancel_import'); + var p = obj.error.yns_alert(msg,title,btn1,btn2,btn3,$("catStrings").getString('staff.cat.z3950.spawn_marc_editor.confirm_action')); + obj.error.sdump('D_ERROR','option ' + p + 'chosen'); + switch(p) { + case 0: + var r3 = obj.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), r.payload.dup_record, new_marcxml, biblio_source ]); + if (typeof r3.ilsevent != 'undefined') { + throw(r3); + } else { + alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_overlay')); + return { + 'id' : r3.id(), + 'on_complete' : function() { + try { + obj.replace_tab_with_opac(r3.id()); + } catch(E) { + alert(E); } - break; - case 1: - var r2 = obj.network.request( - api.MARC_XML_RECORD_IMPORT.app, - api.MARC_XML_RECORD_IMPORT.method + '.override', - [ ses(), new_marcxml, biblio_source ] - ); - if (typeof r2.ilsevent != 'undefined') { - throw(r2); - } else { - alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_import_with_new_tcn')); - return { - 'id' : r2.id(), - 'on_complete' : function() { - try { - obj.replace_tab_with_opac(r2.id()); - } catch(E) { - alert(E); - } - } - }; + } + }; + } + break; + case 1: + var r2 = obj.network.request( + api.MARC_XML_RECORD_IMPORT.app, + api.MARC_XML_RECORD_IMPORT.method + '.override', + [ ses(), new_marcxml, biblio_source ] + ); + if (typeof r2.ilsevent != 'undefined') { + throw(r2); + } else { + alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_import_with_new_tcn')); + return { + 'id' : r2.id(), + 'on_complete' : function() { + try { + obj.replace_tab_with_opac(r2.id()); + } catch(E) { + alert(E); } - break; - case 2: - default: - alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.import_cancelled')); - break; - } - break; - default: - throw(r); - break; - } - } else { - alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_import')); - return { - 'id' : r.id(), - 'on_complete' : function() { - try { - obj.replace_tab_with_opac(r.id()); - } catch(E) { - alert(E); - } + } + }; } - }; + break; + case 2: + default: + alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.import_cancelled')); + break; + } + break; + default: + throw(r); + break; + } + } else { + alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_import')); + return { + 'id' : r.id(), + 'on_complete' : function() { + try { + obj.replace_tab_with_opac(r.id()); + } catch(E) { + alert(E); } + } + }; + } + } catch(E) { + obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.import_error'),E); + } + }; + + if ( $('marc_editor').checked ) { + xulG.new_tab( + xulG.url_prefix(urls.XUL_MARC_EDIT), + { 'tab_name' : 'MARC Editor' }, + { + 'record' : { 'marc' : my_marcxml, "rtype": "bre" }, + '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); } catch(E) { - obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.import_error'),E); + alert(E); } + }, + 'save' : { + 'label' : $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.save_button_label'), + 'func' : save_marc } - } - } - ); + } + ); + } else { + save_marc(my_marcxml); + } }, 'confirm_overlay' : function(record_ids) { @@ -878,100 +885,106 @@ cat.z3950.prototype = { return; } - xulG.new_tab( - xulG.url_prefix(urls.XUL_MARC_EDIT), - { 'tab_name' : $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.tab_name') }, - { - 'record' : { 'marc' : my_marcxml }, - 'fast_add_item' : function(doc_id,cn_label,cp_barcode) { - try { - JSAN.use('cat.util'); cat.util.fast_item_add(doc_id,cn_label,cp_barcode); - } catch(E) { - alert(E); - } - }, - 'save' : { - 'label' : $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.overlay_record_label'), - 'func' : function (new_marcxml) { - try { - if (! obj.confirm_overlay( [ obj.data.marked_record ] ) ) { return; } - var r = obj.network.simple_request('MARC_XML_RECORD_REPLACE', [ ses(), obj.data.marked_record, new_marcxml, biblio_source ]); - if (typeof r.ilsevent != 'undefined') { - switch(Number(r.ilsevent)) { - case 1704 /* TCN_EXISTS */ : - var msg = $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor_for_overlay.same_tcn', [r.payload.tcn]); - var title = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.import_collision'); - var btn1 = typeof r.payload.new_tcn == 'undefined' ? null : $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor_for_overlay.btn1_overlay', [r.payload.new_tcn]); - if (btn1) { - var robj = obj.network.simple_request( - 'PERM_CHECK',[ - ses(), - obj.data.list.au[0].id(), - obj.data.list.au[0].ws_ou(), - [ 'ALLOW_ALT_TCN' ] - ] - ); - if (typeof robj.ilsevent != 'undefined') { - obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.permission_error'),E); - } - if (robj.length != 0) btn1 = null; - } - var btn2 = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.btn2_cancel'); - var p = obj.error.yns_alert(msg,title,btn1,btn2,null, $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.confirm_action')); - obj.error.sdump('D_ERROR','option ' + p + 'chosen'); - switch(p) { - case 0: - var r2 = obj.network.request( - api.MARC_XML_RECORD_REPLACE.app, - api.MARC_XML_RECORD_REPLACE.method + '.override', - [ ses(), obj.data.marked_record, new_marcxml, biblio_source ] - ); - if (typeof r2.ilsevent != 'undefined') { - throw(r2); - } else { - alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.successful_overlay_with_new_TCN')); - return { - 'id' : r2.id(), - 'on_complete' : function() { - try { - obj.replace_tab_with_opac(r2.id()); - } catch(E) { - alert(E); - } - } - }; - } - break; - case 1: - default: - alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.cancelled_overlay')); - break; - } - break; - default: - throw(r); - break; + function overlay_marc (new_marcxml) { + try { + if (! obj.confirm_overlay( [ obj.data.marked_record ] ) ) { return; } + var r = obj.network.simple_request('MARC_XML_RECORD_REPLACE', [ ses(), obj.data.marked_record, new_marcxml, biblio_source ]); + if (typeof r.ilsevent != 'undefined') { + switch(Number(r.ilsevent)) { + case 1704 /* TCN_EXISTS */ : + var msg = $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor_for_overlay.same_tcn', [r.payload.tcn]); + var title = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.import_collision'); + var btn1 = typeof r.payload.new_tcn == 'undefined' ? null : $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor_for_overlay.btn1_overlay', [r.payload.new_tcn]); + if (btn1) { + var robj = obj.network.simple_request( + 'PERM_CHECK',[ + ses(), + obj.data.list.au[0].id(), + obj.data.list.au[0].ws_ou(), + [ 'ALLOW_ALT_TCN' ] + ] + ); + if (typeof robj.ilsevent != 'undefined') { + obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.permission_error'),E); } - } else { - alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.success_overlay')); - return { - 'id' : r.id(), - 'on_complete' : function() { - try { - obj.replace_tab_with_opac(r.id()); - } catch(E) { - alert(E); - } + if (robj.length != 0) btn1 = null; + } + var btn2 = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.btn2_cancel'); + var p = obj.error.yns_alert(msg,title,btn1,btn2,null, $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.confirm_action')); + obj.error.sdump('D_ERROR','option ' + p + 'chosen'); + switch(p) { + case 0: + var r2 = obj.network.request( + api.MARC_XML_RECORD_REPLACE.app, + api.MARC_XML_RECORD_REPLACE.method + '.override', + [ ses(), obj.data.marked_record, new_marcxml, biblio_source ] + ); + if (typeof r2.ilsevent != 'undefined') { + throw(r2); + } else { + alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.successful_overlay_with_new_TCN')); + return { + 'id' : r2.id(), + 'on_complete' : function() { + try { + obj.replace_tab_with_opac(r2.id()); + } catch(E) { + alert(E); + } + } + }; } - }; + break; + case 1: + default: + alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.cancelled_overlay')); + break; + } + break; + default: + throw(r); + break; + } + } else { + alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.success_overlay')); + return { + 'id' : r.id(), + 'on_complete' : function() { + try { + obj.replace_tab_with_opac(r.id()); + } catch(E) { + alert(E); } + } + }; + } + } catch(E) { + obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.overlay_error'),E); + } + } + + if ( $('marc_editor').checked ) { + xulG.new_tab( + xulG.url_prefix(urls.XUL_MARC_EDIT), + { 'tab_name' : $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.tab_name') }, + { + 'record' : { 'marc' : my_marcxml }, + 'fast_add_item' : function(doc_id,cn_label,cp_barcode) { + try { + JSAN.use('cat.util'); cat.util.fast_item_add(doc_id,cn_label,cp_barcode); } catch(E) { - obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.overlay_error'),E); + alert(E); } + }, + 'save' : { + 'label' : $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.overlay_record_label'), + 'func' : overlay_marc } - } - } - ); + } + ); + } else { + overlay_marc(my_marcxml); + } }, diff --git a/Open-ILS/xul/staff_client/server/cat/z3950.xul b/Open-ILS/xul/staff_client/server/cat/z3950.xul index cce0842ad0..029dab5ef5 100644 --- a/Open-ILS/xul/staff_client/server/cat/z3950.xul +++ b/Open-ILS/xul/staff_client/server/cat/z3950.xul @@ -183,6 +183,7 @@