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 ou_id = obj.map_acn['acn_' + o].owning_lib();
261 var label = obj.map_acn['acn_' + o].label();
262 if (!copy_shortcut[ou_id]) copy_shortcut[ou_id] = {};
263 copy_shortcut[ou_id][ label ] = volume_id;
268 /* quick fix */ /* what was this fixing? */
269 list = []; for (var i in copy_shortcut) { list.push( i ); }
273 edit = obj.network.request(
274 api.PERM_MULTI_ORG_CHECK.app,
275 api.PERM_MULTI_ORG_CHECK.method,
278 obj.data.list.au[0].id(),
282 ).length == 0 ? 1 : 0;
284 obj.error.sdump('D_ERROR','batch permission check: ' + E);
287 if (edit==0) return; // no read-only view for this interface
289 var title = document.getElementById('catStrings').getString('staff.cat.copy_browser.add_item.title');
291 JSAN.use('util.window'); var win = new util.window();
293 window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR),
294 //+'?doc_id=' + window.escape(obj.docid)
295 //+'&ou_ids=' + window.escape( js2JSON(list) )
296 //+'©_shortcut=' + window.escape( js2JSON(copy_shortcut) ),
300 w.refresh = function() { obj.refresh_list(); }
301 w.xulG = { 'doc_id':obj.docid, 'ou_ids' : list, 'copy_shortcut' : copy_shortcut };
303 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_item.error'),E);
307 'cmd_add_items_to_buckets' : [
311 JSAN.use('util.functional');
313 var list = util.functional.filter_list(
316 return o.split(/_/)[0] == 'acp';
320 list = util.functional.map_list(
323 return o.split(/_/)[1];
327 JSAN.use('cat.util');
328 cat.util.add_copies_to_bucket( list );
331 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_items_bucket.error'),E);
335 'cmd_replace_barcode' : [
339 JSAN.use('util.functional');
341 var list = util.functional.filter_list(
344 return o.split(/_/)[0] == 'acp';
348 list = util.functional.map_list(
351 var cloned_copy_obj = JSON2js( js2JSON( obj.map_acp[ o ] ) );
352 cloned_copy_obj.call_number( obj.map_acn[ 'acn_' + cloned_copy_obj.call_number() ] );
353 return cloned_copy_obj;
357 xulG.volume_item_creator( {'existing_copies':list, 'onrefresh' : function() { obj.refresh_list(); } } );
360 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.replace_barcode.error'),E);
369 JSAN.use('util.functional');
371 var list = util.functional.filter_list(
374 return o.split(/_/)[0] == 'acp';
378 list = util.functional.map_list(
381 return o.split(/_/)[1];
385 JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
389 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_items.error'),E);
393 'cmd_delete_items' : [
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 JSON2js( js2JSON( obj.map_acp[ 'acp_' + o.split(/_/)[1] ] ) );
414 if (list.length != 1) {
415 delete_msg = document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.delete_items.confirm.plural', [list.length]);
417 delete_msg = document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.confirm');
419 var r = obj.error.yns_alert(
421 document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.title'),
422 document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.delete'),
423 document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.cancel'),
425 document.getElementById('commonStrings').getString('common.confirm')
429 var acn_hash = {}; var acn_list = [];
430 for (var i = 0; i < list.length; i++) {
431 list[i].isdeleted('1');
432 var acn_id = list[i].call_number();
433 if ( ! acn_hash[ acn_id ] ) {
434 acn_hash[ acn_id ] = obj.map_acn[ 'acn_' + acn_id ];
435 acn_hash[ acn_id ].copies( [] );
437 var temp = acn_hash[ acn_id ].copies();
438 temp.push( list[i] );
439 acn_hash[ acn_id ].copies( temp );
441 for (var i in acn_hash) acn_list.push( acn_hash[i] );
442 var robj = obj.network.simple_request(
443 'FM_ACN_TREE_UPDATE',
444 [ ses(), acn_list, true ],
447 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.override'),
448 'overridable_events' : [
449 1208 /* TITLE_LAST_COPY */,
450 1227 /* COPY_DELETE_WARNING */,
454 if (robj == null) throw(robj);
455 if (typeof robj.ilsevent != 'undefined') {
456 if ( (robj.ilsevent != 0) && (robj.ilsevent != 1227 /* COPY_DELETE_WARNING */) && (robj.ilsevent != 1208 /* TITLE_LAST_COPY */) ) throw(robj);
463 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.error'),E);
468 'cmd_print_spine_labels' : [
472 JSAN.use('util.functional');
474 var list = util.functional.filter_list(
477 return o.split(/_/)[0] == 'acp';
481 list = util.functional.map_list(
484 return obj.map_acp[ o ];
488 obj.data.temp_barcodes_for_labels = util.functional.map_list( list, function(o){return o.barcode();}) ;
489 obj.data.stash('temp_barcodes_for_labels');
491 xulG.url_prefix( urls.XUL_SPINE_LABEL ),
492 { 'tab_name' : document.getElementById('catStrings').getString('staff.cat.copy_browser.print_spine.tab') },
496 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.print_spine.error'),E);
500 'cmd_add_volumes' : [
504 JSAN.use('util.functional');
505 var list = util.functional.filter_list(
508 return o.split(/_/)[0] == 'aou';
511 list = util.functional.map_list(
514 return o.split(/_/)[1];
519 edit = obj.network.request(
520 api.PERM_MULTI_ORG_CHECK.app,
521 api.PERM_MULTI_ORG_CHECK.method,
524 obj.data.list.au[0].id(),
526 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
528 ).length == 0 ? 1 : 0;
530 obj.error.sdump('D_ERROR','batch permission check: ' + E);
534 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.permission_error'));
535 return; // no read-only view for this interface
538 var title = document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.title');
540 JSAN.use('util.window'); var win = new util.window();
542 window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR),
543 //+'?doc_id=' + window.escape(obj.docid)
544 //+'&ou_ids=' + window.escape( js2JSON(list) ),
549 w.refresh = function() { obj.refresh_list() };
550 w.xulG = { 'doc_id' : obj.docid, 'ou_ids' : list };
552 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.error'),E);
556 'cmd_edit_volumes' : [
560 JSAN.use('util.functional');
561 var volumes = util.functional.map_list(
562 util.functional.filter_list(
565 return o.split(/_/)[0] == 'acn';
569 return o.split(/_/)[1];
572 volumes = util.functional.map_list(
575 var my_acn = obj.map_acn['acn_' + o];
576 return function(r){return r;}(my_acn);
580 JSAN.use('cat.util');
581 if ( cat.util.batch_edit_volumes( volumes ) ) {
586 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.exception'),E);
590 'cmd_delete_volumes' : [
594 JSAN.use('util.functional');
596 var list = util.functional.filter_list(
599 return o.split(/_/)[0] == 'acn';
603 list = util.functional.map_list(
606 return JSON2js( js2JSON( obj.map_acn[ 'acn_' + o.split(/_/)[1] ] ) );
611 if (list.length == 1) {
612 del_prompt = document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.prompt');
614 del_prompt = document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.delete_volume.prompt.plural', [list.length]);
617 var r = obj.error.yns_alert(
619 document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.title'),
620 document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.delete'),
621 document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.cancel'),
623 document.getElementById('commonStrings').getString('common.confirm')
627 for (var i = 0; i < list.length; i++) {
628 list[i].isdeleted('1');
630 var robj = obj.network.simple_request(
631 'FM_ACN_TREE_UPDATE',
632 [ ses(), list, true ],
635 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.override'),
636 'overridable_events' : [
640 if (robj == null) throw(robj);
641 if (typeof robj.ilsevent != 'undefined') {
642 if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
643 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain'));
646 if (robj.ilsevent != 0) throw(robj);
648 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.success'));
652 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.exception'),E);
658 'cmd_mark_library' : [
662 var list = util.functional.filter_list(
665 return o.split(/_/)[0] == 'aou';
669 list = util.functional.map_list(
672 return o.split(/_/)[1];
676 if (list.length == 1) {
677 obj.data.marked_library = { 'lib' : list[0], 'docid' : obj.docid };
678 obj.data.stash('marked_library');
679 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.alert'));
682 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.prompt'),
683 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.title'),
684 document.getElementById('commonStrings').getString('common.ok'),
687 document.getElementById('commonStrings').getString('common.confirm')
691 obj.error.standard_unexpected_error_alert('copy browser -> mark library',E);
696 'cmd_mark_volume' : [
700 var list = util.functional.filter_list(
703 return o.split(/_/)[0] == 'acn';
707 list = util.functional.map_list(
710 return o.split(/_/)[1];
714 if (list.length == 1) {
715 obj.data.marked_volume = list[0];
716 obj.data.stash('marked_volume');
717 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.alert'));
720 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.prompt'),
721 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.title'),
722 document.getElementById('commonStrings').getString('common.ok'),
725 document.getElementById('commonStrings').getString('common.confirm')
729 obj.error.standard_unexpected_error_alert('copy browser -> mark volume',E);
733 'cmd_refresh_list' : [
739 'cmd_transfer_volume' : [
743 obj.data.stash_retrieve();
744 if (!obj.data.marked_library) {
745 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_volume.alert'));
749 JSAN.use('util.functional');
751 var list = util.functional.filter_list(
754 return o.split(/_/)[0] == 'acn';
758 list = util.functional.map_list(
761 return o.split(/_/)[1];
765 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
767 var acn_list = util.functional.map_list(
770 return obj.map_acn[ 'acn_' + o ].label();
772 ).join(document.getElementById('commonStrings').getString('common.grouping_string'));
774 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: auto">';
775 xml += '<description>';
776 xml += document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.transfer.prompt', [acn_list, obj.data.hash.aou[ obj.data.marked_library.lib ].shortname()]);
777 xml += '</description>';
778 xml += '<hbox><button label="' + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.submit.label') + '" name="fancy_submit"/>';
779 xml += '<button label="'
780 + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.cancel.label')
782 + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.cancel.accesskey')
783 + '" name="fancy_cancel"/></hbox>';
784 xml += '<iframe style="overflow: scroll" flex="1" src="' + urls.XUL_BIB_BRIEF + '?docid=' + obj.data.marked_library.docid + '"/>';
786 JSAN.use('OpenILS.data');
787 var data = new OpenILS.data(); data.init({'via':'stash'});
788 //data.temp_transfer = xml; data.stash('temp_transfer');
789 JSAN.use('util.window'); var win = new util.window();
790 var fancy_prompt_data = win.open(
791 urls.XUL_FANCY_PROMPT,
792 //+ '?xml_in_stash=temp_transfer'
793 //+ '&title=' + window.escape('Volume Transfer'),
794 'fancy_prompt', 'chrome,resizable,modal,width=500,height=300',
797 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.title')
801 if (fancy_prompt_data.fancy_status == 'incomplete') {
802 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.incomplete'));
806 var robj = obj.network.simple_request(
808 [ ses(), { 'docid' : obj.data.marked_library.docid, 'lib' : obj.data.marked_library.lib, 'volumes' : list } ],
811 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.override.failure'),
812 'overridable_events' : [
813 1208 /* TITLE_LAST_COPY */,
814 1219 /* COPY_REMOTE_CIRC_LIB */,
819 if (typeof robj.ilsevent != 'undefined') {
820 if (robj.ilsevent == 1221 /* ORG_CANNOT_HAVE_VOLS */) {
821 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.ineligible_destination'));
826 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.success'));
830 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.unexpected_error'),E);
836 'cmd_transfer_items' : [
840 obj.data.stash_retrieve();
841 if (!obj.data.marked_volume) {
842 alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_items.missing_volume'));
846 JSAN.use('util.functional');
848 var list = util.functional.filter_list(
851 return o.split(/_/)[0] == 'acp';
855 list = util.functional.map_list(
858 return o.split(/_/)[1];
862 var volume = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ obj.data.marked_volume ]);
864 JSAN.use('cat.util'); cat.util.transfer_copies( {
866 'docid' : volume.record(),
867 'volume_label' : volume.label(),
868 'owning_lib' : volume.owning_lib(),
872 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_items.unexpected_error'),E);
882 this.error.standard_unexpected_error_alert('cat.copy_browser.controller_init(): ',E);
886 'depth_menu_init' : function(params) {
891 for (var i = 0; i < obj.data.list.aout.length; i++) {
892 var type = obj.data.list.aout[i];
893 var depth = type.depth();
894 if ( depth > max_depth) { max_depth = depth; }
895 if (typeof list[depth] == 'undefined') {
903 list[depth][0] += ' / ' + type.opac_label();
906 ml = util.widgets.make_menulist( list, max_depth );
907 ml.setAttribute('id','depth_menu'); document.getElementById('x_depth_menu').appendChild(ml);
911 obj.default_depth = ev.target.value;
912 if (document.getElementById('refresh_button')) document.getElementById('refresh_button').focus();
913 JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
914 util.widgets.save_attributes(file, {
915 'lib_menu' : [ 'value' ],
916 'depth_menu' : [ 'value' ],
917 'show_acns' : [ 'checked' ],
918 'show_acps' : [ 'checked' ]
924 file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
925 util.widgets.load_attributes(file);
926 ml.value = ml.getAttribute('value');
928 ml.value = max_depth;
929 ml.setAttribute('value',ml.value);
934 alert('Error in copy_browser.js, depth_menu_init(): ' + E);
938 'library_menu_init' : function(params) {
942 obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative',[ obj.docid ]);
943 if (typeof obj.org_ids.ilsevent != 'undefined') throw(obj.org_ids);
944 JSAN.use('util.functional');
945 obj.org_ids = util.functional.map_list( obj.org_ids, function (o) { return Number(o); });
947 var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
949 JSAN.use('util.file'); JSAN.use('util.widgets');
951 var file; var list_data; var ml;
953 file = new util.file('offline_ou_list');
954 if (file._file.exists()) {
955 list_data = file.get_object(); file.close();
956 for (var i = 0; i < list_data[0].length; i++) { // make sure all entries are enabled
957 list_data[0][i][2] = false;
959 ml = util.widgets.make_menulist( list_data[0], list_data[1] );
960 ml.setAttribute('id','lib_menu'); document.getElementById('x_lib_menu').appendChild(ml);
961 for (var i = 0; i < obj.org_ids.length; i++) {
962 ml.getElementsByAttribute('value',obj.org_ids[i])[0].setAttribute('class','has_copies');
964 ml.firstChild.addEventListener(
967 document.getElementById('legend').setAttribute('hidden','false');
971 ml.firstChild.addEventListener(
974 document.getElementById('legend').setAttribute('hidden','true');
981 obj.default_lib = obj.data.hash.aou[ ev.target.value ];
982 if (document.getElementById('refresh_button')) document.getElementById('refresh_button').focus();
983 JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
984 util.widgets.save_attributes(file, {
985 'lib_menu' : [ 'value' ],
986 'depth_menu' : [ 'value' ],
987 'show_acns' : [ 'checked' ],
988 'show_acps' : [ 'checked' ]
995 throw(document.getElementById('catStrings').getString('staff.cat.copy_browser.missing_library') + '\n');
998 file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
999 util.widgets.load_attributes(file);
1000 ml.value = ml.getAttribute('value');
1002 ml.value = org.id();
1003 ml.setAttribute('value',ml.value);
1009 this.error.standard_unexpected_error_alert('cat.copy_browser.library_menu_init(): ',E);
1013 'show_consortial_count' : function() {
1016 obj.network.simple_request('FM_ACP_COUNT.authoritative',[ obj.data.tree.aou.id(), obj.docid ],function(req){
1018 var robj = req.getResultObject();
1019 var x = document.getElementById('consortial_total');
1020 if (x) x.setAttribute('value',robj[0].count);
1021 x = document.getElementById('consortial_available');
1022 if (x) x.setAttribute('value',robj[0].available);
1024 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.consortial_copy_count.error'),E);
1028 this.error.standard_unexpected_error_alert('cat.copy_browser.show_consortial_count: ',E);
1032 'show_my_libs' : function(org) {
1036 org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
1038 if (typeof org != 'object') org = obj.data.hash.aou[ org ];
1040 obj.show_libs( org, false );
1042 var p_org = obj.data.hash.aou[ org.parent_ou() ];
1044 obj.funcs.push( function() {
1045 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1046 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1047 document.getElementById('lib_menu').setAttribute('disabled','true');
1049 for (var i = 0; i < p_org.children().length; i++) {
1053 obj.show_libs( o, false );
1055 }( p_org.children()[i] )
1058 obj.funcs.push( function() {
1059 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1060 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1061 document.getElementById('lib_menu').setAttribute('disabled','false');
1070 'show_all_libs' : function() {
1075 obj.show_libs( obj.data.tree.aou );
1077 obj.funcs.push( function() {
1078 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1079 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1080 document.getElementById('lib_menu').setAttribute('disabled','true');
1083 for (var i = 0; i < obj.data.tree.aou.children().length; i++) {
1084 var child = obj.data.tree.aou.children()[i];
1085 if (obj.data.hash.aout[child.ou_type()].depth() <= obj.default_depth
1086 && orgIsMine(obj.default_lib,child,obj.default_depth)) {
1096 obj.funcs.push( function() {
1097 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1098 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1099 document.getElementById('lib_menu').setAttribute('disabled','false');
1107 'show_libs_with_copies' : function() {
1110 JSAN.use('util.functional');
1112 var orgs = util.functional.map_list(
1114 function(id) { return obj.data.hash.aou[id]; }
1117 if (a.shortname() < b.shortname()) return -1;
1118 if (a.shortname() > b.shortname()) return 1;
1122 obj.funcs.push( function() {
1123 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1124 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1125 document.getElementById('lib_menu').setAttribute('disabled','true');
1128 for (var i = 0; i < orgs.length; i++) {
1132 obj.show_libs(o,false);
1137 obj.funcs.push( function() {
1138 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1139 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1140 document.getElementById('lib_menu').setAttribute('disabled','false');
1148 'show_libs' : function(start_aou,show_open) {
1151 if (!start_aou) throw('show_libs: Need a start_aou');
1152 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1153 JSAN.use('util.functional');
1156 var temp_aou = start_aou;
1157 while ( temp_aou.parent_ou() ) {
1158 temp_aou = obj.data.hash.aou[ temp_aou.parent_ou() ];
1159 parents.push( temp_aou );
1163 for (var i = 0; i < parents.length; i++) {
1167 obj.append_org(o,p,{'container':'true','open':'true'});
1169 }(parents[i], obj.data.hash.aou[ parents[i].parent_ou() ])
1175 return function() { obj.append_org(o,p); };
1176 }(start_aou,obj.data.hash.aou[ start_aou.parent_ou() ])
1181 if (start_aou.children()) {
1182 var x = obj.map_tree[ 'aou_' + start_aou.id() ];
1183 x.setAttribute('container','true');
1184 if (show_open) x.setAttribute('open','true');
1185 for (var i = 0; i < start_aou.children().length; i++) {
1186 var child = start_aou.children()[i];
1187 if (obj.data.hash.aout[child.ou_type()].depth() <= obj.default_depth
1188 && orgIsMine(obj.default_lib,child,obj.default_depth)) {
1191 return function() { obj.append_org(o,p); };
1192 }( child, start_aou )
1205 'on_select' : function(list,twisty) {
1207 for (var i = 0; i < list.length; i++) {
1208 var node = obj.map_tree[ list[i] ];
1209 //if (node.lastChild.nodeName == 'treechildren') { continue; } else { alert(node.lastChild.nodeName); }
1210 var row_type = list[i].split('_')[0];
1211 var id = list[i].split('_')[1];
1213 case 'aou' : obj.on_select_org(id,twisty); break;
1214 case 'acn' : obj.on_select_acn(id,twisty); break;
1220 'on_select_acn' : function(acn_id,twisty) {
1223 var acn_tree = obj.map_acp[ 'acn_' + acn_id ];
1224 obj.funcs.push( function() {
1225 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1226 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1227 document.getElementById('lib_menu').setAttribute('disabled','true');
1229 if (acn_tree.copies()) {
1230 for (var i = 0; i < acn_tree.copies().length; i++) {
1234 obj.append_acp(c,a);
1236 }( acn_tree.copies()[i], acn_tree )
1240 obj.funcs.push( function() {
1241 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1242 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1243 document.getElementById('lib_menu').setAttribute('disabled','false');
1250 'on_select_org' : function(org_id,twisty) {
1253 var org = obj.data.hash.aou[ org_id ];
1254 obj.funcs.push( function() {
1255 document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
1256 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
1257 document.getElementById('lib_menu').setAttribute('disabled','true');
1259 if (org.children()) {
1260 for (var i = 0; i < org.children().length; i++) {
1261 var child = org.children()[i];
1262 if (obj.data.hash.aout[child.ou_type()].depth() <= obj.default_depth
1263 && orgIsMine(obj.default_lib,child,obj.default_depth)) {
1274 if (obj.map_acn[ 'aou_' + org_id ]) {
1275 for (var i = 0; i < obj.map_acn[ 'aou_' + org_id ].length; i++) {
1279 obj.append_acn(o,a);
1281 }( org, obj.map_acn[ 'aou_' + org_id ][i] )
1285 obj.funcs.push( function() {
1286 document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
1287 document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
1288 document.getElementById('lib_menu').setAttribute('disabled','false');
1291 alert('Error in copy_browser.js, on_select_org(): ' + E);
1295 'append_org' : function (org,parent_org,params) {
1297 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1298 obj.error.consoleService.logStringMessage('append_org: org = ' + org.shortname() + ' parent_org = ' + (parent_org ? parent_org.shortname() : '') + ' params = ' + js2JSON(params) + '\n');
1300 if (obj.map_tree[ 'aou_' + org.id() ]) {
1301 var x = obj.map_tree[ 'aou_' + org.id() ];
1303 for (var i in params) {
1304 x.setAttribute(i,params[i]);
1316 'skip_all_columns_except' : [0,1,2],
1317 'retrieve_id' : 'aou_' + org.id(),
1319 'no_auto_select' : true,
1323 if ( obj.org_ids.indexOf( Number( org.id() ) ) == -1 ) {
1324 if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) {
1325 data.row.my.volume_count = '0';
1326 data.row.my.copy_count = '<0>';
1328 data.row.my.volume_count = '';
1329 data.row.my.copy_count = '';
1332 var v_count = 0; var c_count = 0;
1333 acn_tree_list = obj.network.simple_request(
1334 'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS.authoritative',
1335 [ ses(), obj.docid, [ org.id() ] ]
1337 for (var i = 0; i < acn_tree_list.length; i++) {
1339 obj.map_acn[ 'acn_' + acn_tree_list[i].id() ] = function(r){return r;}(acn_tree_list[i]);
1340 var copies = acn_tree_list[i].copies(); if (copies) c_count += copies.length;
1341 for (var j = 0; j < copies.length; j++) {
1342 obj.map_acp[ 'acp_' + copies[j].id() ] = function(r){return r;}(copies[j]);
1345 data.row.my.volume_count = v_count;
1346 data.row.my.copy_count = '<' + c_count + '>';
1349 data.node = obj.map_tree[ 'aou_' + parent_org.id() ];
1351 var nparams = obj.list.append(data);
1352 var node = nparams.my_node;
1354 for (var i in params) {
1355 node.setAttribute(i,params[i]);
1358 obj.map_tree[ 'aou_' + org.id() ] = node;
1360 if (org.children()) {
1361 node.setAttribute('container','true');
1365 if ( obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].parent_ou() == parent_org.id() ) {
1366 data.node.setAttribute('open','true');
1369 obj.map_tree[ 'aou_' + org.id() ].setAttribute('open','true');
1372 if (acn_tree_list) {
1373 obj.map_acn[ 'aou_' + org.id() ] = acn_tree_list;
1374 node.setAttribute('container','true');
1377 if (document.getElementById('show_acns').checked) {
1378 node.setAttribute('open','true');
1379 obj.funcs.push( function() { obj.on_select_org( org.id() ); } );
1388 'append_acn' : function( org, acn_tree, params ) {
1391 if (obj.map_tree[ 'acn_' + acn_tree.id() ]) {
1392 var x = obj.map_tree[ 'acn_' + acn_tree.id() ];
1394 for (var i in params) {
1395 x.setAttribute(i,params[i]);
1401 var parent_node = obj.map_tree[ 'aou_' + org.id() ];
1407 'volume_count' : '',
1408 'copy_count' : acn_tree.copies() ? acn_tree.copies().length : '0',
1411 'skip_all_columns_except' : [0,1,2],
1412 'retrieve_id' : 'acn_' + acn_tree.id(),
1413 'node' : parent_node,
1415 'no_auto_select' : true,
1417 var nparams = obj.list.append(data);
1418 var node = nparams.my_node;
1419 obj.map_tree[ 'acn_' + acn_tree.id() ] = node;
1421 for (var i in params) {
1422 node.setAttribute(i,params[i]);
1425 if (acn_tree.copies()) {
1426 obj.map_acp[ 'acn_' + acn_tree.id() ] = acn_tree;
1427 node.setAttribute('container','true');
1429 if (document.getElementById('show_acps').checked) {
1430 node.setAttribute('open','true');
1431 obj.funcs.push( function() { obj.on_select_acn( acn_tree.id() ); } );
1440 'append_acp' : function( acp_item, acn_tree, params ) {
1443 if (obj.map_tree[ 'acp_' + acp_item.id() ]) {
1444 var x = obj.map_tree[ 'acp_' + acp_item.id() ];
1446 for (var i in params) {
1447 x.setAttribute(i,params[i]);
1453 var parent_node = obj.map_tree[ 'acn_' + acn_tree.id() ];
1457 'aou' : obj.data.hash.aou[ acn_tree.owning_lib() ],
1460 'volume_count' : '',
1464 'retrieve_id' : 'acp_' + acp_item.id(),
1465 'node' : parent_node,
1467 'no_auto_select' : true,
1469 var nparams = obj.list.append(data);
1470 var node = nparams.my_node;
1471 obj.map_tree[ 'acp_' + acp_item.id() ] = node;
1473 for (var i in params) {
1474 node.setAttribute(i,params[i]);
1484 'list_init' : function( params ) {
1487 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1490 JSAN.use('circ.util');
1493 'id' : 'tree_location',
1494 'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.tree_location'),
1495 'flex' : 1, 'primary' : true, 'hidden' : false,
1496 'render' : function(my) { return my.acp ? my.acp.barcode() : my.acn ? my.acn.label() : my.aou ? my.aou.shortname() + " : " + my.aou.name() : "???"; },
1499 'id' : 'volume_count',
1500 'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.volume_count'),
1501 'flex' : 0, 'primary' : false, 'hidden' : false,
1502 'render' : function(my) { return my.volume_count; },
1505 'id' : 'copy_count',
1506 'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.copy_count'),
1508 'primary' : false, 'hidden' : false,
1509 'render' : function(my) { return my.copy_count; },
1514 'location' : { 'hidden' : false },
1515 'circ_lib' : { 'hidden' : false },
1516 'owning_lib' : { 'hidden' : false },
1517 'call_number' : { 'hidden' : false },
1518 'due_date' : { 'hidden' : false },
1519 'acp_status' : { 'hidden' : false },
1543 'acp_mint_condition',
1549 JSAN.use('util.list'); obj.list = new util.list('copy_tree');
1552 'no_auto_select' : true,
1553 'columns' : columns,
1554 'map_row_to_columns' : circ.util.std_map_row_to_columns(' '),
1555 'retrieve_row' : function(params) {
1557 var row = params.row;
1560 if (!row.my.mvr) obj.funcs.push(
1563 row.my.mvr = obj.network.request(
1564 api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.app,
1565 api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.method,
1566 [ row.my.circ.target_copy() ]
1575 row.my.acp = obj.network.request(
1576 api.FM_ACP_RETRIEVE.app,
1577 api.FM_ACP_RETRIEVE.method,
1578 [ row.my.circ.target_copy() ]
1581 params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
1586 params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
1592 if (typeof params.on_retrieve == 'function') {
1593 params.on_retrieve(row);
1601 'on_click' : function(ev) {
1602 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserRead');
1603 var row = {}; var col = {}; var nobj = {};
1604 obj.list.node.treeBoxObject.getCellAt(ev.clientX,ev.clientY,row,col,nobj);
1605 if ((row.value == -1)||(nobj.value != 'twisty')) { return; }
1606 var node = obj.list.node.contentView.getItemAtIndex(row.value);
1607 var list = [ node.getAttribute('retrieve_id') ];
1608 if (typeof obj.on_select == 'function') {
1609 obj.on_select(list,true);
1611 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
1612 window.xulG.on_select(list);
1615 'on_select' : function(ev) {
1616 JSAN.use('util.functional');
1617 var sel = obj.list.retrieve_selection();
1618 obj.controller.view.sel_clip.disabled = sel.length < 1;
1619 obj.sel_list = util.functional.map_list(
1621 function(o) { return o.getAttribute('retrieve_id'); }
1623 obj.toggle_actions();
1624 if (typeof obj.on_select == 'function') {
1625 obj.on_select(obj.sel_list);
1627 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
1628 window.xulG.on_select(obj.sel_list);
1635 this.error.sdump('D_ERROR','cat.copy_browser.list_init: ' + E + '\n');
1640 'toggle_actions' : function() {
1643 var found_aou = false; var found_acn = false; var found_acp = false;
1644 var found_aou_with_can_have_vols = false;
1645 var sel_copy_libs = {};
1646 for (var i = 0; i < obj.sel_list.length; i++) {
1647 var type = obj.sel_list[i].split(/_/)[0];
1651 var org = obj.data.hash.aou[ obj.sel_list[i].split(/_/)[1] ];
1652 if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) found_aou_with_can_have_vols = true;
1654 case 'acn' : found_acn = true; break;
1660 obj.map_acp[obj.sel_list[i]].call_number()
1666 obj.controller.view.cmd_add_items.setAttribute('disabled','true');
1667 obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','true');
1668 obj.controller.view.cmd_edit_items.setAttribute('disabled','true');
1669 obj.controller.view.cmd_replace_barcode.setAttribute('disabled','true');
1670 obj.controller.view.cmd_delete_items.setAttribute('disabled','true');
1671 obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','true');
1672 obj.controller.view.cmd_add_volumes.setAttribute('disabled','true');
1673 obj.controller.view.cmd_mark_library.setAttribute('disabled','true');
1674 obj.controller.view.cmd_edit_volumes.setAttribute('disabled','true');
1675 obj.controller.view.cmd_delete_volumes.setAttribute('disabled','true');
1676 obj.controller.view.cmd_mark_volume.setAttribute('disabled','true');
1677 obj.controller.view.cmd_transfer_volume.setAttribute('disabled','true');
1678 obj.controller.view.cmd_transfer_items.setAttribute('disabled','true');
1679 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
1680 obj.controller.view.cmd_create_brt.setAttribute('disabled','true');
1681 obj.controller.view.cmd_book_item_now.setAttribute('disabled','true');
1682 obj.controller.view.sel_patron.setAttribute('disabled','true');
1683 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
1684 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
1685 if (found_aou && found_aou_with_can_have_vols) {
1686 obj.controller.view.cmd_add_volumes.setAttribute('disabled','false');
1687 obj.controller.view.cmd_mark_library.setAttribute('disabled','false');
1690 obj.controller.view.cmd_edit_volumes.setAttribute('disabled','false');
1691 obj.controller.view.cmd_delete_volumes.setAttribute('disabled','false');
1692 obj.controller.view.cmd_mark_volume.setAttribute('disabled','false');
1693 obj.controller.view.cmd_add_items.setAttribute('disabled','false');
1694 obj.controller.view.cmd_transfer_volume.setAttribute('disabled','false');
1697 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
1698 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
1699 obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','false');
1700 obj.controller.view.cmd_edit_items.setAttribute('disabled','false');
1701 obj.controller.view.cmd_replace_barcode.setAttribute('disabled','false');
1702 obj.controller.view.cmd_delete_items.setAttribute('disabled','false');
1703 obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','false');
1704 obj.controller.view.cmd_transfer_items.setAttribute('disabled','false');
1705 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
1706 obj.controller.view.cmd_create_brt.setAttribute('disabled','false');
1707 obj.controller.view.sel_patron.setAttribute('disabled','false');
1709 var L = 0; for (var k in sel_copy_libs) L++;
1711 obj.controller.view.cmd_book_item_now.setAttribute('disabled','false');
1715 obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.actions.error'),E);
1719 'refresh_list' : function() {
1726 obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative',[ obj.docid ]);
1727 if (typeof obj.org_ids.ilsevent != 'undefined') throw(obj.org_ids);
1728 JSAN.use('util.functional');
1729 obj.org_ids = util.functional.map_list( obj.org_ids, function (o) { return Number(o); });
1730 obj.show_my_libs( obj.default_lib.id() );
1731 // FIXME - we get a null from the copy_count call if we call it too quickly here
1732 setTimeout( function() { obj.show_consortial_count(); }, 2000 );
1734 this.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.refresh_list.error'),E);
1739 dump('exiting cat.copy_browser.js\n');