]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/admin/do_not_auto_attempt_print_setting.js
LP1615805 No inputs after submit in patron search (AngularJS)
[Evergreen.git] / Open-ILS / xul / staff_client / server / admin / do_not_auto_attempt_print_setting.js
1 var error;
2 var network;
3 var data;
4 var coust_obj;
5
6 function my_init() {
7     try {
8         if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
9         JSAN.errorLevel = "die"; // none, warn, or die
10         JSAN.addRepository('/xul/server/');
11         JSAN.use('util.error'); error = new util.error();
12         error.sdump('D_TRACE','my_init() for main_test.xul');
13         JSAN.use('util.network'); network = new util.network();
14         JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
15
16         dojo.require('openils.PermaCrud');
17         coust_obj = new openils.PermaCrud({authtoken:ses()}).search('coust',{'name':'circ.staff_client.do_not_auto_attempt_print'})[0];
18         document.getElementById('caption').setAttribute('label',coust_obj.label());
19         document.getElementById('caption').setAttribute('tooltiptext',coust_obj.name());
20         append_to_vbox('desc',coust_obj.description());
21
22         render_current_setting();
23
24         document.getElementById('apply').addEventListener(
25             'command',
26             apply_setting,
27             false
28         );
29
30         var ml = util.widgets.render_perm_org_menu('ADMIN_ORG_UNIT_SETTING_TYPE');
31         if (ml) {
32             document.getElementById('apply').disabled = false;
33             ml.setAttribute('id','lib_menulist');
34             var x = document.getElementById('menu');
35             util.widgets.remove_children(x);
36             x.appendChild(ml);
37         }
38
39     } catch(E) {
40         try { error.standard_unexpected_error_alert('main/test.xul',E); } catch(F) { alert(E); }
41     }
42 }
43
44 function append_to_vbox(id,node) {
45     if (typeof node == 'string') { var text = document.createTextNode(node); node = document.createElement('description'); node.appendChild(text); }
46     document.getElementById(id).appendChild(node);
47 }
48
49 function admin_string(s,p) {
50     var mc = document.getElementById('adminStrings');
51     if (p) {
52         return mc.getFormattedString(s,p);
53     } else {
54         return mc.getString(s);
55     }
56 }
57
58 function apply_setting(ev) {
59     var values = [];
60     if (document.getElementById('checkout').checked) { values.push('Checkout'); }
61     if (document.getElementById('bill_pay').checked) { values.push('Bill Pay'); }
62     if (document.getElementById('hold_slip').checked) { values.push('Hold Slip'); }
63     if (document.getElementById('transit_slip').checked) { values.push('Transit Slip'); }
64     if (document.getElementById('hold_transit_slip').checked) { values.push('Hold/Transit Slip'); }
65     var org = document.getElementById('lib_menulist').value;
66     var result = network.simple_request('FM_AOUS_UPDATE',[ ses(), org, { 'circ.staff_client.do_not_auto_attempt_print' : values } ]);
67     if (result == 1) {
68         alert(admin_string('staff.admin.staff.do_not_auto_attempt_print_setting.update_success'));
69         render_current_setting();
70     } else {
71         error.standard_unexpected_error_alert(admin_string('staff.admin.staff.do_not_auto_attempt_print_setting.update_failure'),result);
72     }
73 }
74
75 function render_current_setting() {
76     JSAN.use('util.widgets');
77
78     util.widgets.remove_children('current');
79
80     /* FIXME: would be good to have an .authoritative version of FM_AOUS_SPECIFIC_RETRIEVE */
81     var aous_req = network.simple_request('FM_AOUS_SPECIFIC_RETRIEVE',[ ses('ws_ou'), 'circ.staff_client.do_not_auto_attempt_print', ses() ]);
82     if (aous_req) {
83         append_to_vbox(
84             'current',
85             admin_string(
86                 'staff.admin.staff.do_not_auto_attempt_print_setting.current_setting_preamble',
87                 [ ses('ws_ou_shortname'), data.hash.aou[ aous_req.org ].shortname() ]
88             )
89         );
90
91         for (var i in aous_req.value) {
92             var label = document.createElement('label');
93             label.setAttribute('value', '   ' + aous_req.value[i]);
94             append_to_vbox('current',label);
95         }
96
97         /* update data.hash.aous while we have fresh data */
98
99         data.hash.aous['circ.staff_client.do_not_auto_attempt_print'] = aous_req.value;
100         data.stash('hash');
101
102     } else {
103         append_to_vbox(
104             'current',
105             admin_string(
106                 'staff.admin.staff.do_not_auto_attempt_print_setting.current_setting_nonexistent',
107                 [ ses('ws_ou_shortname') ]
108             )
109         );
110     }
111 }
112
113
114