8 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
9 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
10 JSAN.errorLevel = "die"; // none, warn, or die
11 JSAN.addRepository('/xul/server/');
12 JSAN.use('util.error'); error = new util.error();
13 error.sdump('D_TRACE','my_init() for main_test.xul');
14 JSAN.use('util.network'); network = new util.network();
15 JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
17 dojo.require('openils.PermaCrud');
18 coust_obj = new openils.PermaCrud({authtoken:ses()}).search('coust',{'name':'circ.staff_client.do_not_auto_attempt_print'})[0];
19 document.getElementById('caption').setAttribute('label',coust_obj.label());
20 document.getElementById('caption').setAttribute('tooltiptext',coust_obj.name());
21 append_to_vbox('desc',coust_obj.description());
23 render_current_setting();
25 document.getElementById('apply').addEventListener(
34 try { error.standard_unexpected_error_alert('main/test.xul',E); } catch(F) { alert(E); }
38 function append_to_vbox(id,node) {
39 if (typeof node == 'string') { var text = document.createTextNode(node); node = document.createElement('description'); node.appendChild(text); }
40 document.getElementById(id).appendChild(node);
43 function admin_string(s,p) {
44 var mc = document.getElementById('adminStrings');
46 return mc.getFormattedString(s,p);
48 return mc.getString(s);
52 function apply_setting(ev) {
54 if (document.getElementById('checkout').checked) { values.push('Checkout'); }
55 if (document.getElementById('bill_pay').checked) { values.push('Bill Pay'); }
56 if (document.getElementById('hold_slip').checked) { values.push('Hold Slip'); }
57 if (document.getElementById('transit_slip').checked) { values.push('Transit Slip'); }
58 if (document.getElementById('hold_transit_slip').checked) { values.push('Hold/Transit Slip'); }
59 var org = document.getElementById('lib_menulist').value;
60 var result = network.simple_request('FM_AOUS_UPDATE',[ ses(), org, { 'circ.staff_client.do_not_auto_attempt_print' : values } ]);
62 alert(admin_string('staff.admin.staff.do_not_auto_attempt_print_setting.update_success'));
63 render_current_setting();
65 error.standard_unexpected_error_alert(admin_string('staff.admin.staff.do_not_auto_attempt_print_setting.update_failure'),result);
69 function render_current_setting() {
70 JSAN.use('util.widgets');
72 util.widgets.remove_children('current');
74 /* FIXME: would be good to have an .authoritative version of FM_AOUS_SPECIFIC_RETRIEVE */
75 var aous_req = network.simple_request('FM_AOUS_SPECIFIC_RETRIEVE',[ ses('ws_ou'), 'circ.staff_client.do_not_auto_attempt_print', ses() ]);
80 'staff.admin.staff.do_not_auto_attempt_print_setting.current_setting_preamble',
81 [ ses('ws_ou_shortname'), data.hash.aou[ aous_req.org ].shortname() ]
85 for (var i in aous_req.value) {
86 var label = document.createElement('label');
87 label.setAttribute('value', ' ' + aous_req.value[i]);
88 append_to_vbox('current',label);
91 /* update data.hash.aous while we have fresh data */
93 data.hash.aous['circ.staff_client.do_not_auto_attempt_print'] = aous_req.value;
100 'staff.admin.staff.do_not_auto_attempt_print_setting.current_setting_nonexistent',
101 [ ses('ws_ou_shortname') ]
108 function render_lib_menu() {
110 JSAN.use('util.functional'); JSAN.use('util.fm_utils'); JSAN.use('util.widgets');
112 var work_ous = network.simple_request(
113 'PERM_RETRIEVE_WORK_OU',
114 [ ses(), 'ADMIN_ORG_UNIT_SETTING_TYPE']
116 if (work_ous.length == 0) {
119 document.getElementById('apply').disabled = false;
123 for (var i = 0; i < work_ous.length; i++ ) {
124 var perm_depth = data.hash.aout[ data.hash.aou[ work_ous[i] ].ou_type() ].depth();
126 var my_libs_tree = network.simple_request(
127 'FM_AOU_DESCENDANTS_RETRIEVE',
128 [ work_ous[i], perm_depth ]
130 if (!instanceOf(my_libs_tree,aou)) { /* FIXME - workaround for weird descendants call result */
131 my_libs_tree = my_libs_tree[0];
133 my_libs = my_libs.concat( util.fm_utils.flatten_ou_branch( my_libs_tree ) );
136 var x = document.getElementById('menu');
137 util.widgets.remove_children( x );
139 var default_lib = my_libs[0].id();
141 var ml = util.widgets.make_menulist(
142 util.functional.map_list(
149 ( data.hash.aout[ obj.ou_type() ].depth() )
155 ml.setAttribute('id','lib_menulist');
159 alert('Error in do_not_auto_attempt_print_setting.js, render_lib_menu(): ' + E);