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');
25 result = user_request(
27 'open-ils.search.asset.copy.fleshed.batch.retrieve',
33 mw.sdump('D_CAT','result.length = ' + result.length + '\n');
34 cn_list = new Array();
35 for (var i in result) {
36 cn_list[i] = new acn();
37 cn_list[i].label( filtered_list[i].getAttribute('callnumber') );
38 cn_list[i].owning_lib( filtered_list[i].getAttribute('ou_id') );
39 cn_list[i].copies( [ result[i] ] );
41 mw.sdump('D_CAT','cn_list = ' + js2JSON(cn_list) + '\n');
42 spawn_legacy_copy_editor();
45 function spawn_legacy_copy_editor() {
46 mw.sdump('D_CAT','trying to spawn_copy_editor()\n');
47 var params = { 'select_all' : true };
48 var chrome = 'chrome://evergreen/content/cat/copy.xul';
49 var frame = document.getElementById('copy_edit_frame');
50 frame.setAttribute('src',chrome);
51 frame.setAttribute('flex','1');
52 frame.contentWindow.cn_list = cn_list;
53 frame.contentWindow.mw = mw;
54 frame.contentWindow.real_parentWindow = this;
55 frame.contentWindow.parentWindow = window.app_shell;
56 frame.contentWindow.params = params;
59 function save_edited_copies() {
60 //mw.sdump('D_CAT','trying to save ====================================================================================\n\n\n');
61 //mw.sdump('D_CAT','cn_list = ' + js2JSON(cn_list) + '\n\n');
63 for (var i = 0; i < cn_list.length; i++) {
64 var cn_copies = cn_list[i].copies();
65 for (var j = 0; j < cn_copies.length; j++) {
66 copies.push( cn_copies[j] );
69 //mw.sdump('D_CAT','copies = ' + js2JSON(copies) + '\n\n');
71 var result = user_request(
73 'open-ils.cat.asset.copy.fleshed.batch.update',
74 [ mw.G.auth_ses[0], copies ]
77 alert('Successfully updated these copies.\n');
79 throw('There was an error updating the copies.\n');
81 mw.sdump('D_CAT','Result = ' + js2JSON(result) + '\n');
82 refresh_spawning_browse_list();
88 function refresh_spawning_browse_list() {
90 params.refresh_func();
92 mw.sdump('D_CAT','refresh_spawning_browse_list error: ' + js2JSON(E) + '\n');