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 */
378 if (robj == null) throw(robj);
379 if (typeof robj.ilsevent != 'undefined') {
380 if ( (robj.ilsevent != 0) && (robj.ilsevent != 1208 /* TITLE_LAST_COPY */) ) throw(robj);
382 alert('Action complete.');
388 obj.error.standard_unexpected_error_alert('copy browser -> delete items',E);
393 'cmd_print_spine_labels' : [
397 JSAN.use('util.functional');
399 var list = util.functional.filter_list(
402 return o.split(/_/)[0] == 'acp';
406 list = util.functional.map_list(
409 return obj.map_acp[ o ];
413 obj.data.temp_barcodes_for_labels = util.functional.map_list( list, function(o){return o.barcode();}) ;
414 obj.data.stash('temp_barcodes_for_labels');
416 xulG.url_prefix( urls.XUL_SPINE_LABEL ),
417 { 'tab_name' : 'Spine Labels' },
421 obj.error.standard_unexpected_error_alert('copy browser -> Spine Labels',E);
425 'cmd_add_volumes' : [
429 JSAN.use('util.functional');
430 var list = util.functional.filter_list(
433 return o.split(/_/)[0] == 'aou';
436 list = util.functional.map_list(
439 return o.split(/_/)[1];
444 edit = obj.network.request(
445 api.PERM_MULTI_ORG_CHECK.app,
446 api.PERM_MULTI_ORG_CHECK.method,
449 obj.data.list.au[0].id(),
451 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
453 ).length == 0 ? 1 : 0;
455 obj.error.sdump('D_ERROR','batch permission check: ' + E);
459 alert("You don't have permission to add volumes to that library.");
460 return; // no read-only view for this interface
463 var title = 'Add Volume/Item';
465 JSAN.use('util.window'); var win = new util.window();
467 window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR)
468 +'?doc_id=' + window.escape(obj.docid)
469 +'&ou_ids=' + window.escape( js2JSON(list) ),
474 w.refresh = function() { obj.refresh_list() };
476 obj.error.standard_unexpected_error_alert('copy browser -> add volumes',E);
480 'cmd_edit_volumes' : [
484 JSAN.use('util.functional');
485 var list = util.functional.map_list(
486 util.functional.filter_list(
489 return o.split(/_/)[0] == 'acn';
493 return o.split(/_/)[1];
496 if (list.length == 0) return;
500 edit = obj.network.request(
501 api.PERM_MULTI_ORG_CHECK.app,
502 api.PERM_MULTI_ORG_CHECK.method,
505 obj.data.list.au[0].id(),
506 util.functional.map_list(
509 return obj.map_acn[ 'acn_' + o ].owning_lib();
514 ).length == 0 ? 1 : 0;
516 obj.error.sdump('D_ERROR','batch permission check: ' + E);
520 alert("You don't have permission to edit this volume.");
521 return; // no read-only view for this interface
524 list = util.functional.map_list(
527 var my_acn = obj.map_acn['acn_' + o];
528 return function(r){return r;}(my_acn);
532 var title = list.length == 1 ? 'Volume' : 'Volumes';
534 JSAN.use('util.window'); var win = new util.window();
535 obj.data.volumes_temp = js2JSON( list );
536 obj.data.stash('volumes_temp');
538 window.xulG.url_prefix(urls.XUL_VOLUME_EDITOR),
540 'chrome,modal,resizable'
543 /* FIXME -- need to unique the temp space, and not rely on modalness of window */
544 obj.data.stash_retrieve();
545 var volumes = JSON2js( obj.data.volumes_temp );
546 obj.error.sdump('D_CAT','in browse, obj.data.temp =\n' + obj.data.temp);
547 if (volumes=='') return;
549 volumes = util.functional.filter_list(
552 return o.ischanged() == '1';
556 volumes = util.functional.map_list(
559 o.record( obj.docid ); // staff client 2 did not do this. Does it matter?
564 if (volumes.length == 0) return;
567 var r = obj.network.request(
568 api.FM_ACN_TREE_UPDATE.app,
569 api.FM_ACN_TREE_UPDATE.method,
570 [ ses(), volumes, true ]
572 if (typeof r.ilsevent != 'undefined') throw(r);
573 alert('Volumes modified.');
575 obj.error.standard_unexpected_error_alert('volume update error: ',E);
580 obj.error.standard_unexpected_error_alert('Copy Browser -> Volume Edit',E);
584 'cmd_delete_volumes' : [
588 JSAN.use('util.functional');
590 var list = util.functional.filter_list(
593 return o.split(/_/)[0] == 'acn';
597 list = util.functional.map_list(
600 return JSON2js( js2JSON( obj.map_acn[ 'acn_' + o.split(/_/)[1] ] ) );
604 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');
607 for (var i = 0; i < list.length; i++) {
608 list[i].isdeleted('1');
610 var robj = obj.network.simple_request(
611 'FM_ACN_TREE_UPDATE',
612 [ ses(), list, true ],
615 'title' : 'Override Delete Failure?',
616 'overridable_events' : [
620 if (robj == null) throw(robj);
621 if (typeof robj.ilsevent != 'undefined') {
622 if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
623 alert('You must delete all the copies on the volume before you may delete the volume itself.');
626 if (robj.ilsevent != 0) throw(robj);
628 alert('Volumes deleted.');
632 obj.error.standard_unexpected_error_alert('copy browser -> delete volumes',E);
638 'cmd_mark_library' : [
642 var list = util.functional.filter_list(
645 return o.split(/_/)[0] == 'aou';
649 list = util.functional.map_list(
652 return o.split(/_/)[1];
656 if (list.length == 1) {
657 obj.data.marked_library = { 'lib' : list[0], 'docid' : obj.docid };
658 obj.data.stash('marked_library');
659 alert('Library + Record marked as Volume Transfer Destination');
661 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');
664 obj.error.standard_unexpected_error_alert('copy browser -> mark library',E);
669 'cmd_mark_volume' : [
673 var list = util.functional.filter_list(
676 return o.split(/_/)[0] == 'acn';
680 list = util.functional.map_list(
683 return o.split(/_/)[1];
687 if (list.length == 1) {
688 obj.data.marked_volume = list[0];
689 obj.data.stash('marked_volume');
690 alert('Volume marked as Item Transfer Destination');
692 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');
695 obj.error.standard_unexpected_error_alert('copy browser -> mark volume',E);
699 'cmd_refresh_list' : [
705 'cmd_transfer_volume' : [
709 obj.data.stash_retrieve();
710 if (!obj.data.marked_library) {
711 alert('Please mark a library as the destination from within holdings maintenance and then try this again.');
715 JSAN.use('util.functional');
717 var list = util.functional.filter_list(
720 return o.split(/_/)[0] == 'acn';
724 list = util.functional.map_list(
727 return o.split(/_/)[1];
731 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
732 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: auto">';
733 xml += '<description>Transfer volumes ';
735 xml += util.functional.map_list(
738 return obj.map_acn[ 'acn_' + o ].label();
742 xml += ' to library ' + obj.data.hash.aou[ obj.data.marked_library.lib ].shortname();
743 xml += ' on the following record?</description>';
744 xml += '<hbox><button label="Transfer" name="fancy_submit"/>';
745 xml += '<button label="Cancel" accesskey="C" name="fancy_cancel"/></hbox>';
746 xml += '<iframe style="overflow: scroll" flex="1" src="' + urls.XUL_BIB_BRIEF + '?docid=' + obj.data.marked_library.docid + '"/>';
748 JSAN.use('OpenILS.data');
749 var data = new OpenILS.data(); data.init({'via':'stash'});
750 data.temp_transfer = xml; data.stash('temp_transfer');
752 urls.XUL_FANCY_PROMPT
753 + '?xml_in_stash=temp_transfer'
754 + '&title=' + window.escape('Volume Transfer'),
755 'fancy_prompt', 'chrome,resizable,modal,width=500,height=300'
757 data.init({'via':'stash'});
759 if (data.fancy_prompt_data == '') { alert('Transfer Aborted'); return; }
761 var robj = obj.network.simple_request(
763 [ ses(), { 'docid' : obj.data.marked_library.docid, 'lib' : obj.data.marked_library.lib, 'volumes' : list } ],
766 'title' : 'Override Volume Transfer Failure?',
767 'overridable_events' : [
768 1208 /* TITLE_LAST_COPY */,
769 1219 /* COPY_REMOTE_CIRC_LIB */,
774 if (typeof robj.ilsevent != 'undefined') {
775 if (robj.ilsevent == 1221 /* ORG_CANNOT_HAVE_VOLS */) {
776 alert('That destination cannot have volumes.');
781 alert('Volumes transferred.');
785 obj.error.standard_unexpected_error_alert('All volumes not likely transferred.',E);
791 'cmd_transfer_items' : [
795 obj.data.stash_retrieve();
796 if (!obj.data.marked_volume) {
797 alert('Please mark a volume as the destination from within holdings maintenance and then try this again.');
801 JSAN.use('util.functional');
803 var list = util.functional.filter_list(
806 return o.split(/_/)[0] == 'acp';
810 list = util.functional.map_list(
813 return o.split(/_/)[1];
817 var volume = obj.network.simple_request('FM_ACN_RETRIEVE',[ obj.data.marked_volume ]);
819 JSAN.use('cat.util'); cat.util.transfer_copies( {
821 'docid' : volume.record(),
822 'volume_label' : volume.label(),
823 'owning_lib' : volume.owning_lib(),
827 obj.error.standard_unexpected_error_alert('All copies not likely transferred.',E);
836 obj.list_init(params);
838 obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID',[ obj.docid ]);
839 if (typeof obj.org_ids.ilsevent != 'undefined') throw(obj.org_ids);
841 var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
842 //obj.show_libs( org );
844 //obj.show_my_libs();
846 JSAN.use('util.file'); JSAN.use('util.widgets');
848 var file; var list_data; var ml;
850 file = new util.file('offline_ou_list');
851 if (file._file.exists()) {
852 list_data = file.get_object(); file.close();
853 ml = util.widgets.make_menulist( list_data[0], list_data[1] );
854 ml.setAttribute('id','lib_menu'); document.getElementById('x_lib_menu').appendChild(ml);
855 for (var i = 0; i < obj.org_ids.length; i++) {
856 ml.getElementsByAttribute('value',obj.org_ids[i])[0].setAttribute('class','has_copies');
858 ml.firstChild.addEventListener(
861 document.getElementById('legend').setAttribute('hidden','false');
865 ml.firstChild.addEventListener(
868 document.getElementById('legend').setAttribute('hidden','true');
875 //obj.show_my_libs(ev.target.value);
876 JSAN.use('util.file'); var file = new util.file('copy_browser_prefs');
877 util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
883 throw('Missing library list.\n');
886 JSAN.use('util.widgets');
888 file = new util.file('copy_browser_prefs');
889 util.widgets.load_attributes(file);
890 ml.value = ml.getAttribute('value');
892 document.getElementById('show_acns').addEventListener(
895 JSAN.use('util.file'); var file = new util.file('copy_browser_prefs');
896 util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
901 document.getElementById('show_acps').addEventListener(
904 JSAN.use('util.file'); var file = new util.file('copy_browser_prefs');
905 util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
910 obj.show_my_libs( ml.value );
913 this.error.standard_unexpected_error_alert('cat.copy_browser.init: ',E);
917 'show_my_libs' : function(org) {
921 org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
923 if (typeof org != 'object') org = obj.data.hash.aou[ org ];
925 obj.show_libs( org, true );
927 var p_org = obj.data.hash.aou[ org.parent_ou() ];
929 JSAN.use('util.exec'); var exec = new util.exec();
931 funcs.push( function() {
932 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
933 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
934 document.getElementById('lib_menu').setAttribute('disabled','true');
936 for (var i = 0; i < p_org.children().length; i++) {
940 obj.show_libs( o, true );
942 }( p_org.children()[i] )
945 funcs.push( function() {
946 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
947 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
948 document.getElementById('lib_menu').setAttribute('disabled','false');
957 'show_all_libs' : function() {
962 obj.show_libs( obj.data.tree.aou );
964 JSAN.use('util.exec'); var exec = new util.exec();
966 funcs.push( function() {
967 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
968 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
969 document.getElementById('lib_menu').setAttribute('disabled','true');
972 for (var i = 0; i < obj.data.tree.aou.children().length; i++) {
978 }( obj.data.tree.aou.children()[i] )
981 funcs.push( function() {
982 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
983 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
984 document.getElementById('lib_menu').setAttribute('disabled','false');
993 'show_libs_with_copies' : function() {
996 JSAN.use('util.exec'); var exec = new util.exec();
997 JSAN.use('util.functional');
999 var orgs = util.functional.map_list(
1001 function(id) { return obj.data.hash.aou[id]; }
1004 if (a.shortname() < b.shortname()) return -1;
1005 if (a.shortname() > b.shortname()) return 1;
1010 funcs.push( function() {
1011 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1012 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1013 document.getElementById('lib_menu').setAttribute('disabled','true');
1016 for (var i = 0; i < orgs.length; i++) {
1020 obj.show_libs(o,true);
1025 funcs.push( function() {
1026 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1027 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1028 document.getElementById('lib_menu').setAttribute('disabled','false');
1031 exec.chain( funcs );
1037 'show_libs' : function(start_aou,show_open) {
1040 if (!start_aou) throw('show_libs: Need a start_aou');
1041 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1042 JSAN.use('util.functional'); JSAN.use('util.exec'); var exec = new util.exec();
1047 var temp_aou = start_aou;
1048 while ( temp_aou.parent_ou() ) {
1049 temp_aou = obj.data.hash.aou[ temp_aou.parent_ou() ];
1050 parents.push( temp_aou );
1054 for (var i = 0; i < parents.length; i++) {
1059 obj.append_org(o,p,{'container':'true','open':'true'});
1061 obj.append_org(o,p,{'container':'true'});
1064 }(parents[i], obj.data.hash.aou[ parents[i].parent_ou() ])
1070 return function() { obj.append_org(o,p); };
1071 }(start_aou,obj.data.hash.aou[ start_aou.parent_ou() ])
1076 if (start_aou.children()) {
1077 var x = obj.map_tree[ 'aou_' + start_aou.id() ];
1078 x.setAttribute('container','true');
1079 if (show_open) x.setAttribute('open','true');
1080 for (var i = 0; i < start_aou.children().length; i++) {
1083 return function() { obj.append_org(o,p); };
1084 }( start_aou.children()[i], start_aou )
1091 exec.chain( funcs );
1098 'on_select' : function(list,twisty) {
1100 for (var i = 0; i < list.length; i++) {
1101 var node = obj.map_tree[ list[i] ];
1102 //if (node.lastChild.nodeName == 'treechildren') { continue; } else { alert(node.lastChild.nodeName); }
1103 var row_type = list[i].split('_')[0];
1104 var id = list[i].split('_')[1];
1106 case 'aou' : obj.on_select_org(id,twisty); break;
1107 case 'acn' : obj.on_select_acn(id,twisty); break;
1113 'on_select_acn' : function(acn_id,twisty) {
1116 var acn_tree = obj.map_acp[ 'acn_' + acn_id ];
1118 funcs.push( function() {
1119 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1120 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1121 document.getElementById('lib_menu').setAttribute('disabled','true');
1123 if (acn_tree.copies()) {
1124 for (var i = 0; i < acn_tree.copies().length; i++) {
1128 obj.append_acp(c,a);
1130 }( acn_tree.copies()[i], acn_tree )
1134 funcs.push( function() {
1135 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1136 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1137 document.getElementById('lib_menu').setAttribute('disabled','false');
1139 JSAN.use('util.exec'); var exec = new util.exec();
1140 exec.chain( funcs );
1146 'on_select_org' : function(org_id,twisty) {
1148 var org = obj.data.hash.aou[ org_id ];
1149 if (obj.data.hash.aout[ org.ou_type() ].depth() == 0) return;
1150 /* otherwise, we'd show every system in the consortia */
1152 funcs.push( function() {
1153 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1154 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1155 document.getElementById('lib_menu').setAttribute('disabled','true');
1157 if (org.children()) {
1158 for (var i = 0; i < org.children().length; i++) {
1164 }(org.children()[i],org)
1168 if (obj.map_acn[ 'aou_' + org_id ]) {
1169 for (var i = 0; i < obj.map_acn[ 'aou_' + org_id ].length; i++) {
1173 obj.append_acn(o,a);
1175 }( org, obj.map_acn[ 'aou_' + org_id ][i] )
1179 funcs.push( function() {
1180 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1181 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1182 document.getElementById('lib_menu').setAttribute('disabled','false');
1184 JSAN.use('util.exec'); var exec = new util.exec();
1185 exec.chain( funcs );
1188 'append_org' : function (org,parent_org,params) {
1191 if (obj.map_tree[ 'aou_' + org.id() ]) {
1192 var x = obj.map_tree[ 'aou_' + org.id() ];
1194 for (var i in params) {
1195 x.setAttribute(i,params[i]);
1207 'skip_all_columns_except' : [0,1,2],
1208 'retrieve_id' : 'aou_' + org.id(),
1212 if ( obj.org_ids.indexOf( org.id() ) == -1 ) {
1213 if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) {
1214 data.row.my.volume_count = '0';
1215 data.row.my.copy_count = '<0>';
1217 data.row.my.volume_count = '';
1218 data.row.my.copy_count = '';
1221 var v_count = 0; var c_count = 0;
1222 acn_tree_list = obj.network.simple_request(
1223 'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS',
1224 [ ses(), obj.docid, [ org.id() ] ]
1226 for (var i = 0; i < acn_tree_list.length; i++) {
1228 obj.map_acn[ 'acn_' + acn_tree_list[i].id() ] = function(r){return r;}(acn_tree_list[i]);
1229 var copies = acn_tree_list[i].copies(); if (copies) c_count += copies.length;
1230 for (var j = 0; j < copies.length; j++) {
1231 obj.map_acp[ 'acp_' + copies[j].id() ] = function(r){return r;}(copies[j]);
1234 data.row.my.volume_count = v_count;
1235 data.row.my.copy_count = '<' + c_count + '>';
1238 data.node = obj.map_tree[ 'aou_' + parent_org.id() ];
1240 var node = obj.list.append(data);
1242 for (var i in params) {
1243 node.setAttribute(i,params[i]);
1246 obj.map_tree[ 'aou_' + org.id() ] = node;
1248 if (org.children()) {
1249 node.setAttribute('container','true');
1253 if ( obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].parent_ou() == parent_org.id() ) {
1254 data.node.setAttribute('open','true');
1257 obj.map_tree[ 'aou_' + org.id() ].setAttribute('open','true');
1260 if (acn_tree_list) {
1261 obj.map_acn[ 'aou_' + org.id() ] = acn_tree_list;
1262 node.setAttribute('container','true');
1265 if (document.getElementById('show_acns').checked) {
1266 if ( obj.data.hash.aout[ org.ou_type() ].depth() != 0 ) {
1267 node.setAttribute('open','true');
1268 setTimeout( function() { obj.on_select_org( org.id() ); }, 0 );
1278 'append_acn' : function( org, acn_tree, params ) {
1281 if (obj.map_tree[ 'acn_' + acn_tree.id() ]) {
1282 var x = obj.map_tree[ 'acn_' + acn_tree.id() ];
1284 for (var i in params) {
1285 x.setAttribute(i,params[i]);
1291 var parent_node = obj.map_tree[ 'aou_' + org.id() ];
1297 'volume_count' : '',
1298 'copy_count' : acn_tree.copies() ? acn_tree.copies().length : '0',
1301 'skip_all_columns_except' : [0,1,2],
1302 'retrieve_id' : 'acn_' + acn_tree.id(),
1303 'node' : parent_node,
1305 var node = obj.list.append(data);
1306 obj.map_tree[ 'acn_' + acn_tree.id() ] = node;
1308 for (var i in params) {
1309 node.setAttribute(i,params[i]);
1312 if (acn_tree.copies()) {
1313 obj.map_acp[ 'acn_' + acn_tree.id() ] = acn_tree;
1314 node.setAttribute('container','true');
1316 if (document.getElementById('show_acps').checked) {
1317 node.setAttribute('open','true');
1318 setTimeout( function() { obj.on_select_acn( acn_tree.id() ); }, 0 );
1327 'append_acp' : function( acp_item, acn_tree, params ) {
1330 if (obj.map_tree[ 'acp_' + acp_item.id() ]) {
1331 var x = obj.map_tree[ 'acp_' + acp_item.id() ];
1333 for (var i in params) {
1334 x.setAttribute(i,params[i]);
1340 var parent_node = obj.map_tree[ 'acn_' + acn_tree.id() ];
1344 'aou' : obj.data.hash.aou[ acn_tree.owning_lib() ],
1347 'volume_count' : '',
1351 'retrieve_id' : 'acp_' + acp_item.id(),
1352 'node' : parent_node,
1354 var node = obj.list.append(data);
1355 obj.map_tree[ 'acp_' + acp_item.id() ] = node;
1357 for (var i in params) {
1358 node.setAttribute(i,params[i]);
1368 'list_init' : function( params ) {
1371 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1374 JSAN.use('circ.util');
1377 'id' : 'tree_location', 'label' : 'Location/Barcode', 'flex' : 1,
1378 'primary' : true, 'hidden' : false,
1379 'render' : function(my) { return my.acp ? my.acp.barcode() : my.acn ? my.acn.label() : my.aou ? my.aou.shortname() + " : " + my.aou.name() : "???"; },
1382 'id' : 'volume_count', 'label' : 'Volumes', 'flex' : 0,
1383 'primary' : false, 'hidden' : false,
1384 'render' : function(my) { return my.volume_count; },
1387 'id' : 'copy_count', 'label' : 'Copies', 'flex' : 0,
1388 'primary' : false, 'hidden' : false,
1389 'render' : function(my) { return my.copy_count; },
1394 'location' : { 'hidden' : false },
1395 'circ_lib' : { 'hidden' : false },
1396 'owning_lib' : { 'hidden' : false },
1397 'call_number' : { 'hidden' : false },
1398 'due_date' : { 'hidden' : false },
1399 'status' : { 'hidden' : false },
1428 JSAN.use('util.list'); obj.list = new util.list('copy_tree');
1431 'columns' : columns,
1432 'map_row_to_columns' : circ.util.std_map_row_to_columns(' '),
1433 'retrieve_row' : function(params) {
1435 var row = params.row;
1439 if (!row.my.mvr) funcs.push(
1442 row.my.mvr = obj.network.request(
1443 api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.app,
1444 api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.method,
1445 [ row.my.circ.target_copy() ]
1454 row.my.acp = obj.network.request(
1455 api.FM_ACP_RETRIEVE.app,
1456 api.FM_ACP_RETRIEVE.method,
1457 [ row.my.circ.target_copy() ]
1460 params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
1465 params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
1471 if (typeof params.on_retrieve == 'function') {
1472 params.on_retrieve(row);
1478 JSAN.use('util.exec'); var exec = new util.exec();
1479 exec.on_error = function(E) {
1480 var err = 'items chain: ' + js2JSON(E);
1481 obj.error.sdump('D_ERROR',err);
1482 return true; /* keep going */
1484 exec.chain( funcs );
1488 'on_click' : function(ev) {
1489 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserRead');
1490 var row = {}; var col = {}; var nobj = {};
1491 obj.list.node.treeBoxObject.getCellAt(ev.clientX,ev.clientY,row,col,nobj);
1492 if ((row.value == -1)||(nobj.value != 'twisty')) { return; }
1493 var node = obj.list.node.contentView.getItemAtIndex(row.value);
1494 var list = [ node.getAttribute('retrieve_id') ];
1495 if (typeof obj.on_select == 'function') {
1496 obj.on_select(list,true);
1498 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
1499 window.xulG.on_select(list);
1502 'on_select' : function(ev) {
1503 JSAN.use('util.functional');
1504 var sel = obj.list.retrieve_selection();
1505 obj.controller.view.sel_clip.disabled = sel.length < 1;
1506 obj.sel_list = util.functional.map_list(
1508 function(o) { return o.getAttribute('retrieve_id'); }
1510 obj.toggle_actions();
1511 if (typeof obj.on_select == 'function') {
1512 obj.on_select(obj.sel_list);
1514 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
1515 window.xulG.on_select(obj.sel_list);
1521 obj.controller.render();
1524 this.error.sdump('D_ERROR','cat.copy_browser.list_init: ' + E + '\n');
1529 'toggle_actions' : function() {
1532 var found_aou = false; var found_acn = false; var found_acp = false;
1533 var found_aou_with_can_have_vols = false;
1534 for (var i = 0; i < obj.sel_list.length; i++) {
1535 var type = obj.sel_list[i].split(/_/)[0];
1539 var org = obj.data.hash.aou[ obj.sel_list[i].split(/_/)[1] ];
1540 if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) found_aou_with_can_have_vols = true;
1542 case 'acn' : found_acn = true; break;
1543 case 'acp' : found_acp = true; break;
1546 obj.controller.view.cmd_add_items.setAttribute('disabled','true');
1547 obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','true');
1548 obj.controller.view.cmd_edit_items.setAttribute('disabled','true');
1549 obj.controller.view.cmd_replace_barcode.setAttribute('disabled','true');
1550 obj.controller.view.cmd_delete_items.setAttribute('disabled','true');
1551 obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','true');
1552 obj.controller.view.cmd_add_volumes.setAttribute('disabled','true');
1553 obj.controller.view.cmd_mark_library.setAttribute('disabled','true');
1554 obj.controller.view.cmd_edit_volumes.setAttribute('disabled','true');
1555 obj.controller.view.cmd_delete_volumes.setAttribute('disabled','true');
1556 obj.controller.view.cmd_mark_volume.setAttribute('disabled','true');
1557 obj.controller.view.cmd_transfer_volume.setAttribute('disabled','true');
1558 obj.controller.view.cmd_transfer_items.setAttribute('disabled','true');
1559 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
1560 obj.controller.view.sel_patron.setAttribute('disabled','true');
1561 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
1562 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
1563 if (found_aou && found_aou_with_can_have_vols) {
1564 obj.controller.view.cmd_add_volumes.setAttribute('disabled','false');
1565 obj.controller.view.cmd_mark_library.setAttribute('disabled','false');
1568 obj.controller.view.cmd_edit_volumes.setAttribute('disabled','false');
1569 obj.controller.view.cmd_delete_volumes.setAttribute('disabled','false');
1570 obj.controller.view.cmd_mark_volume.setAttribute('disabled','false');
1571 obj.controller.view.cmd_add_items.setAttribute('disabled','false');
1572 obj.controller.view.cmd_transfer_volume.setAttribute('disabled','false');
1575 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
1576 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
1577 obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','false');
1578 obj.controller.view.cmd_edit_items.setAttribute('disabled','false');
1579 obj.controller.view.cmd_replace_barcode.setAttribute('disabled','false');
1580 obj.controller.view.cmd_delete_items.setAttribute('disabled','false');
1581 obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','false');
1582 obj.controller.view.cmd_transfer_items.setAttribute('disabled','false');
1583 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
1584 obj.controller.view.sel_patron.setAttribute('disabled','false');
1587 obj.error.standard_unexpected_error_alert('Copy Browser Actions',E);
1591 'refresh_list' : function() {
1598 obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID',[ obj.docid ]);
1600 var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
1601 obj.show_libs( org );
1603 obj.show_my_libs( document.getElementById('lib_menu').value );
1605 this.error.standard_unexpected_error_alert('Problem refreshing the volume/copy tree.',E);
1610 dump('exiting cat.copy_browser.js\n');