3 function copy_edit_init() {
4 mw.sdump('D_CAT','entering my_init for copy_edit.js\n');
5 mw.sdump('D_CAT','TESTING: copy_edit.js: ' + mw.G['main_test_variable'] + '\n');
6 mw.sdump('D_CAT','Gathering copies to put in the acn object...\n');
7 var id_mapped_list = [];
8 var filtered_list = [];
10 var list = get_list_from_tree_selection( params.tree );
11 mw.sdump('D_CAT','list.length = ' + list.length + '\n');
12 filtered_list = filtered_list.concat(
16 return (obj.getAttribute('object_type') == 'copy');
20 mw.sdump('D_CAT','filtered_list.length = ' + filtered_list.length + '\n');
21 id_mapped_list = id_mapped_list.concat(
25 return obj.getAttribute('copy_id');
29 mw.sdump('D_CAT','id_mapped_list.length = ' + id_mapped_list.length + '\n');
31 if (params.copy_ids) {
32 id_mapped_list = id_mapped_list.concat( params.copy_ids );
36 result = user_request(
38 'open-ils.search.asset.copy.fleshed.batch.retrieve',
44 mw.sdump('D_CAT','result.length = ' + result.length + '\n');
45 cn_list = new Array();
46 for (var i in result) {
47 cn_list[i] = new acn();
48 try { cn_list[i].label( filtered_list[i].getAttribute('callnumber') ); } catch(E) { cn_list[i].label( 'dummy callnumber' ); }
49 try { cn_list[i].owning_lib( filtered_list[i].getAttribute('ou_id') ); } catch(E) { cn_list[i].owning_lib( 1 ); }
50 cn_list[i].copies( [ result[i] ] );
52 mw.sdump('D_CAT','cn_list = ' + js2JSON(cn_list) + '\n');
53 spawn_legacy_copy_editor();
56 function spawn_legacy_copy_editor() {
57 mw.sdump('D_CAT','trying to spawn_copy_editor()\n');
58 var params = { 'select_all' : true };
59 var chrome = 'chrome://evergreen/content/cat/copy.xul';
60 var frame = document.getElementById('copy_edit_frame');
61 frame.setAttribute('src',chrome);
62 frame.setAttribute('flex','1');
63 frame.contentWindow.cn_list = cn_list;
64 frame.contentWindow.mw = mw;
65 frame.contentWindow.real_parentWindow = this;
66 frame.contentWindow.parentWindow = window.app_shell;
67 frame.contentWindow.params = params;
70 function save_edited_copies() {
71 //mw.sdump('D_CAT','trying to save ====================================================================================\n\n\n');
72 //mw.sdump('D_CAT','cn_list = ' + js2JSON(cn_list) + '\n\n');
74 for (var i = 0; i < cn_list.length; i++) {
75 var cn_copies = cn_list[i].copies();
76 for (var j = 0; j < cn_copies.length; j++) {
77 copies.push( cn_copies[j] );
80 //mw.sdump('D_CAT','copies = ' + js2JSON(copies) + '\n\n');
82 var result = user_request(
84 'open-ils.cat.asset.copy.fleshed.batch.update',
85 [ mw.G.auth_ses[0], copies ]
88 alert('Successfully updated these copies.\n');
90 throw('There was an error updating the copies.\n');
92 mw.sdump('D_CAT','Result = ' + js2JSON(result) + '\n');
93 refresh_spawning_browse_list();
99 function refresh_spawning_browse_list() {
101 params.refresh_func();
103 mw.sdump('D_CAT','refresh_spawning_browse_list error: ' + js2JSON(E) + '\n');
107 function spawn_marc_from_copy_editor() {
109 var record_id = user_request(
111 'open-ils.search.biblio.find_by_barcode',
112 [ cn_list[0].copies()[0].barcode() ]
114 marc_view(app_shell,record_id);