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 list = get_list_from_tree_selection( params.tree );
8 mw.sdump('D_CAT','list.length = ' + list.length + '\n');
9 var filtered_list = filter_list(
12 return (obj.getAttribute('object_type') == 'copy');
15 mw.sdump('D_CAT','filtered_list.length = ' + filtered_list.length + '\n');
16 var id_mapped_list = map_list(
19 return obj.getAttribute('copy_id');
22 mw.sdump('D_CAT','id_mapped_list.length = ' + id_mapped_list.length + '\n');
23 var result = user_request(
25 'open-ils.search.asset.copy.fleshed.batch.retrieve',
28 mw.sdump('D_CAT','result.length = ' + result.length + '\n');
29 cn_list = new Array();
30 for (var i in result) {
31 cn_list[i] = new acn();
32 cn_list[i].label( filtered_list[i].getAttribute('callnumber') );
33 cn_list[i].owning_lib( filtered_list[i].getAttribute('ou_id') );
34 cn_list[i].copies( [ result[i] ] );
36 mw.sdump('D_CAT','cn_list = ' + js2JSON(cn_list) + '\n');
37 spawn_legacy_copy_editor();
40 function spawn_legacy_copy_editor() {
41 mw.sdump('D_CAT','trying to spawn_copy_editor()\n');
42 var params = { 'select_all' : true };
43 var chrome = 'chrome://evergreen/content/cat/copy.xul';
44 var frame = document.getElementById('copy_edit_frame');
45 frame.setAttribute('src',chrome);
46 frame.setAttribute('flex','1');
47 frame.contentWindow.cn_list = cn_list;
48 frame.contentWindow.mw = mw;
49 frame.contentWindow.real_parentWindow = this;
50 frame.contentWindow.parentWindow = window.app_shell;
51 frame.contentWindow.params = params;
54 function save_edited_copies() {
55 //mw.sdump('D_CAT','trying to save ====================================================================================\n\n\n');
56 //mw.sdump('D_CAT','cn_list = ' + js2JSON(cn_list) + '\n\n');
58 for (var i = 0; i < cn_list.length; i++) {
59 var cn_copies = cn_list[i].copies();
60 for (var j = 0; j < cn_copies.length; j++) {
61 copies.push( cn_copies[j] );
64 //mw.sdump('D_CAT','copies = ' + js2JSON(copies) + '\n\n');
66 var result = user_request(
68 'open-ils.cat.asset.copy.fleshed.batch.update',
69 [ mw.G.auth_ses[0], copies ]
72 alert('Successfully updated these copies.\n');
74 throw('There was an error updating the copies.\n');
76 mw.sdump('D_CAT','Result = ' + js2JSON(result) + '\n');
77 refresh_spawning_browse_list();
83 function refresh_spawning_browse_list() {
85 params.refresh_func();
87 mw.sdump('D_CAT','refresh_spawning_browse_list error: ' + js2JSON(E) + '\n');