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 = [];
9 var list = get_list_from_tree_selection( params.tree );
10 mw.sdump('D_CAT','list.length = ' + list.length + '\n');
11 var filtered_list = filter_list(
14 return (obj.getAttribute('object_type') == 'copy');
17 mw.sdump('D_CAT','filtered_list.length = ' + filtered_list.length + '\n');
18 id_mapped_list.concat(
22 return obj.getAttribute('copy_id');
26 mw.sdump('D_CAT','id_mapped_list.length = ' + id_mapped_list.length + '\n');
28 if (params.copy_ids) {
29 id_mapped_list = id_mapped_list.concat( params.copy_ids );
33 result = user_request(
35 'open-ils.search.asset.copy.fleshed.batch.retrieve',
41 mw.sdump('D_CAT','result.length = ' + result.length + '\n');
42 cn_list = new Array();
43 for (var i in result) {
44 cn_list[i] = new acn();
45 try { cn_list[i].label( filtered_list[i].getAttribute('callnumber') ); } catch(E) { cn_list[i].label( 'dummy callnumber' ); }
46 try { cn_list[i].owning_lib( filtered_list[i].getAttribute('ou_id') ); } catch(E) { cn_list[i].owning_lib( 1 ); }
47 cn_list[i].copies( [ result[i] ] );
49 mw.sdump('D_CAT','cn_list = ' + js2JSON(cn_list) + '\n');
50 spawn_legacy_copy_editor();
53 function spawn_legacy_copy_editor() {
54 mw.sdump('D_CAT','trying to spawn_copy_editor()\n');
55 var params = { 'select_all' : true };
56 var chrome = 'chrome://evergreen/content/cat/copy.xul';
57 var frame = document.getElementById('copy_edit_frame');
58 frame.setAttribute('src',chrome);
59 frame.setAttribute('flex','1');
60 frame.contentWindow.cn_list = cn_list;
61 frame.contentWindow.mw = mw;
62 frame.contentWindow.real_parentWindow = this;
63 frame.contentWindow.parentWindow = window.app_shell;
64 frame.contentWindow.params = params;
67 function save_edited_copies() {
68 //mw.sdump('D_CAT','trying to save ====================================================================================\n\n\n');
69 //mw.sdump('D_CAT','cn_list = ' + js2JSON(cn_list) + '\n\n');
71 for (var i = 0; i < cn_list.length; i++) {
72 var cn_copies = cn_list[i].copies();
73 for (var j = 0; j < cn_copies.length; j++) {
74 copies.push( cn_copies[j] );
77 //mw.sdump('D_CAT','copies = ' + js2JSON(copies) + '\n\n');
79 var result = user_request(
81 'open-ils.cat.asset.copy.fleshed.batch.update',
82 [ mw.G.auth_ses[0], copies ]
85 alert('Successfully updated these copies.\n');
87 throw('There was an error updating the copies.\n');
89 mw.sdump('D_CAT','Result = ' + js2JSON(result) + '\n');
90 refresh_spawning_browse_list();
96 function refresh_spawning_browse_list() {
98 params.refresh_func();
100 mw.sdump('D_CAT','refresh_spawning_browse_list error: ' + js2JSON(E) + '\n');