1 dump('entering cat.copy_browser.js\n');
3 if (typeof cat == 'undefined') cat = {};
4 cat.copy_browser = function (params) {
6 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7 JSAN.use('util.error'); this.error = new util.error();
9 dump('cat.copy_browser: ' + E + '\n');
13 cat.copy_browser.prototype = {
20 'init' : function( params ) {
23 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
26 obj.docid = params.docid;
28 JSAN.use('util.network'); obj.network = new util.network();
29 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
30 JSAN.use('util.controller'); obj.controller = new util.controller();
34 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
37 function() { obj.list.clipboard(); }
41 function() { alert('Not Yet Implemented'); }
43 'cmd_show_my_libs' : [
49 'cmd_show_all_libs' : [
55 'cmd_show_libs_with_copies' : [
58 obj.show_libs_with_copies();
68 'sel_mark_items_damaged' : [
71 JSAN.use('cat.util'); JSAN.use('util.functional');
73 var list = util.functional.filter_list( obj.sel_list, function (o) { return o.split(/_/)[0] == 'acp'; });
75 list = util.functional.map_list( list, function (o) { return o.split(/_/)[1]; });
77 cat.util.mark_item_damaged( list );
82 'sel_mark_items_missing' : [
85 JSAN.use('cat.util'); JSAN.use('util.functional');
87 var list = util.functional.filter_list( obj.sel_list, function (o) { return o.split(/_/)[0] == 'acp'; });
89 list = util.functional.map_list( list, function (o) { return o.split(/_/)[1]; });
91 cat.util.mark_item_missing( list );
99 JSAN.use('util.functional');
101 var list = util.functional.filter_list(
104 return o.split(/_/)[0] == 'acp';
108 list = util.functional.map_list(
111 return { 'copy_id' : o.split(/_/)[1] };
115 JSAN.use('circ.util');
116 circ.util.show_last_few_circs(list);
119 'sel_copy_details' : [
122 JSAN.use('util.functional');
124 var list = util.functional.filter_list(
127 return o.split(/_/)[0] == 'acp';
131 list = util.functional.map_list(
134 return o.split(/_/)[1];
138 JSAN.use('circ.util');
139 for (var i = 0; i < list.length; i++) {
140 circ.util.show_copy_details( list[i] );
148 JSAN.use('util.functional');
149 var list = util.functional.map_list(
150 util.functional.filter_list(
153 return o.split(/_/)[0] == 'acn';
157 return o.split(/_/)[1];
160 if (list.length == 0) return;
162 var copy_shortcut = {};
163 list = util.functional.map_list(
166 var ou_id = obj.map_acn['acn_' + o].owning_lib();
168 var label = obj.map_acn['acn_' + o].label();
169 if (!copy_shortcut[ou_id]) copy_shortcut[ou_id] = {};
170 copy_shortcut[ou_id][ label ] = volume_id;
175 /* quick fix */ /* what was this fixing? */
176 list = []; for (var i in copy_shortcut) { list.push( i ); }
180 edit = obj.network.request(
181 api.PERM_MULTI_ORG_CHECK.app,
182 api.PERM_MULTI_ORG_CHECK.method,
185 obj.data.list.au[0].id(),
189 ).length == 0 ? 1 : 0;
191 obj.error.sdump('D_ERROR','batch permission check: ' + E);
194 if (edit==0) return; // no read-only view for this interface
196 var title = 'Add Item';
198 JSAN.use('util.window'); var win = new util.window();
200 window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR)
201 +'?doc_id=' + window.escape(obj.docid)
202 +'&ou_ids=' + window.escape( js2JSON(list) )
203 +'©_shortcut=' + window.escape( js2JSON(copy_shortcut) ),
207 w.refresh = function() { obj.refresh_list(); }
209 obj.error.standard_unexpected_error_alert('copy browser -> add copies',E);
213 'cmd_add_items_to_buckets' : [
217 JSAN.use('util.functional');
219 var list = util.functional.filter_list(
222 return o.split(/_/)[0] == 'acp';
226 list = util.functional.map_list(
229 return o.split(/_/)[1];
233 JSAN.use('cat.util');
234 cat.util.add_copies_to_bucket( list );
237 obj.error.standard_unexpected_error_alert('copy browser -> add copies to bucket',E);
241 'cmd_replace_barcode' : [
245 JSAN.use('util.functional');
247 var list = util.functional.filter_list(
250 return o.split(/_/)[0] == 'acp';
254 list = util.functional.map_list(
257 return obj.map_acp[ o ].barcode();
261 JSAN.use('cat.util');
262 for (var i = 0; i < list.length; i++) {
264 cat.util.replace_barcode(list[i]);
266 obj.error.standard_unexpected_error_alert('Barcode ' +list[i] + ' not likely replaced.',E);
272 obj.error.standard_unexpected_error_alert('copy browser -> replace barcode',E);
281 JSAN.use('util.functional');
283 var list = util.functional.filter_list(
286 return o.split(/_/)[0] == 'acp';
290 list = util.functional.map_list(
293 return o.split(/_/)[1];
299 edit = obj.network.request(
300 api.PERM_MULTI_ORG_CHECK.app,
301 api.PERM_MULTI_ORG_CHECK.method,
304 obj.data.list.au[0].id(),
305 util.functional.map_list(
308 var o_acp = obj.map_acp[ 'acp_' + o ];
309 if (o_acp.call_number() == -1) {
310 return o_acp.circ_lib();
312 return obj.map_acn[ 'acn_' + o_acp.call_number() ].owning_lib();
316 list.length == 1 ? [ 'UPDATE_COPY' ] : [ 'UPDATE_COPY', 'UPDATE_BATCH_COPY' ]
318 ).length == 0 ? 1 : 0;
320 obj.error.sdump('D_ERROR','batch permission check: ' + E);
323 JSAN.use('cat.util'); cat.util.spawn_copy_editor(list,edit);
327 obj.error.standard_unexpected_error_alert('Copy Browser -> Edit Items',E);
331 'cmd_delete_items' : [
335 JSAN.use('util.functional');
337 var list = util.functional.filter_list(
340 return o.split(/_/)[0] == 'acp';
344 list = util.functional.map_list(
347 return JSON2js( js2JSON( obj.map_acp[ 'acp_' + o.split(/_/)[1] ] ) );
351 var r = obj.error.yns_alert('Are you sure you would like to delete ' + (list.length != 1 ? 'these ' + list.length + ' items' : 'this one item') + '?', 'Delete Items?', 'Delete', 'Cancel', null, 'Check here to confirm this action');
354 var acn_hash = {}; var acn_list = [];
355 for (var i = 0; i < list.length; i++) {
356 list[i].isdeleted('1');
357 var acn_id = list[i].call_number();
358 if ( ! acn_hash[ acn_id ] ) {
359 acn_hash[ acn_id ] = obj.map_acn[ 'acn_' + acn_id ];
360 acn_hash[ acn_id ].copies( [] );
362 var temp = acn_hash[ acn_id ].copies();
363 temp.push( list[i] );
364 acn_hash[ acn_id ].copies( temp );
366 for (var i in acn_hash) acn_list.push( acn_hash[i] );
367 var robj = obj.network.simple_request(
368 'FM_ACN_TREE_UPDATE',
369 [ ses(), acn_list, true ],
372 'title' : 'Override Delete Failure?',
373 'overridable_events' : [
374 1208 /* TITLE_LAST_COPY */,
375 1227 /* COPY_DELETE_WARNING */,
379 if (robj == null) throw(robj);
380 if (typeof robj.ilsevent != 'undefined') {
381 if ( (robj.ilsevent != 0) && (robj.ilsevent != 1227 /* COPY_DELETE_WARNING */) && (robj.ilsevent != 1208 /* TITLE_LAST_COPY */) ) throw(robj);
383 alert('Action complete.');
389 obj.error.standard_unexpected_error_alert('copy browser -> delete items',E);
394 'cmd_print_spine_labels' : [
398 JSAN.use('util.functional');
400 var list = util.functional.filter_list(
403 return o.split(/_/)[0] == 'acp';
407 list = util.functional.map_list(
410 return obj.map_acp[ o ];
414 obj.data.temp_barcodes_for_labels = util.functional.map_list( list, function(o){return o.barcode();}) ;
415 obj.data.stash('temp_barcodes_for_labels');
417 xulG.url_prefix( urls.XUL_SPINE_LABEL ),
418 { 'tab_name' : 'Spine Labels' },
422 obj.error.standard_unexpected_error_alert('copy browser -> Spine Labels',E);
426 'cmd_add_volumes' : [
430 JSAN.use('util.functional');
431 var list = util.functional.filter_list(
434 return o.split(/_/)[0] == 'aou';
437 list = util.functional.map_list(
440 return o.split(/_/)[1];
445 edit = obj.network.request(
446 api.PERM_MULTI_ORG_CHECK.app,
447 api.PERM_MULTI_ORG_CHECK.method,
450 obj.data.list.au[0].id(),
452 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
454 ).length == 0 ? 1 : 0;
456 obj.error.sdump('D_ERROR','batch permission check: ' + E);
460 alert("You don't have permission to add volumes to that library.");
461 return; // no read-only view for this interface
464 var title = 'Add Volume/Item';
466 JSAN.use('util.window'); var win = new util.window();
468 window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR)
469 +'?doc_id=' + window.escape(obj.docid)
470 +'&ou_ids=' + window.escape( js2JSON(list) ),
475 w.refresh = function() { obj.refresh_list() };
477 obj.error.standard_unexpected_error_alert('copy browser -> add volumes',E);
481 'cmd_edit_volumes' : [
485 JSAN.use('util.functional');
486 var list = util.functional.map_list(
487 util.functional.filter_list(
490 return o.split(/_/)[0] == 'acn';
494 return o.split(/_/)[1];
497 if (list.length == 0) return;
501 edit = obj.network.request(
502 api.PERM_MULTI_ORG_CHECK.app,
503 api.PERM_MULTI_ORG_CHECK.method,
506 obj.data.list.au[0].id(),
507 util.functional.map_list(
510 return obj.map_acn[ 'acn_' + o ].owning_lib();
515 ).length == 0 ? 1 : 0;
517 obj.error.sdump('D_ERROR','batch permission check: ' + E);
521 alert("You don't have permission to edit this volume.");
522 return; // no read-only view for this interface
525 list = util.functional.map_list(
528 var my_acn = obj.map_acn['acn_' + o];
529 return function(r){return r;}(my_acn);
533 var title = list.length == 1 ? 'Volume' : 'Volumes';
535 JSAN.use('util.window'); var win = new util.window();
536 obj.data.volumes_temp = js2JSON( list );
537 obj.data.stash('volumes_temp');
539 window.xulG.url_prefix(urls.XUL_VOLUME_EDITOR),
541 'chrome,modal,resizable'
544 /* FIXME -- need to unique the temp space, and not rely on modalness of window */
545 obj.data.stash_retrieve();
546 var volumes = JSON2js( obj.data.volumes_temp );
547 obj.error.sdump('D_CAT','in browse, obj.data.temp =\n' + obj.data.temp);
548 if (volumes=='') return;
550 volumes = util.functional.filter_list(
553 return o.ischanged() == '1';
557 volumes = util.functional.map_list(
560 o.record( obj.docid ); // staff client 2 did not do this. Does it matter?
565 if (volumes.length == 0) return;
568 var r = obj.network.request(
569 api.FM_ACN_TREE_UPDATE.app,
570 api.FM_ACN_TREE_UPDATE.method,
571 [ ses(), volumes, true ]
573 if (typeof r.ilsevent != 'undefined') throw(r);
574 alert('Volumes modified.');
576 obj.error.standard_unexpected_error_alert('volume update error: ',E);
581 obj.error.standard_unexpected_error_alert('Copy Browser -> Volume Edit',E);
585 'cmd_delete_volumes' : [
589 JSAN.use('util.functional');
591 var list = util.functional.filter_list(
594 return o.split(/_/)[0] == 'acn';
598 list = util.functional.map_list(
601 return JSON2js( js2JSON( obj.map_acn[ 'acn_' + o.split(/_/)[1] ] ) );
605 var r = obj.error.yns_alert('Are you sure you would like to delete ' + (list.length != 1 ? 'these ' + list.length + ' volumes' : 'this one volume') + '?', 'Delete Volumes?', 'Delete', 'Cancel', null, 'Check here to confirm this action');
608 for (var i = 0; i < list.length; i++) {
609 list[i].isdeleted('1');
611 var robj = obj.network.simple_request(
612 'FM_ACN_TREE_UPDATE',
613 [ ses(), list, true ],
616 'title' : 'Override Delete Failure?',
617 'overridable_events' : [
621 if (robj == null) throw(robj);
622 if (typeof robj.ilsevent != 'undefined') {
623 if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
624 alert('You must delete all the copies on the volume before you may delete the volume itself.');
627 if (robj.ilsevent != 0) throw(robj);
629 alert('Volumes deleted.');
633 obj.error.standard_unexpected_error_alert('copy browser -> delete volumes',E);
639 'cmd_mark_library' : [
643 var list = util.functional.filter_list(
646 return o.split(/_/)[0] == 'aou';
650 list = util.functional.map_list(
653 return o.split(/_/)[1];
657 if (list.length == 1) {
658 obj.data.marked_library = { 'lib' : list[0], 'docid' : obj.docid };
659 obj.data.stash('marked_library');
660 alert('Library + Record marked as Volume Transfer Destination');
662 obj.error.yns_alert('Choose just one Library to mark as Volume Transfer Destination','Limit Selection','OK',null,null,'Check here to confirm this dialog');
665 obj.error.standard_unexpected_error_alert('copy browser -> mark library',E);
670 'cmd_mark_volume' : [
674 var list = util.functional.filter_list(
677 return o.split(/_/)[0] == 'acn';
681 list = util.functional.map_list(
684 return o.split(/_/)[1];
688 if (list.length == 1) {
689 obj.data.marked_volume = list[0];
690 obj.data.stash('marked_volume');
691 alert('Volume marked as Item Transfer Destination');
693 obj.error.yns_alert('Choose just one Volume to mark as Item Transfer Destination','Limit Selection','OK',null,null,'Check here to confirm this dialog');
696 obj.error.standard_unexpected_error_alert('copy browser -> mark volume',E);
700 'cmd_refresh_list' : [
706 'cmd_transfer_volume' : [
710 obj.data.stash_retrieve();
711 if (!obj.data.marked_library) {
712 alert('Please mark a library as the destination from within holdings maintenance and then try this again.');
716 JSAN.use('util.functional');
718 var list = util.functional.filter_list(
721 return o.split(/_/)[0] == 'acn';
725 list = util.functional.map_list(
728 return o.split(/_/)[1];
732 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
733 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: auto">';
734 xml += '<description>Transfer volumes ';
736 xml += util.functional.map_list(
739 return obj.map_acn[ 'acn_' + o ].label();
743 xml += ' to library ' + obj.data.hash.aou[ obj.data.marked_library.lib ].shortname();
744 xml += ' on the following record?</description>';
745 xml += '<hbox><button label="Transfer" name="fancy_submit"/>';
746 xml += '<button label="Cancel" accesskey="C" name="fancy_cancel"/></hbox>';
747 xml += '<iframe style="overflow: scroll" flex="1" src="' + urls.XUL_BIB_BRIEF + '?docid=' + obj.data.marked_library.docid + '"/>';
749 JSAN.use('OpenILS.data');
750 var data = new OpenILS.data(); data.init({'via':'stash'});
751 data.temp_transfer = xml; data.stash('temp_transfer');
753 urls.XUL_FANCY_PROMPT
754 + '?xml_in_stash=temp_transfer'
755 + '&title=' + window.escape('Volume Transfer'),
756 'fancy_prompt', 'chrome,resizable,modal,width=500,height=300'
758 data.init({'via':'stash'});
760 if (data.fancy_prompt_data == '') { alert('Transfer Aborted'); return; }
762 var robj = obj.network.simple_request(
764 [ ses(), { 'docid' : obj.data.marked_library.docid, 'lib' : obj.data.marked_library.lib, 'volumes' : list } ],
767 'title' : 'Override Volume Transfer Failure?',
768 'overridable_events' : [
769 1208 /* TITLE_LAST_COPY */,
770 1219 /* COPY_REMOTE_CIRC_LIB */,
775 if (typeof robj.ilsevent != 'undefined') {
776 if (robj.ilsevent == 1221 /* ORG_CANNOT_HAVE_VOLS */) {
777 alert('That destination cannot have volumes.');
782 alert('Volumes transferred.');
786 obj.error.standard_unexpected_error_alert('All volumes not likely transferred.',E);
792 'cmd_transfer_items' : [
796 obj.data.stash_retrieve();
797 if (!obj.data.marked_volume) {
798 alert('Please mark a volume as the destination from within holdings maintenance and then try this again.');
802 JSAN.use('util.functional');
804 var list = util.functional.filter_list(
807 return o.split(/_/)[0] == 'acp';
811 list = util.functional.map_list(
814 return o.split(/_/)[1];
818 var volume = obj.network.simple_request('FM_ACN_RETRIEVE',[ obj.data.marked_volume ]);
820 JSAN.use('cat.util'); cat.util.transfer_copies( {
822 'docid' : volume.record(),
823 'volume_label' : volume.label(),
824 'owning_lib' : volume.owning_lib(),
828 obj.error.standard_unexpected_error_alert('All copies not likely transferred.',E);
837 obj.list_init(params);
839 obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID',[ obj.docid ]);
840 if (typeof obj.org_ids.ilsevent != 'undefined') throw(obj.org_ids);
842 var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
843 //obj.show_libs( org );
845 //obj.show_my_libs();
847 JSAN.use('util.file'); JSAN.use('util.widgets');
849 var file; var list_data; var ml;
851 file = new util.file('offline_ou_list');
852 if (file._file.exists()) {
853 list_data = file.get_object(); file.close();
854 ml = util.widgets.make_menulist( list_data[0], list_data[1] );
855 ml.setAttribute('id','lib_menu'); document.getElementById('x_lib_menu').appendChild(ml);
856 for (var i = 0; i < obj.org_ids.length; i++) {
857 ml.getElementsByAttribute('value',obj.org_ids[i])[0].setAttribute('class','has_copies');
859 ml.firstChild.addEventListener(
862 document.getElementById('legend').setAttribute('hidden','false');
866 ml.firstChild.addEventListener(
869 document.getElementById('legend').setAttribute('hidden','true');
876 //obj.show_my_libs(ev.target.value);
877 JSAN.use('util.file'); var file = new util.file('copy_browser_prefs');
878 util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
884 throw('Missing library list.\n');
887 JSAN.use('util.widgets');
889 file = new util.file('copy_browser_prefs');
890 util.widgets.load_attributes(file);
891 ml.value = ml.getAttribute('value');
893 document.getElementById('show_acns').addEventListener(
896 JSAN.use('util.file'); var file = new util.file('copy_browser_prefs');
897 util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
902 document.getElementById('show_acps').addEventListener(
905 JSAN.use('util.file'); var file = new util.file('copy_browser_prefs');
906 util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
911 obj.show_my_libs( ml.value );
914 this.error.standard_unexpected_error_alert('cat.copy_browser.init: ',E);
918 'show_my_libs' : function(org) {
922 org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
924 if (typeof org != 'object') org = obj.data.hash.aou[ org ];
926 obj.show_libs( org, true );
928 var p_org = obj.data.hash.aou[ org.parent_ou() ];
930 JSAN.use('util.exec'); var exec = new util.exec();
932 funcs.push( function() {
933 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
934 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
935 document.getElementById('lib_menu').setAttribute('disabled','true');
937 for (var i = 0; i < p_org.children().length; i++) {
941 obj.show_libs( o, true );
943 }( p_org.children()[i] )
946 funcs.push( function() {
947 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
948 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
949 document.getElementById('lib_menu').setAttribute('disabled','false');
958 'show_all_libs' : function() {
963 obj.show_libs( obj.data.tree.aou );
965 JSAN.use('util.exec'); var exec = new util.exec();
967 funcs.push( function() {
968 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
969 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
970 document.getElementById('lib_menu').setAttribute('disabled','true');
973 for (var i = 0; i < obj.data.tree.aou.children().length; i++) {
979 }( obj.data.tree.aou.children()[i] )
982 funcs.push( function() {
983 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
984 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
985 document.getElementById('lib_menu').setAttribute('disabled','false');
994 'show_libs_with_copies' : function() {
997 JSAN.use('util.exec'); var exec = new util.exec();
998 JSAN.use('util.functional');
1000 var orgs = util.functional.map_list(
1002 function(id) { return obj.data.hash.aou[id]; }
1005 if (a.shortname() < b.shortname()) return -1;
1006 if (a.shortname() > b.shortname()) return 1;
1011 funcs.push( function() {
1012 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1013 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1014 document.getElementById('lib_menu').setAttribute('disabled','true');
1017 for (var i = 0; i < orgs.length; i++) {
1021 obj.show_libs(o,true);
1026 funcs.push( function() {
1027 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1028 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1029 document.getElementById('lib_menu').setAttribute('disabled','false');
1032 exec.chain( funcs );
1038 'show_libs' : function(start_aou,show_open) {
1041 if (!start_aou) throw('show_libs: Need a start_aou');
1042 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1043 JSAN.use('util.functional'); JSAN.use('util.exec'); var exec = new util.exec();
1048 var temp_aou = start_aou;
1049 while ( temp_aou.parent_ou() ) {
1050 temp_aou = obj.data.hash.aou[ temp_aou.parent_ou() ];
1051 parents.push( temp_aou );
1055 for (var i = 0; i < parents.length; i++) {
1060 obj.append_org(o,p,{'container':'true','open':'true'});
1062 obj.append_org(o,p,{'container':'true'});
1065 }(parents[i], obj.data.hash.aou[ parents[i].parent_ou() ])
1071 return function() { obj.append_org(o,p); };
1072 }(start_aou,obj.data.hash.aou[ start_aou.parent_ou() ])
1077 if (start_aou.children()) {
1078 var x = obj.map_tree[ 'aou_' + start_aou.id() ];
1079 x.setAttribute('container','true');
1080 if (show_open) x.setAttribute('open','true');
1081 for (var i = 0; i < start_aou.children().length; i++) {
1084 return function() { obj.append_org(o,p); };
1085 }( start_aou.children()[i], start_aou )
1092 exec.chain( funcs );
1099 'on_select' : function(list,twisty) {
1101 for (var i = 0; i < list.length; i++) {
1102 var node = obj.map_tree[ list[i] ];
1103 //if (node.lastChild.nodeName == 'treechildren') { continue; } else { alert(node.lastChild.nodeName); }
1104 var row_type = list[i].split('_')[0];
1105 var id = list[i].split('_')[1];
1107 case 'aou' : obj.on_select_org(id,twisty); break;
1108 case 'acn' : obj.on_select_acn(id,twisty); break;
1114 'on_select_acn' : function(acn_id,twisty) {
1117 var acn_tree = obj.map_acp[ 'acn_' + acn_id ];
1119 funcs.push( function() {
1120 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1121 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1122 document.getElementById('lib_menu').setAttribute('disabled','true');
1124 if (acn_tree.copies()) {
1125 for (var i = 0; i < acn_tree.copies().length; i++) {
1129 obj.append_acp(c,a);
1131 }( acn_tree.copies()[i], acn_tree )
1135 funcs.push( function() {
1136 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1137 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1138 document.getElementById('lib_menu').setAttribute('disabled','false');
1140 JSAN.use('util.exec'); var exec = new util.exec();
1141 exec.chain( funcs );
1147 'on_select_org' : function(org_id,twisty) {
1149 var org = obj.data.hash.aou[ org_id ];
1150 if (obj.data.hash.aout[ org.ou_type() ].depth() == 0) return;
1151 /* otherwise, we'd show every system in the consortia */
1153 funcs.push( function() {
1154 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1155 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1156 document.getElementById('lib_menu').setAttribute('disabled','true');
1158 if (org.children()) {
1159 for (var i = 0; i < org.children().length; i++) {
1165 }(org.children()[i],org)
1169 if (obj.map_acn[ 'aou_' + org_id ]) {
1170 for (var i = 0; i < obj.map_acn[ 'aou_' + org_id ].length; i++) {
1174 obj.append_acn(o,a);
1176 }( org, obj.map_acn[ 'aou_' + org_id ][i] )
1180 funcs.push( function() {
1181 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1182 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1183 document.getElementById('lib_menu').setAttribute('disabled','false');
1185 JSAN.use('util.exec'); var exec = new util.exec();
1186 exec.chain( funcs );
1189 'append_org' : function (org,parent_org,params) {
1192 if (obj.map_tree[ 'aou_' + org.id() ]) {
1193 var x = obj.map_tree[ 'aou_' + org.id() ];
1195 for (var i in params) {
1196 x.setAttribute(i,params[i]);
1208 'skip_all_columns_except' : [0,1,2],
1209 'retrieve_id' : 'aou_' + org.id(),
1214 if ( obj.org_ids.indexOf( org.id() ) == -1 ) {
1215 if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) {
1216 data.row.my.volume_count = '0';
1217 data.row.my.copy_count = '<0>';
1219 data.row.my.volume_count = '';
1220 data.row.my.copy_count = '';
1223 var v_count = 0; var c_count = 0;
1224 acn_tree_list = obj.network.simple_request(
1225 'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS',
1226 [ ses(), obj.docid, [ org.id() ] ]
1228 for (var i = 0; i < acn_tree_list.length; i++) {
1230 obj.map_acn[ 'acn_' + acn_tree_list[i].id() ] = function(r){return r;}(acn_tree_list[i]);
1231 var copies = acn_tree_list[i].copies(); if (copies) c_count += copies.length;
1232 for (var j = 0; j < copies.length; j++) {
1233 obj.map_acp[ 'acp_' + copies[j].id() ] = function(r){return r;}(copies[j]);
1236 data.row.my.volume_count = v_count;
1237 data.row.my.copy_count = '<' + c_count + '>';
1240 data.node = obj.map_tree[ 'aou_' + parent_org.id() ];
1242 var node = obj.list.append(data);
1244 for (var i in params) {
1245 node.setAttribute(i,params[i]);
1248 obj.map_tree[ 'aou_' + org.id() ] = node;
1250 if (org.children()) {
1251 node.setAttribute('container','true');
1255 if ( obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].parent_ou() == parent_org.id() ) {
1256 data.node.setAttribute('open','true');
1259 obj.map_tree[ 'aou_' + org.id() ].setAttribute('open','true');
1262 if (acn_tree_list) {
1263 obj.map_acn[ 'aou_' + org.id() ] = acn_tree_list;
1264 node.setAttribute('container','true');
1267 if (document.getElementById('show_acns').checked) {
1268 if ( obj.data.hash.aout[ org.ou_type() ].depth() != 0 ) {
1269 node.setAttribute('open','true');
1270 setTimeout( function() { obj.on_select_org( org.id() ); }, 0 );
1280 'append_acn' : function( org, acn_tree, params ) {
1283 if (obj.map_tree[ 'acn_' + acn_tree.id() ]) {
1284 var x = obj.map_tree[ 'acn_' + acn_tree.id() ];
1286 for (var i in params) {
1287 x.setAttribute(i,params[i]);
1293 var parent_node = obj.map_tree[ 'aou_' + org.id() ];
1299 'volume_count' : '',
1300 'copy_count' : acn_tree.copies() ? acn_tree.copies().length : '0',
1303 'skip_all_columns_except' : [0,1,2],
1304 'retrieve_id' : 'acn_' + acn_tree.id(),
1305 'node' : parent_node,
1308 var node = obj.list.append(data);
1309 obj.map_tree[ 'acn_' + acn_tree.id() ] = node;
1311 for (var i in params) {
1312 node.setAttribute(i,params[i]);
1315 if (acn_tree.copies()) {
1316 obj.map_acp[ 'acn_' + acn_tree.id() ] = acn_tree;
1317 node.setAttribute('container','true');
1319 if (document.getElementById('show_acps').checked) {
1320 node.setAttribute('open','true');
1321 setTimeout( function() { obj.on_select_acn( acn_tree.id() ); }, 0 );
1330 'append_acp' : function( acp_item, acn_tree, params ) {
1333 if (obj.map_tree[ 'acp_' + acp_item.id() ]) {
1334 var x = obj.map_tree[ 'acp_' + acp_item.id() ];
1336 for (var i in params) {
1337 x.setAttribute(i,params[i]);
1343 var parent_node = obj.map_tree[ 'acn_' + acn_tree.id() ];
1347 'aou' : obj.data.hash.aou[ acn_tree.owning_lib() ],
1350 'volume_count' : '',
1354 'retrieve_id' : 'acp_' + acp_item.id(),
1355 'node' : parent_node,
1358 var node = obj.list.append(data);
1359 obj.map_tree[ 'acp_' + acp_item.id() ] = node;
1361 for (var i in params) {
1362 node.setAttribute(i,params[i]);
1372 'list_init' : function( params ) {
1375 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1378 JSAN.use('circ.util');
1381 'id' : 'tree_location', 'label' : 'Location/Barcode', 'flex' : 1,
1382 'primary' : true, 'hidden' : false,
1383 'render' : function(my) { return my.acp ? my.acp.barcode() : my.acn ? my.acn.label() : my.aou ? my.aou.shortname() + " : " + my.aou.name() : "???"; },
1386 'id' : 'volume_count', 'label' : 'Volumes', 'flex' : 0,
1387 'primary' : false, 'hidden' : false,
1388 'render' : function(my) { return my.volume_count; },
1391 'id' : 'copy_count', 'label' : 'Copies', 'flex' : 0,
1392 'primary' : false, 'hidden' : false,
1393 'render' : function(my) { return my.copy_count; },
1398 'location' : { 'hidden' : false },
1399 'circ_lib' : { 'hidden' : false },
1400 'owning_lib' : { 'hidden' : false },
1401 'call_number' : { 'hidden' : false },
1402 'due_date' : { 'hidden' : false },
1403 'status' : { 'hidden' : false },
1432 JSAN.use('util.list'); obj.list = new util.list('copy_tree');
1435 'columns' : columns,
1436 'map_row_to_columns' : circ.util.std_map_row_to_columns(' '),
1437 'retrieve_row' : function(params) {
1439 var row = params.row;
1443 if (!row.my.mvr) funcs.push(
1446 row.my.mvr = obj.network.request(
1447 api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.app,
1448 api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.method,
1449 [ row.my.circ.target_copy() ]
1458 row.my.acp = obj.network.request(
1459 api.FM_ACP_RETRIEVE.app,
1460 api.FM_ACP_RETRIEVE.method,
1461 [ row.my.circ.target_copy() ]
1464 params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
1469 params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
1475 if (typeof params.on_retrieve == 'function') {
1476 params.on_retrieve(row);
1482 JSAN.use('util.exec'); var exec = new util.exec();
1483 exec.on_error = function(E) {
1484 var err = 'items chain: ' + js2JSON(E);
1485 obj.error.sdump('D_ERROR',err);
1486 return true; /* keep going */
1488 exec.chain( funcs );
1492 'on_click' : function(ev) {
1493 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserRead');
1494 var row = {}; var col = {}; var nobj = {};
1495 obj.list.node.treeBoxObject.getCellAt(ev.clientX,ev.clientY,row,col,nobj);
1496 if ((row.value == -1)||(nobj.value != 'twisty')) { return; }
1497 var node = obj.list.node.contentView.getItemAtIndex(row.value);
1498 var list = [ node.getAttribute('retrieve_id') ];
1499 if (typeof obj.on_select == 'function') {
1500 obj.on_select(list,true);
1502 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
1503 window.xulG.on_select(list);
1506 'on_select' : function(ev) {
1507 JSAN.use('util.functional');
1508 var sel = obj.list.retrieve_selection();
1509 obj.controller.view.sel_clip.disabled = sel.length < 1;
1510 obj.sel_list = util.functional.map_list(
1512 function(o) { return o.getAttribute('retrieve_id'); }
1514 obj.toggle_actions();
1515 if (typeof obj.on_select == 'function') {
1516 obj.on_select(obj.sel_list);
1518 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
1519 window.xulG.on_select(obj.sel_list);
1525 obj.controller.render();
1528 this.error.sdump('D_ERROR','cat.copy_browser.list_init: ' + E + '\n');
1533 'toggle_actions' : function() {
1536 var found_aou = false; var found_acn = false; var found_acp = false;
1537 var found_aou_with_can_have_vols = false;
1538 for (var i = 0; i < obj.sel_list.length; i++) {
1539 var type = obj.sel_list[i].split(/_/)[0];
1543 var org = obj.data.hash.aou[ obj.sel_list[i].split(/_/)[1] ];
1544 if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) found_aou_with_can_have_vols = true;
1546 case 'acn' : found_acn = true; break;
1547 case 'acp' : found_acp = true; break;
1550 obj.controller.view.cmd_add_items.setAttribute('disabled','true');
1551 obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','true');
1552 obj.controller.view.cmd_edit_items.setAttribute('disabled','true');
1553 obj.controller.view.cmd_replace_barcode.setAttribute('disabled','true');
1554 obj.controller.view.cmd_delete_items.setAttribute('disabled','true');
1555 obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','true');
1556 obj.controller.view.cmd_add_volumes.setAttribute('disabled','true');
1557 obj.controller.view.cmd_mark_library.setAttribute('disabled','true');
1558 obj.controller.view.cmd_edit_volumes.setAttribute('disabled','true');
1559 obj.controller.view.cmd_delete_volumes.setAttribute('disabled','true');
1560 obj.controller.view.cmd_mark_volume.setAttribute('disabled','true');
1561 obj.controller.view.cmd_transfer_volume.setAttribute('disabled','true');
1562 obj.controller.view.cmd_transfer_items.setAttribute('disabled','true');
1563 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
1564 obj.controller.view.sel_patron.setAttribute('disabled','true');
1565 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
1566 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
1567 if (found_aou && found_aou_with_can_have_vols) {
1568 obj.controller.view.cmd_add_volumes.setAttribute('disabled','false');
1569 obj.controller.view.cmd_mark_library.setAttribute('disabled','false');
1572 obj.controller.view.cmd_edit_volumes.setAttribute('disabled','false');
1573 obj.controller.view.cmd_delete_volumes.setAttribute('disabled','false');
1574 obj.controller.view.cmd_mark_volume.setAttribute('disabled','false');
1575 obj.controller.view.cmd_add_items.setAttribute('disabled','false');
1576 obj.controller.view.cmd_transfer_volume.setAttribute('disabled','false');
1579 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
1580 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
1581 obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','false');
1582 obj.controller.view.cmd_edit_items.setAttribute('disabled','false');
1583 obj.controller.view.cmd_replace_barcode.setAttribute('disabled','false');
1584 obj.controller.view.cmd_delete_items.setAttribute('disabled','false');
1585 obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','false');
1586 obj.controller.view.cmd_transfer_items.setAttribute('disabled','false');
1587 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
1588 obj.controller.view.sel_patron.setAttribute('disabled','false');
1591 obj.error.standard_unexpected_error_alert('Copy Browser Actions',E);
1595 'refresh_list' : function() {
1602 obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID',[ obj.docid ]);
1604 var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
1605 obj.show_libs( org );
1607 obj.show_my_libs( document.getElementById('lib_menu').value );
1609 this.error.standard_unexpected_error_alert('Problem refreshing the volume/copy tree.',E);
1614 dump('exiting cat.copy_browser.js\n');