2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Cataloger's Search Result Screen -->
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
7 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
8 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
10 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
12 <!DOCTYPE window SYSTEM "chrome://open_ils_staff_client/locale/lang.dtd">
14 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
16 <?xul-overlay href="chrome://open_ils_staff_client/content/OpenILS/util_overlay.xul"?>
17 <?xul-overlay href="chrome://open_ils_staff_client/content/legacy/browse_list_overlay.xul"?>
19 <window id="browse_list_win"
20 orient="vertical" style="overflow: scroll"
21 onload="try { my_pre_init(); } catch(E) { alert(E); }"
22 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
24 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
26 <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
27 <script type="text/javascript" src="chrome://open_ils_staff_client/content/main/JSAN.js"/>
28 <script type="text/javascript" src="chrome://open_ils_staff_client/content/main/constants.js"/>
29 <script type="text/javascript" src="chrome://open_ils_staff_client/content/OpenILS/util/fmall.js"/>
30 <scripts id="openils_util_scripts"/>
31 <script type="text/javascript">
34 var parentWindow = {};
39 var org_shortname2id = {};
41 var browse_meter_per = 0;
42 var orgs_with_copies = [];
43 var orgs_with_copies_hash = {};
45 function my_pre_init() {
47 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
48 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
49 JSAN.errorLevel = "die"; // none, warn, or die
50 JSAN.addRepository('..');
51 JSAN.use('util.error'); g.error = new util.error();
52 g.error.sdump('D_TRACE','my_pre_init() for legacy/_browse.xul');
55 mw.G.main_test_variable = 'Hello World';
57 mw.G.auth_ses = [ ses() ];
58 mw.sdump = function(a,b) { g.error.sdump(a,b); }
60 find_this_id = g.cgi.param('docid');
62 JSAN.use('util.network');
63 g.network = new util.network();
65 JSAN.use('OpenILS.data');
66 g.data = new OpenILS.data(); g.data.init({'via':'stash'});
67 XML_HTTP_SERVER = g.data.server_unadorned;
69 mw.G.my_orgs = g.data.list.my_aou;
70 mw.G.my_orgs_hash = g.data.hash.my_aou;
71 mw.G.org_tree = g.data.tree.aou;
72 mw.G.user_ou = g.data.hash.aou[ g.data.list.au[0].home_ou() ];
73 mw.G.aout_list = g.data.list.aout;
74 mw.G.aout_hash = g.data.hash.aout;
75 mw.G.ccs_list = g.data.list.ccs;
76 mw.G.ccs_hash = g.data.hash.ccs;
78 var x = document.getElementById('cmd_copy_edit');
79 x.setAttribute('oncommand','try{spawn_copy_editor();}catch(E){alert(E);}');
81 x = document.getElementById('cmd_copy_add');
82 x.setAttribute('oncommand','try{spawn_copy_add_wizard();}catch(E){alert(E);}');
84 x = document.getElementById('cmd_volume_edit');
85 x.setAttribute('oncommand','try{spawn_volume_editor();}catch(E){alert(E);}');
87 x = document.getElementById('cmd_volume_add');
88 x.setAttribute('oncommand','try{spawn_volume_add_wizard();}catch(E){alert(E);}');
90 x = document.getElementById('browse_list_tree');
91 x.setAttribute('seltype','multiple');
96 var err_msg = "!! This software has encountered an error. Please tell your friendly " +
97 "system administrator or software developer the following:\nlegacy/_browse.xul\n" + E + '\n';
98 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
103 function timer_init() {
107 function timer_elapsed() {
111 function handle_error(err) {
112 try { alert(js2JSON(err)); } catch(E) { alert(err); }
115 function user_request(a,b,c,d) {
116 return [ g.network.request(a,b,c,d) ];
119 function user_async_request(a,b,c,d) {
120 return [ g.network.request(a,b,c,d) ];
125 function counter_init(id) {
129 function counter_incr(id) {
130 if (! counter[id]) { counter_init(id); }
131 return ++counter[id];
134 function counter_peek(id) {
135 if (! counter[id]) { return 0; }
139 function disable_widgets() {
140 var d = document; var idx = 0;
141 if (arguments[0].nodeName == '#document') {
142 idx = 1; d = arguments[0];
144 for (var i = idx; i < arguments.length; i++) {
145 if (typeof(arguments[i]) == 'object') {
146 arguments[i].disabled = true;
148 var w = d.getElementById( arguments[i] );
156 function enable_widgets() {
157 var d = document; var idx = 0;
158 if (arguments[0].nodeName == '#document') {
159 idx = 1; d = arguments[0];
161 for (var i = idx; i < arguments.length; i++) {
162 if (typeof(arguments[i]) == 'object') {
163 arguments[i].disabled = false;
165 var w = d.getElementById( arguments[i] );
173 function find_ou(tree,id) {
174 if (typeof(id)=='object') { id = id.id(); }
178 for (var i in tree.children()) {
179 var child = tree.children()[i];
180 ou = find_ou( child, id );
181 if (ou) { return ou; }
186 function yesno(value) {
188 case true: case 'true': case '1': case 'on':
195 function empty_widget() {
197 if (arguments.length == 1) {
202 if (typeof(e) != 'object') { e = d.getElementById(e); }
204 if (typeof(e) != 'object') { dump('Failed on empty_widget\n'); return null; }
205 while (e.lastChild) { e.removeChild(e.lastChild); }
208 function get_list_from_tree_selection() {
209 var d = document; var tree_w;
210 if (arguments.length == 1) {
211 tree_w = arguments[0];
214 tree_w = arguments[1];
217 if (typeof(tree_w) != 'object') {
218 hitlist = d.getElementById(tree_w);
223 var start = new Object();
224 var end = new Object();
225 var numRanges = hitlist.view.selection.getRangeCount();
226 for (var t=0; t<numRanges; t++){
227 hitlist.view.selection.getRangeAt(t,start,end);
228 for (var v=start.value; v<=end.value; v++){
229 var i = hitlist.contentView.getItemAtIndex(v);
230 //sdump('D_WIDGETS',i.tagName + '\n');
237 function filter_list(list,f) {
239 for (var i in list) {
240 var t = f( list[i] );
241 if (t) new_list.push( list[i] );
246 function cycle_attribute() {
247 var d; var e; var a; var v;
248 if (arguments.length == 3) {
257 if (typeof(e) != 'object') { e = d.getElementById(e); }
260 if (typeof(e) != 'object') { throw('typeof e != object : typeof e = ' + typeof(e)); }
261 if (!a) { throw('!a : a = ' + a); }
262 if (! e.getAttribute(a) ) { throw(' ! e.getAttribute(a) : a = ' + a); }
263 if (typeof(v) != 'object') { throw('typeof v != object : typeof v = ' + typeof(v)); }
265 var toggle = e.getAttribute(a);
266 var next_one = false;
267 for (var i = 0; i < v.length; i++) {
269 e.setAttribute(a,v[i]);
272 if (toggle == v[i]) {
277 e.setAttribute(a,v[0]);
280 throw('current value not in list');
288 function mapChrome(chrome) {
290 case 'chrome://open_ils_staff_client/content/cat/volume_copy_add_wizard.xul':
291 return 'chrome://open_ils_staff_client/content/legacy/_volume_copy_add_wizard.xul'; break;
292 case 'chrome://open_ils_staff_client/content/cat/copy_add_wizard.xul':
293 return 'chrome://open_ils_staff_client/content/legacy/_copy_add_wizard.xul'; break;
294 case 'chrome://open_ils_staff_client/content/cat/volume_edit_wizard.xul':
295 return 'chrome://open_ils_staff_client/content/legacy/_volume_edit_wizard.xul'; break;
300 parentWindow.new_tab = function() { };
302 parentWindow.replace_tab = function(a,b,c) {
303 if (window.xulG && typeof window.xulG.new_tab == 'function') {
305 var f = window.xulG.new_tab( mapChrome(c), { 'tab_name' : b }, {} );
306 return f.contentWindow;
313 mw.new_window = function(a,b,c) {
314 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
315 JSAN.use('util.window'); var win = new util.window();
316 return win.open( mapChrome(a), b, c );
319 function spawn_copy_editor() {
321 JSAN.use('util.widgets'); JSAN.use('util.functional');
323 var list = util.widgets.get_list_from_tree_selection('browse_list_tree');
324 list = util.functional.filter_list(
327 return o.getAttribute('object_type') == 'copy';
333 edit = g.network.request(
334 api.PERM_MULTI_ORG_CHECK.app,
335 api.PERM_MULTI_ORG_CHECK.method,
338 g.data.list.au[0].id(),
339 util.functional.map_list(
342 return o.getAttribute('ou_id');
345 [ 'UPDATE_COPY', 'UPDATE_BATCH_COPY' ]
347 ).length == 0 ? 1 : 0;
349 g.error.sdump('D_ERROR','batch permission check: ' + E);
352 list = util.functional.map_list(
355 return o.getAttribute('copy_id');
359 var title = list.length == 1 ? 'Copy' : 'Copies';
361 JSAN.use('util.window'); var win = new util.window();
363 g.data.stash('temp');
365 window.xulG.url_prefix(urls.XUL_COPY_EDITOR)
366 +'?copy_ids='+window.escape(js2JSON(list))
367 +'&docid='+window.escape(find_this_id)
371 'chrome,modal,resizable'
373 /* FIXME -- need to unique the temp space, and not rely on modalness of window */
374 g.data.stash_retrieve();
375 var copies = JSON2js( g.data.temp );
376 g.error.sdump('D_CAT','in browse, copies =\n<<' + copies + '>>');
377 if (edit=='1' && copies!='' && typeof copies != 'undefined') {
378 refresh_browse_list();
382 function spawn_volume_editor() {
383 JSAN.use('util.widgets'); JSAN.use('util.functional');
384 var list = util.widgets.get_list_from_tree_selection('browse_list_tree');
385 list = util.functional.filter_list(
388 return o.getAttribute('object_type') == 'volume';
394 edit = g.network.request(
395 api.PERM_MULTI_ORG_CHECK.app,
396 api.PERM_MULTI_ORG_CHECK.method,
399 g.data.list.au[0].id(),
400 util.functional.map_list(
403 return o.getAttribute('ou_id');
408 ).length == 0 ? 1 : 0;
410 g.error.sdump('batch permission check: ' + E);
413 if (edit==0) return; // no read-only view for this interface
415 list = util.functional.map_list(
418 return [ o.getAttribute('ou_id'), o.getAttribute('volume_id'), o.getAttribute('callnumber') ];
422 var title = list.length == 1 ? 'Volume' : 'Volumes';
424 JSAN.use('util.window'); var win = new util.window();
426 g.data.stash('temp');
428 window.xulG.url_prefix(urls.XUL_VOLUME_EDITOR)
429 +'?ou_id_volume_id_callnumber_tuples=' + window.escape( js2JSON(list) ),
431 'chrome,modal,resizable'
434 /* FIXME -- need to unique the temp space, and not rely on modalness of window */
435 g.data.stash_retrieve();
436 var volumes = JSON2js( g.data.temp );
437 g.error.sdump('D_CAT','in browse, g.data.temp =\n' + g.data.temp);
438 if (volumes=='') return;
440 volumes = util.functional.filter_list(
443 return o.ischanged() == '1';
447 volumes = util.functional.map_list(
450 o.record( find_this_id ); // staff client 2 didn't do this. Does it matter?
455 if (volumes.length == 0) return;
458 var r = g.network.request(
459 api.FM_ACN_TREE_UPDATE.app,
460 api.FM_ACN_TREE_UPDATE.method,
463 /* FIXME -- revisit the return value here */
465 alert('volume update error: ' + js2JSON(E));
467 refresh_browse_list();
471 function spawn_volume_add_wizard() {
472 JSAN.use('util.widgets'); JSAN.use('util.functional');
473 var list = util.widgets.get_list_from_tree_selection('browse_list_tree');
474 list = util.functional.filter_list(
477 return o.getAttribute('object_type') == 'org_unit';
480 list = util.functional.map_list(
483 return o.getAttribute('ou_id');
488 edit = g.network.request(
489 api.PERM_MULTI_ORG_CHECK.app,
490 api.PERM_MULTI_ORG_CHECK.method,
493 g.data.list.au[0].id(),
495 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
497 ).length == 0 ? 1 : 0;
499 g.error.sdump('batch permission check: ' + E);
502 if (edit==0) return; // no read-only view for this interface
504 var title = 'Add Volume/Copy';
506 JSAN.use('util.window'); var win = new util.window();
508 window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR)
509 +'?doc_id=' + window.escape(find_this_id)
510 +'&ou_ids=' + window.escape( js2JSON(list) ),
512 'chrome,modal,resizable'
515 refresh_browse_list();
518 function spawn_copy_add_wizard() {
519 JSAN.use('util.widgets'); JSAN.use('util.functional');
520 var list = util.widgets.get_list_from_tree_selection('browse_list_tree');
521 list = util.functional.filter_list(
524 return o.getAttribute('object_type') == 'volume';
527 var copy_shortcut = {};
528 list = util.functional.map_list(
531 var ou_id = o.getAttribute('ou_id');
532 var volume_id = o.getAttribute('volume_id');
533 var label = o.getAttribute('callnumber');
534 if (!copy_shortcut[ou_id]) copy_shortcut[ou_id] = {};
535 copy_shortcut[ou_id][ label ] = volume_id;
541 list = []; for (var i in copy_shortcut) { list.push( i ); }
545 edit = g.network.request(
546 api.PERM_MULTI_ORG_CHECK.app,
547 api.PERM_MULTI_ORG_CHECK.method,
550 g.data.list.au[0].id(),
554 ).length == 0 ? 1 : 0;
556 g.error.sdump('batch permission check: ' + E);
559 if (edit==0) return; // no read-only view for this interface
561 var title = 'Add Copy';
563 JSAN.use('util.window'); var win = new util.window();
565 window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR)
566 +'?doc_id=' + window.escape(find_this_id)
567 +'&ou_ids=' + window.escape( js2JSON(list) )
568 +'©_shortcut=' + window.escape( js2JSON(copy_shortcut) ),
570 'chrome,modal,resizable'
572 refresh_browse_list();
575 function mark_volume() {
576 JSAN.use('util.widgets'); JSAN.use('util.functional');
577 var list = util.widgets.get_list_from_tree_selection('browse_list_tree');
578 list = util.functional.filter_list(
581 return o.getAttribute('object_type') == 'volume';
584 list = util.functional.map_list(
587 return o.getAttribute('volume_id');
591 g.data.marked_volume = list[0];
592 g.data.stash('marked_volume');
593 alert('Volume marked as Copy Transfer Destination');
596 function add_to_bucket() {
598 JSAN.use('util.widgets'); JSAN.use('util.functional');
600 var list = util.widgets.get_list_from_tree_selection('browse_list_tree');
601 list = util.functional.filter_list(
604 return o.getAttribute('object_type') == 'copy';
608 list = util.functional.map_list(
611 return o.getAttribute('copy_id');
615 JSAN.use('util.window'); var win = new util.window();
617 xulG.url_prefix(urls.XUL_COPY_BUCKETS)
618 + '?copy_ids=' + js2JSON( list ),
619 'sel_bucket_win' + win.window_name_increment(),
620 'chrome,resizable,modal,center'
627 <!-- The logic for this app -->
628 <Evergreen id="browse_list_js" />
630 <!-- XUL'ified abstraction for logic to attach to widgets -->
631 <commandset id="browse_list_cmds" />
633 <!-- Accelerator Keys (Accessor Keys are in DTD's) -->
634 <keyset id="browse_list_keys" />
636 <!-- Context menus -->
637 <popupset id="browse_list_popupset" />
639 <!-- Layout to be filled in by overlays and javascript -->
641 <caption label="Holdings Maintenance"/>
642 <vbox id="browse_list_vbox" class="test_class"/>