1 dump('entering cat.copy_browser.js\n');
4 if (typeof cat == 'undefined') cat = {};
5 cat.copy_browser = function (params) {
7 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
8 JSAN.use('util.error'); this.error = new util.error();
10 dump('cat.copy_browser: ' + E + '\n');
14 cat.copy_browser.prototype = {
22 'init' : function( params ) {
25 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
28 obj.docid = params.docid;
30 JSAN.use('util.network'); obj.network = new util.network();
31 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
33 obj.controller_init(params);
35 obj.list_init(params);
37 obj.controller.render();
39 obj.default_depth = obj.depth_menu_init();
40 obj.default_lib = obj.data.hash.aou[ obj.library_menu_init() ];
42 document.getElementById('show_acns').addEventListener(
45 JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
46 util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
51 document.getElementById('show_acps').addEventListener(
54 JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
55 util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
60 obj.show_my_libs( obj.default_lib.id() );
62 JSAN.use('util.exec'); var exec = new util.exec(20); exec.timer(obj.funcs,100);
64 obj.show_consortial_count();
67 this.error.standard_unexpected_error_alert('cat.copy_browser.init: ',E);
71 'controller_init' : function(params) {
74 JSAN.use('util.controller'); obj.controller = new util.controller();
78 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
81 function() { obj.list.clipboard(); }
86 alert(document.getElementById('commonStrings').getString('common.unimplemented'));
89 'cmd_show_my_libs' : [
95 'cmd_show_all_libs' : [
101 'cmd_show_libs_with_copies' : [
104 obj.show_libs_with_copies();
114 'sel_mark_items_damaged' : [
117 JSAN.use('cat.util'); JSAN.use('util.functional');
119 var list = util.functional.filter_list( obj.sel_list, function (o) { return o.split(/_/)[0] == 'acp'; });
121 list = util.functional.map_list( list, function (o) { return o.split(/_/)[1]; });
123 cat.util.mark_item_damaged( list );
128 'sel_mark_items_missing' : [
131 JSAN.use('cat.util'); JSAN.use('util.functional');
133 var list = util.functional.filter_list( obj.sel_list, function (o) { return o.split(/_/)[0] == 'acp'; });
135 list = util.functional.map_list( list, function (o) { return o.split(/_/)[1]; });
137 cat.util.mark_item_missing( list );
145 JSAN.use('util.functional');
147 var list = util.functional.filter_list(
150 return o.split(/_/)[0] == 'acp';
154 list = util.functional.map_list(
157 return { 'copy_id' : o.split(/_/)[1] };
161 JSAN.use('circ.util');
162 circ.util.show_last_few_circs(list);
165 'sel_copy_details' : [
168 JSAN.use('util.functional');
170 var list = util.functional.filter_list(
173 return o.split(/_/)[0] == 'acp';
177 JSAN.use('circ.util');
178 circ.util.item_details_new(
179 util.functional.map_list(
181 return obj.map_acp[o].barcode();
190 JSAN.use("cat.util");
191 JSAN.use("util.functional");
193 /* Filter selected rows that aren"t copies. */
194 var list = util.functional.filter_list(
197 return o.split(/_/)[0] == "acp";
200 var results = cat.util.make_bookable(
201 util.functional.map_list(
203 return obj.map_acp[o].id();
207 if (results && results["brsrc"]) {
208 cat.util.edit_new_brsrc(results["brsrc"]);
212 'cmd_book_item_now' : [
215 JSAN.use("cat.util");
216 JSAN.use("util.functional");
218 /* Filter selected rows that aren"t copies. */
219 var list = util.functional.filter_list(
222 return o.split(/_/)[0] == "acp";
225 var results = cat.util.make_bookable(
226 util.functional.map_list(
228 return obj.map_acp[o].id();
233 cat.util.edit_new_bresv(results);
241 JSAN.use('util.functional');
242 var list = util.functional.map_list(
243 util.functional.filter_list(
246 return o.split(/_/)[0] == 'acn';
250 return o.split(/_/)[1];
253 if (list.length == 0) return;
255 var copy_shortcut = {};
256 list = util.functional.map_list(
259 var call_number = obj.map_acn['acn_'+o];
260 var ou_id = call_number.owning_lib();
262 var label = call_number.label();
263 var acnc_id = typeof call_number.label_class() == 'object'
264 ? call_number.label_class().id()
265 : call_number.label_class();
266 var acnp_id = typeof call_number.prefix() == 'object'
267 ? call_number.prefix().id()
268 : call_number.prefix();
269 var acns_id = typeof call_number.suffix() == 'object'
270 ? call_number.suffix().id()
271 : call_number.suffix();
272 if (!copy_shortcut[ou_id]) copy_shortcut[ou_id] = {};
273 var callnumber_composite_key = acnc_id + ':' + acnp_id + ':' + label + ':' + acns_id;
274 copy_shortcut[ou_id][ callnumber_composite_key ] = volume_id;
279 /* quick fix */ /* what was this fixing? */
280 list = []; for (var i in copy_shortcut) { list.push( i ); }
284 edit = obj.network.request(
285 api.PERM_MULTI_ORG_CHECK.app,
286 api.PERM_MULTI_ORG_CHECK.method,
289 obj.data.list.au[0].id(),
293 ).length == 0 ? 1 : 0;
295 obj.error.sdump('D_ERROR','batch permission check: ' + E);
298 if (edit==0) return; // no read-only view for this interface
300 var title = document.getElementById('catStrings').getString('staff.cat.copy_browser.add_item.title');
303 var unified_interface = String( obj.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
304 if (unified_interface) {
305 var horizontal_interface = String( obj.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
306 url = xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
308 url = xulG.url_prefix( urls.XUL_VOLUME_COPY_CREATOR_ORIGINAL );
311 var w = xulG.new_tab(
313 { 'tab_name' : title },
315 'doc_id' : obj.docid,
317 'copy_shortcut' : copy_shortcut,
318 'onrefresh' : function() { obj.refresh_list(); }
322 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_item.error'),E);
326 'cmd_add_items_to_buckets' : [
330 JSAN.use('util.functional');
332 var list = util.functional.filter_list(
335 return o.split(/_/)[0] == 'acp';
339 list = util.functional.map_list(
342 return o.split(/_/)[1];
346 JSAN.use('cat.util');
347 cat.util.add_copies_to_bucket( list );
350 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_items_bucket.error'),E);
358 var unified_interface = String( obj.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
359 if (!unified_interface) {
360 obj.controller.control_map['old_cmd_edit_items'][1]();
364 JSAN.use('util.functional');
366 var list = util.functional.filter_list(
369 return o.split(/_/)[0] == 'acp';
373 list = util.functional.map_list(
376 var cloned_copy_obj = JSON2js( js2JSON( obj.map_acp[ o ] ) );
377 cloned_copy_obj.call_number( obj.map_acn[ 'acn_' + cloned_copy_obj.call_number() ] );
378 return cloned_copy_obj;
382 xulG.volume_item_creator( {'existing_copies':list, 'onrefresh' : function() { obj.refresh_list(); } } );
385 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_items.error'),E);
390 'cmd_replace_barcode' : [
394 JSAN.use('util.functional');
396 var list = util.functional.filter_list(
399 return o.split(/_/)[0] == 'acp';
403 list = util.functional.map_list(
406 var cloned_copy_obj = JSON2js( js2JSON( obj.map_acp[ o ] ) );
407 cloned_copy_obj.call_number( obj.map_acn[ 'acn_' + cloned_copy_obj.call_number() ] );
408 return cloned_copy_obj;
412 xulG.volume_item_creator( {'existing_copies':list, 'onrefresh' : function() { obj.refresh_list(); } } );
415 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_items.error'),E);
421 'old_cmd_edit_items' : [
425 JSAN.use('util.functional');
427 var list = util.functional.filter_list(
430 return o.split(/_/)[0] == 'acp';
434 list = util.functional.map_list(
437 return o.split(/_/)[1];
441 JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
445 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_items.error'),E);
449 'cmd_delete_items' : [
453 JSAN.use('util.functional');
455 var list = util.functional.filter_list(
458 return o.split(/_/)[0] == 'acp';
462 list = util.functional.map_list(
465 return JSON2js( js2JSON( obj.map_acp[ 'acp_' + o.split(/_/)[1] ] ) );
470 if (list.length != 1) {
471 delete_msg = document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.delete_items.confirm.plural', [list.length]);
473 delete_msg = document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.confirm');
475 var r = obj.error.yns_alert(
477 document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.title'),
478 document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.delete'),
479 document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.cancel'),
481 document.getElementById('commonStrings').getString('common.confirm')
485 var acn_hash = {}; var acn_list = [];
486 for (var i = 0; i < list.length; i++) {
487 list[i].isdeleted('1');
488 var acn_id = list[i].call_number();
489 if ( ! acn_hash[ acn_id ] ) {
490 acn_hash[ acn_id ] = obj.map_acn[ 'acn_' + acn_id ];
491 acn_hash[ acn_id ].copies( [] );
493 var temp = acn_hash[ acn_id ].copies();
494 temp.push( list[i] );
495 acn_hash[ acn_id ].copies( temp );
497 for (var i in acn_hash) acn_list.push( acn_hash[i] );
498 var robj = obj.network.simple_request(
499 'FM_ACN_TREE_UPDATE',
500 [ ses(), acn_list, true ],
503 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.override'),
504 'overridable_events' : [
505 1208 /* TITLE_LAST_COPY */,
506 1227 /* COPY_DELETE_WARNING */,
510 if (robj == null) throw(robj);
511 if (typeof robj.ilsevent != 'undefined') {
512 if ( (robj.ilsevent != 0) && (robj.ilsevent != 1227 /* COPY_DELETE_WARNING */) && (robj.ilsevent != 1208 /* TITLE_LAST_COPY */) ) throw(robj);
519 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.error'),E);
524 'cmd_print_spine_labels' : [
528 JSAN.use('util.functional');
530 var list = util.functional.filter_list(
533 return o.split(/_/)[0] == 'acp';
537 list = util.functional.map_list(
540 return obj.map_acp[ o ];
545 xulG.url_prefix( urls.XUL_SPINE_LABEL ),
546 { 'tab_name' : document.getElementById('catStrings').getString('staff.cat.copy_browser.print_spine.tab') },
548 'barcodes' : util.functional.map_list( list, function(o){return o.barcode();})
552 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.print_spine.error'),E);
556 'cmd_add_volumes' : [
560 JSAN.use('util.functional');
561 var list = util.functional.filter_list(
564 return o.split(/_/)[0] == 'aou';
567 list = util.functional.map_list(
570 return o.split(/_/)[1];
575 edit = obj.network.request(
576 api.PERM_MULTI_ORG_CHECK.app,
577 api.PERM_MULTI_ORG_CHECK.method,
580 obj.data.list.au[0].id(),
582 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
584 ).length == 0 ? 1 : 0;
586 obj.error.sdump('D_ERROR','batch permission check: ' + E);
590 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.permission_error'));
591 return; // no read-only view for this interface
594 var title = document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.title');
596 var horizontal_interface = String( obj.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
597 var url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
598 var w = xulG.new_tab(
600 { 'tab_name' : title },
601 { 'doc_id' : obj.docid, 'ou_ids' : list, 'onrefresh' : function() { obj.refresh_list(); } }
605 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.error'),E);
609 'cmd_edit_volumes' : [
613 JSAN.use('util.functional');
614 var volumes = util.functional.map_list(
615 util.functional.filter_list(
618 return o.split(/_/)[0] == 'acn';
622 return o.split(/_/)[1];
625 volumes = util.functional.map_list(
628 var my_acn = obj.map_acn['acn_' + o];
629 return function(r){return r;}(my_acn);
633 JSAN.use('cat.util');
634 if ( cat.util.batch_edit_volumes( volumes ) ) {
639 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.exception'),E);
643 'cmd_delete_volumes' : [
647 JSAN.use('util.functional');
649 var list = util.functional.filter_list(
652 return o.split(/_/)[0] == 'acn';
656 list = util.functional.map_list(
659 return JSON2js( js2JSON( obj.map_acn[ 'acn_' + o.split(/_/)[1] ] ) );
664 if (list.length == 1) {
665 del_prompt = document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.prompt');
667 del_prompt = document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.delete_volume.prompt.plural', [list.length]);
670 var r = obj.error.yns_alert(
672 document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.title'),
673 document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.delete'),
674 document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.cancel'),
676 document.getElementById('commonStrings').getString('common.confirm')
680 for (var i = 0; i < list.length; i++) {
681 list[i].isdeleted('1');
683 var robj = obj.network.simple_request(
684 'FM_ACN_TREE_UPDATE',
685 [ ses(), list, true ],
688 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.override'),
689 'overridable_events' : [
693 if (robj == null) throw(robj);
694 if (typeof robj.ilsevent != 'undefined') {
695 if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
696 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain'));
699 if (robj.ilsevent != 0) throw(robj);
704 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.exception'),E);
710 'cmd_mark_library' : [
714 var list = util.functional.filter_list(
717 return o.split(/_/)[0] == 'aou';
721 list = util.functional.map_list(
724 return o.split(/_/)[1];
728 if (list.length == 1) {
729 obj.data.marked_library = { 'lib' : list[0], 'docid' : obj.docid };
730 obj.data.stash('marked_library');
731 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.alert'));
734 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.prompt'),
735 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.title'),
736 document.getElementById('commonStrings').getString('common.ok'),
739 document.getElementById('commonStrings').getString('common.confirm')
743 obj.error.standard_unexpected_error_alert('copy browser -> mark library',E);
748 'cmd_mark_volume' : [
752 var list = util.functional.filter_list(
755 return o.split(/_/)[0] == 'acn';
759 list = util.functional.map_list(
762 return o.split(/_/)[1];
766 if (list.length == 1) {
767 obj.data.marked_volume = list[0];
768 obj.data.stash('marked_volume');
769 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.alert'));
772 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.prompt'),
773 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.title'),
774 document.getElementById('commonStrings').getString('common.ok'),
777 document.getElementById('commonStrings').getString('common.confirm')
781 obj.error.standard_unexpected_error_alert('copy browser -> mark volume',E);
785 'cmd_refresh_list' : [
791 'cmd_transfer_volume' : [
795 obj.data.stash_retrieve();
796 if (!obj.data.marked_library) {
797 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_volume.alert'));
801 JSAN.use('util.functional');
803 var list = util.functional.filter_list(
806 return o.split(/_/)[0] == 'acn';
810 list = util.functional.map_list(
813 return o.split(/_/)[1];
817 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
819 var acn_list = util.functional.map_list(
822 return obj.map_acn[ 'acn_' + o ].label();
824 ).join(document.getElementById('commonStrings').getString('common.grouping_string'));
826 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: auto">';
827 xml += '<description>';
828 xml += document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.transfer.prompt', [acn_list, obj.data.hash.aou[ obj.data.marked_library.lib ].shortname()]);
829 xml += '</description>';
830 xml += '<hbox><button label="' + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.submit.label') + '" name="fancy_submit"/>';
831 xml += '<button label="'
832 + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.cancel.label')
834 + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.cancel.accesskey')
835 + '" name="fancy_cancel"/></hbox>';
836 xml += '<iframe style="overflow: scroll" flex="1" src="' + urls.XUL_BIB_BRIEF + '?docid=' + obj.data.marked_library.docid + '"/>';
838 JSAN.use('OpenILS.data');
839 var data = new OpenILS.data(); data.init({'via':'stash'});
840 //data.temp_transfer = xml; data.stash('temp_transfer');
841 JSAN.use('util.window'); var win = new util.window();
842 var fancy_prompt_data = win.open(
843 urls.XUL_FANCY_PROMPT,
844 //+ '?xml_in_stash=temp_transfer'
845 //+ '&title=' + window.escape('Volume Transfer'),
846 'fancy_prompt', 'chrome,resizable,modal,width=500,height=300',
849 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.title')
853 if (fancy_prompt_data.fancy_status == 'incomplete') {
854 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.incomplete'));
858 var robj = obj.network.simple_request(
860 [ ses(), { 'docid' : obj.data.marked_library.docid, 'lib' : obj.data.marked_library.lib, 'volumes' : list } ],
863 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.override.failure'),
864 'overridable_events' : [
865 1208 /* TITLE_LAST_COPY */,
866 1219 /* COPY_REMOTE_CIRC_LIB */,
871 if (typeof robj.ilsevent != 'undefined') {
872 if (robj.ilsevent == 1221 /* ORG_CANNOT_HAVE_VOLS */) {
873 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.ineligible_destination'));
878 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.success'));
882 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.unexpected_error'),E);
888 'cmd_transfer_items' : [
892 obj.data.stash_retrieve();
893 if (!obj.data.marked_volume) {
894 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_items.missing_volume'));
898 JSAN.use('util.functional');
900 var list = util.functional.filter_list(
903 return o.split(/_/)[0] == 'acp';
907 list = util.functional.map_list(
910 return o.split(/_/)[1];
914 var volume = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ obj.data.marked_volume ]);
916 JSAN.use('cat.util'); cat.util.transfer_copies( {
918 'docid' : volume.record(),
919 'volume_label' : volume.label(),
920 'owning_lib' : volume.owning_lib(),
924 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_items.unexpected_error'),E);
930 'cmd_link_as_multi_bib' : [
934 obj.data.stash_retrieve();
935 if (!obj.data.marked_multi_home_record) {
936 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.link_as_multi_bib.missing_bib'));
940 JSAN.use('util.functional');
942 var list = util.functional.filter_list(
945 return o.split(/_/)[0] == 'acp';
949 list = util.functional.map_list(
952 return obj.map_acp[ o ].barcode();
957 window.xulG.url_prefix(urls.MANAGE_MULTI_HOME_ITEMS),
959 { 'docid' : obj.data.marked_multi_home_record, 'barcodes' : list }
963 alert('Error in copy_browser.js, cmd_link_as_multi_bib: ' + E);
973 this.error.standard_unexpected_error_alert('cat.copy_browser.controller_init(): ',E);
977 'depth_menu_init' : function(params) {
982 for (var i = 0; i < obj.data.list.aout.length; i++) {
983 var type = obj.data.list.aout[i];
984 var depth = type.depth();
985 if ( depth > max_depth) { max_depth = depth; }
986 if (typeof list[depth] == 'undefined') {
994 list[depth][0] += ' / ' + type.opac_label();
997 ml = util.widgets.make_menulist( list, max_depth );
998 ml.setAttribute('id','depth_menu'); document.getElementById('x_depth_menu').appendChild(ml);
1002 obj.default_depth = ev.target.value;
1003 if (document.getElementById('refresh_button')) document.getElementById('refresh_button').focus();
1004 JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
1005 util.widgets.save_attributes(file, {
1006 'lib_menu' : [ 'value' ],
1007 'depth_menu' : [ 'value' ],
1008 'show_acns' : [ 'checked' ],
1009 'show_acps' : [ 'checked' ]
1015 file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
1016 util.widgets.load_attributes(file);
1017 ml.value = ml.getAttribute('value');
1019 ml.value = max_depth;
1020 ml.setAttribute('value',ml.value);
1025 alert('Error in copy_browser.js, depth_menu_init(): ' + E);
1029 'library_menu_init' : function(params) {
1033 obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative',[ obj.docid ]);
1034 if (typeof obj.org_ids.ilsevent != 'undefined') throw(obj.org_ids);
1035 JSAN.use('util.functional');
1036 obj.org_ids = util.functional.map_list( obj.org_ids, function (o) { return Number(o); });
1038 var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
1040 JSAN.use('util.file'); JSAN.use('util.widgets');
1042 var file; var list_data; var ml;
1044 file = new util.file('offline_ou_list');
1045 if (file._file.exists()) {
1046 list_data = file.get_object(); file.close();
1047 for (var i = 0; i < list_data[0].length; i++) { // make sure all entries are enabled
1048 list_data[0][i][2] = false;
1050 ml = util.widgets.make_menulist( list_data[0], list_data[1] );
1051 ml.setAttribute('id','lib_menu'); document.getElementById('x_lib_menu').appendChild(ml);
1052 for (var i = 0; i < obj.org_ids.length; i++) {
1053 ml.getElementsByAttribute('value',obj.org_ids[i])[0].setAttribute('class','has_copies');
1055 ml.firstChild.addEventListener(
1058 document.getElementById('legend').setAttribute('hidden','false');
1062 ml.firstChild.addEventListener(
1065 document.getElementById('legend').setAttribute('hidden','true');
1069 ml.addEventListener(
1072 obj.default_lib = obj.data.hash.aou[ ev.target.value ];
1073 if (document.getElementById('refresh_button')) document.getElementById('refresh_button').focus();
1074 JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
1075 util.widgets.save_attributes(file, {
1076 'lib_menu' : [ 'value' ],
1077 'depth_menu' : [ 'value' ],
1078 'show_acns' : [ 'checked' ],
1079 'show_acps' : [ 'checked' ]
1086 throw(document.getElementById('catStrings').getString('staff.cat.copy_browser.missing_library') + '\n');
1089 file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
1090 util.widgets.load_attributes(file);
1091 ml.value = ml.getAttribute('value');
1093 ml.value = org.id();
1094 ml.setAttribute('value',ml.value);
1100 this.error.standard_unexpected_error_alert('cat.copy_browser.library_menu_init(): ',E);
1104 'show_consortial_count' : function() {
1107 obj.network.simple_request('FM_ACP_COUNT.authoritative',[ obj.data.tree.aou.id(), obj.docid ],function(req){
1109 var robj = req.getResultObject();
1110 var x = document.getElementById('consortial_total');
1111 if (x) x.setAttribute('value',robj[0].count);
1112 x = document.getElementById('consortial_available');
1113 if (x) x.setAttribute('value',robj[0].available);
1115 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.consortial_copy_count.error'),E);
1119 this.error.standard_unexpected_error_alert('cat.copy_browser.show_consortial_count: ',E);
1123 'show_my_libs' : function(org) {
1127 org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
1129 if (typeof org != 'object') org = obj.data.hash.aou[ org ];
1131 obj.show_libs( org, false );
1133 var p_org = obj.data.hash.aou[ org.parent_ou() ];
1135 obj.funcs.push( function() {
1136 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1137 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1138 document.getElementById('lib_menu').setAttribute('disabled','true');
1140 for (var i = 0; i < p_org.children().length; i++) {
1144 obj.show_libs( o, false );
1146 }( p_org.children()[i] )
1149 obj.funcs.push( function() {
1150 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1151 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1152 document.getElementById('lib_menu').setAttribute('disabled','false');
1161 'show_all_libs' : function() {
1166 obj.show_libs( obj.data.tree.aou );
1168 obj.funcs.push( function() {
1169 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1170 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1171 document.getElementById('lib_menu').setAttribute('disabled','true');
1174 for (var i = 0; i < obj.data.tree.aou.children().length; i++) {
1175 var child = obj.data.tree.aou.children()[i];
1176 if (obj.data.hash.aout[child.ou_type()].depth() <= obj.default_depth
1177 && orgIsMine(obj.default_lib,child,obj.default_depth)) {
1187 obj.funcs.push( function() {
1188 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1189 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1190 document.getElementById('lib_menu').setAttribute('disabled','false');
1198 'show_libs_with_copies' : function() {
1201 JSAN.use('util.functional');
1203 var orgs = util.functional.map_list(
1205 function(id) { return obj.data.hash.aou[id]; }
1208 if (a.shortname() < b.shortname()) return -1;
1209 if (a.shortname() > b.shortname()) return 1;
1213 obj.funcs.push( function() {
1214 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1215 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1216 document.getElementById('lib_menu').setAttribute('disabled','true');
1219 for (var i = 0; i < orgs.length; i++) {
1223 obj.show_libs(o,false);
1228 obj.funcs.push( function() {
1229 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1230 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1231 document.getElementById('lib_menu').setAttribute('disabled','false');
1239 'show_libs' : function(start_aou,show_open) {
1242 if (!start_aou) throw('show_libs: Need a start_aou');
1243 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1244 JSAN.use('util.functional');
1247 var temp_aou = start_aou;
1248 while ( temp_aou.parent_ou() ) {
1249 temp_aou = obj.data.hash.aou[ temp_aou.parent_ou() ];
1250 parents.push( temp_aou );
1254 for (var i = 0; i < parents.length; i++) {
1258 obj.append_org(o,p,{'container':'true','open':'true'});
1260 }(parents[i], obj.data.hash.aou[ parents[i].parent_ou() ])
1266 return function() { obj.append_org(o,p); };
1267 }(start_aou,obj.data.hash.aou[ start_aou.parent_ou() ])
1272 if (start_aou.children()) {
1273 var x = obj.map_tree[ 'aou_' + start_aou.id() ];
1274 x.setAttribute('container','true');
1275 if (show_open) x.setAttribute('open','true');
1276 for (var i = 0; i < start_aou.children().length; i++) {
1277 var child = start_aou.children()[i];
1278 if (obj.data.hash.aout[child.ou_type()].depth() <= obj.default_depth
1279 && orgIsMine(obj.default_lib,child,obj.default_depth)) {
1282 return function() { obj.append_org(o,p); };
1283 }( child, start_aou )
1296 'on_select' : function(list,twisty) {
1298 for (var i = 0; i < list.length; i++) {
1299 var node = obj.map_tree[ list[i] ];
1300 //if (node.lastChild.nodeName == 'treechildren') { continue; } else { alert(node.lastChild.nodeName); }
1301 var row_type = list[i].split('_')[0];
1302 var id = list[i].split('_')[1];
1304 case 'aou' : obj.on_select_org(id,twisty); break;
1305 case 'acn' : obj.on_select_acn(id,twisty); break;
1311 'on_select_acn' : function(acn_id,twisty) {
1314 var acn_tree = obj.map_acp[ 'acn_' + acn_id ];
1315 obj.funcs.push( function() {
1316 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1317 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1318 document.getElementById('lib_menu').setAttribute('disabled','true');
1320 if (acn_tree.copies()) {
1321 for (var i = 0; i < acn_tree.copies().length; i++) {
1325 obj.append_acp(c,a);
1327 }( acn_tree.copies()[i], acn_tree )
1331 obj.funcs.push( function() {
1332 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1333 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1334 document.getElementById('lib_menu').setAttribute('disabled','false');
1341 'on_select_org' : function(org_id,twisty) {
1344 var org = obj.data.hash.aou[ org_id ];
1345 obj.funcs.push( function() {
1346 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1347 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1348 document.getElementById('lib_menu').setAttribute('disabled','true');
1350 if (org.children()) {
1351 for (var i = 0; i < org.children().length; i++) {
1352 var child = org.children()[i];
1353 if (obj.data.hash.aout[child.ou_type()].depth() <= obj.default_depth
1354 && orgIsMine(obj.default_lib,child,obj.default_depth)) {
1365 if (obj.map_acn[ 'aou_' + org_id ]) {
1366 for (var i = 0; i < obj.map_acn[ 'aou_' + org_id ].length; i++) {
1370 obj.append_acn(o,a);
1372 }( org, obj.map_acn[ 'aou_' + org_id ][i] )
1376 obj.funcs.push( function() {
1377 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1378 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1379 document.getElementById('lib_menu').setAttribute('disabled','false');
1382 alert('Error in copy_browser.js, on_select_org(): ' + E);
1386 'append_org' : function (org,parent_org,params) {
1388 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1389 obj.error.consoleService.logStringMessage('append_org: org = ' + org.shortname() + ' parent_org = ' + (parent_org ? parent_org.shortname() : '') + ' params = ' + js2JSON(params) + '\n');
1391 if (obj.map_tree[ 'aou_' + org.id() ]) {
1392 var x = obj.map_tree[ 'aou_' + org.id() ];
1394 for (var i in params) {
1395 x.setAttribute(i,params[i]);
1407 'skip_all_columns_except' : [0,1,2],
1408 'retrieve_id' : 'aou_' + org.id(),
1410 'no_auto_select' : true,
1414 if ( obj.org_ids.indexOf( Number( org.id() ) ) == -1 ) {
1415 if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) {
1416 data.row.my.volume_count = '0';
1417 data.row.my.copy_count = '<0>';
1419 data.row.my.volume_count = '';
1420 data.row.my.copy_count = '';
1423 var v_count = 0; var c_count = 0;
1424 acn_tree_list = obj.network.simple_request(
1425 'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS.authoritative',
1426 [ ses(), obj.docid, [ org.id() ] ]
1428 for (var i = 0; i < acn_tree_list.length; i++) {
1430 obj.map_acn[ 'acn_' + acn_tree_list[i].id() ] = function(r){return r;}(acn_tree_list[i]);
1431 var copies = acn_tree_list[i].copies(); if (copies) c_count += copies.length;
1432 for (var j = 0; j < copies.length; j++) {
1433 obj.map_acp[ 'acp_' + copies[j].id() ] = function(r){return r;}(copies[j]);
1436 data.row.my.volume_count = v_count;
1437 data.row.my.copy_count = '<' + c_count + '>';
1440 data.node = obj.map_tree[ 'aou_' + parent_org.id() ];
1442 var nparams = obj.list.append(data);
1443 var node = nparams.my_node;
1445 for (var i in params) {
1446 node.setAttribute(i,params[i]);
1449 obj.map_tree[ 'aou_' + org.id() ] = node;
1451 if (org.children()) {
1452 node.setAttribute('container','true');
1456 if ( obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].parent_ou() == parent_org.id() ) {
1457 data.node.setAttribute('open','true');
1460 obj.map_tree[ 'aou_' + org.id() ].setAttribute('open','true');
1463 if (acn_tree_list) {
1464 obj.map_acn[ 'aou_' + org.id() ] = acn_tree_list;
1465 node.setAttribute('container','true');
1468 if (document.getElementById('show_acns').checked) {
1469 node.setAttribute('open','true');
1470 obj.funcs.push( function() { obj.on_select_org( org.id() ); } );
1479 'append_acn' : function( org, acn_tree, params ) {
1482 if (obj.map_tree[ 'acn_' + acn_tree.id() ]) {
1483 var x = obj.map_tree[ 'acn_' + acn_tree.id() ];
1485 for (var i in params) {
1486 x.setAttribute(i,params[i]);
1492 var parent_node = obj.map_tree[ 'aou_' + org.id() ];
1498 'volume_count' : '',
1499 'copy_count' : acn_tree.copies() ? acn_tree.copies().length : '0',
1502 'skip_all_columns_except' : [0,1,2],
1503 'retrieve_id' : 'acn_' + acn_tree.id(),
1504 'node' : parent_node,
1506 'no_auto_select' : true,
1508 var nparams = obj.list.append(data);
1509 var node = nparams.my_node;
1510 obj.map_tree[ 'acn_' + acn_tree.id() ] = node;
1512 for (var i in params) {
1513 node.setAttribute(i,params[i]);
1516 if (acn_tree.copies()) {
1517 obj.map_acp[ 'acn_' + acn_tree.id() ] = acn_tree;
1518 node.setAttribute('container','true');
1520 if (document.getElementById('show_acps').checked) {
1521 node.setAttribute('open','true');
1522 obj.funcs.push( function() { obj.on_select_acn( acn_tree.id() ); } );
1531 'append_acp' : function( acp_item, acn_tree, params ) {
1534 if (obj.map_tree[ 'acp_' + acp_item.id() ]) {
1535 var x = obj.map_tree[ 'acp_' + acp_item.id() ];
1537 for (var i in params) {
1538 x.setAttribute(i,params[i]);
1544 var parent_node = obj.map_tree[ 'acn_' + acn_tree.id() ];
1548 'doc_id' : obj.docid,
1549 'aou' : obj.data.hash.aou[ acn_tree.owning_lib() ],
1553 acp_item.circulations()
1555 acp_item.circulations().length > 0
1556 ? acp_item.circulations()[0]
1560 'volume_count' : '',
1564 'retrieve_id' : 'acp_' + acp_item.id(),
1565 'node' : parent_node,
1567 'no_auto_select' : true,
1569 var nparams = obj.list.append(data);
1570 var node = nparams.my_node;
1571 obj.map_tree[ 'acp_' + acp_item.id() ] = node;
1573 for (var i in params) {
1574 node.setAttribute(i,params[i]);
1584 'list_init' : function( params ) {
1587 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1590 JSAN.use('circ.util');
1593 'id' : 'tree_location',
1594 'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.tree_location'),
1595 'flex' : 1, 'primary' : true, 'hidden' : false,
1596 'render' : function(my) { return my.acp ? my.acp.barcode() : my.acn ? my.acn.label() : my.aou ? my.aou.shortname() + " : " + my.aou.name() : "???"; },
1599 'id' : 'volume_count',
1600 'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.volume_count'),
1601 'flex' : 0, 'primary' : false, 'hidden' : false,
1602 'render' : function(my) { return my.volume_count; },
1605 'id' : 'copy_count',
1606 'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.copy_count'),
1608 'primary' : false, 'hidden' : false,
1609 'render' : function(my) { return my.copy_count; },
1614 'location' : { 'hidden' : false },
1615 'circ_lib' : { 'hidden' : false },
1616 'owning_lib' : { 'hidden' : false },
1617 'call_number' : { 'hidden' : false },
1618 'parts' : { 'hidden' : false },
1619 'due_date' : { 'hidden' : false },
1620 'acp_status' : { 'hidden' : false },
1648 'acp_mint_condition',
1654 JSAN.use('util.list'); obj.list = new util.list('copy_tree');
1657 'no_auto_select' : true,
1658 'columns' : columns,
1659 'map_row_to_columns' : circ.util.std_map_row_to_columns(' '),
1660 'retrieve_row' : function(params) {
1662 var row = params.row;
1665 if (!row.my.mvr) obj.funcs.push(
1668 row.my.mvr = obj.network.request(
1669 api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.app,
1670 api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.method,
1671 [ row.my.circ.target_copy() ]
1680 row.my.acp = obj.network.request(
1681 api.FM_ACP_RETRIEVE.app,
1682 api.FM_ACP_RETRIEVE.method,
1683 [ row.my.circ.target_copy() ]
1686 params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
1691 params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
1697 if (typeof params.on_retrieve == 'function') {
1698 params.on_retrieve(row);
1706 'on_click' : function(ev) {
1707 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserRead');
1708 var row = {}; var col = {}; var nobj = {};
1709 obj.list.node.treeBoxObject.getCellAt(ev.clientX,ev.clientY,row,col,nobj);
1710 if ((row.value == -1)||(nobj.value != 'twisty')) { return; }
1711 var node = obj.list.node.contentView.getItemAtIndex(row.value);
1712 var list = [ node.getAttribute('retrieve_id') ];
1713 if (typeof obj.on_select == 'function') {
1714 obj.on_select(list,true);
1716 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
1717 window.xulG.on_select(list);
1720 'on_select' : function(ev) {
1721 JSAN.use('util.functional');
1722 var sel = obj.list.retrieve_selection();
1723 obj.controller.view.sel_clip.disabled = sel.length < 1;
1724 obj.sel_list = util.functional.map_list(
1726 function(o) { return o.getAttribute('retrieve_id'); }
1728 obj.toggle_actions();
1729 if (typeof obj.on_select == 'function') {
1730 obj.on_select(obj.sel_list);
1732 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
1733 window.xulG.on_select(obj.sel_list);
1740 this.error.sdump('D_ERROR','cat.copy_browser.list_init: ' + E + '\n');
1745 'toggle_actions' : function() {
1748 var found_aou = false; var found_acn = false; var found_acp = false;
1749 var found_aou_with_can_have_vols = false;
1750 var sel_copy_libs = {};
1751 for (var i = 0; i < obj.sel_list.length; i++) {
1752 var type = obj.sel_list[i].split(/_/)[0];
1756 var org = obj.data.hash.aou[ obj.sel_list[i].split(/_/)[1] ];
1757 if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) found_aou_with_can_have_vols = true;
1759 case 'acn' : found_acn = true; break;
1765 obj.map_acp[obj.sel_list[i]].call_number()
1771 obj.controller.view.cmd_add_items.setAttribute('disabled','true');
1772 obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','true');
1773 obj.controller.view.cmd_edit_items.setAttribute('disabled','true');
1774 obj.controller.view.cmd_replace_barcode.setAttribute('disabled','true');
1775 obj.controller.view.cmd_delete_items.setAttribute('disabled','true');
1776 obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','true');
1777 obj.controller.view.cmd_add_volumes.setAttribute('disabled','true');
1778 obj.controller.view.cmd_mark_library.setAttribute('disabled','true');
1779 obj.controller.view.cmd_edit_volumes.setAttribute('disabled','true');
1780 obj.controller.view.cmd_delete_volumes.setAttribute('disabled','true');
1781 obj.controller.view.cmd_mark_volume.setAttribute('disabled','true');
1782 obj.controller.view.cmd_transfer_volume.setAttribute('disabled','true');
1783 obj.controller.view.cmd_transfer_items.setAttribute('disabled','true');
1784 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
1785 obj.controller.view.cmd_create_brt.setAttribute('disabled','true');
1786 obj.controller.view.cmd_book_item_now.setAttribute('disabled','true');
1787 obj.controller.view.sel_patron.setAttribute('disabled','true');
1788 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
1789 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
1790 if (found_aou && found_aou_with_can_have_vols) {
1791 obj.controller.view.cmd_add_volumes.setAttribute('disabled','false');
1792 obj.controller.view.cmd_mark_library.setAttribute('disabled','false');
1795 obj.controller.view.cmd_edit_volumes.setAttribute('disabled','false');
1796 obj.controller.view.cmd_delete_volumes.setAttribute('disabled','false');
1797 obj.controller.view.cmd_mark_volume.setAttribute('disabled','false');
1798 obj.controller.view.cmd_add_items.setAttribute('disabled','false');
1799 obj.controller.view.cmd_transfer_volume.setAttribute('disabled','false');
1802 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
1803 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
1804 obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','false');
1805 obj.controller.view.cmd_edit_items.setAttribute('disabled','false');
1806 obj.controller.view.cmd_replace_barcode.setAttribute('disabled','false');
1807 obj.controller.view.cmd_delete_items.setAttribute('disabled','false');
1808 obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','false');
1809 obj.controller.view.cmd_transfer_items.setAttribute('disabled','false');
1810 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
1811 obj.controller.view.cmd_create_brt.setAttribute('disabled','false');
1812 obj.controller.view.sel_patron.setAttribute('disabled','false');
1814 var L = 0; for (var k in sel_copy_libs) L++;
1816 obj.controller.view.cmd_book_item_now.setAttribute('disabled','false');
1820 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.actions.error'),E);
1824 'refresh_list' : function() {
1831 obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative',[ obj.docid ]);
1832 if (typeof obj.org_ids.ilsevent != 'undefined') throw(obj.org_ids);
1833 JSAN.use('util.functional');
1834 obj.org_ids = util.functional.map_list( obj.org_ids, function (o) { return Number(o); });
1835 obj.show_my_libs( obj.default_lib.id() );
1836 // FIXME - we get a null from the copy_count call if we call it too quickly here
1837 setTimeout( function() { obj.show_consortial_count(); }, 2000 );
1839 this.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.refresh_list.error'),E);
1844 dump('exiting cat.copy_browser.js\n');