'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) {
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);
+ }
},