]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/main/gen_offline_widgets.xul
just the data this time
[Evergreen.git] / Open-ILS / xul / staff_client / server / main / gen_offline_widgets.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Main, Authentication Window -->
4
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
6 <!-- PRESENTATION -->
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"?>
9 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/auth.css" type="text/css"?>
10
11 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
12 <!-- LOCALIZATION -->
13 <!DOCTYPE window PUBLIC "" ""[
14         <!--#include virtual="/opac/locale/en-US/lang.dtd"-->
15 ]>
16
17 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
18 <!-- OVERLAYS -->
19 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
20
21 <window id="gen_offline_menus_win" 
22         onload="try { gen_offline_menus_init(); } catch(E) { alert(E); }"
23         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
24
25
26         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
27         <!-- BEHAVIOR -->
28         <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
29         <scripts id="openils_util_scripts"/>
30
31         <script type="text/javascript" src="chrome://open_ils_staff_client/content/main/lang.js"/>
32         <script type="text/javascript" src="/xul/server/main/lang.js"/>
33         <script type="text/javascript" src="chrome://open_ils_staff_client/content/main/JSAN.js"/>
34         <script>
35         <![CDATA[
36
37                 function gen_offline_menus_init() {
38
39                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
40
41                         if (typeof JSAN == 'undefined') {
42                                 throw(
43                                         "The JSAN library object is missing."
44                                 );
45                         }
46                         /////////////////////////////////////////////////////////////////////////////
47
48                         JSAN.errorLevel = "die"; // none, warn, or die
49                         JSAN.addRepository('/xul/server/');
50
51                         JSAN.use('util.error'); g.error = new util.error();
52                         JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
53                         JSAN.use('util.network'); g.network = new util.network();
54                         JSAN.use('util.functional');
55
56                         save_object('offline_ou_list', build_ou_list());
57
58                         save_object('offline_pgt_list', build_pgt_list());
59
60                         save_object('offline_cit_list', build_cit_list());
61
62                         save_object('offline_cnct_list', build_cnct_list());
63
64                         save_object('offline_asv_list', build_asv_list());
65
66                         $('placeholder').setAttribute('value','Offline interface synchronized with server.');
67
68                 }
69
70                 function $(id) {
71                         return document.getElementById(id);
72                 }
73
74                 function save_object(filename,obj) {
75                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
76                         JSAN.use('util.file'); var file = new util.file(filename);
77                         file.set_object(obj); file.close();
78                 }
79
80                 function build_ou_list() {
81                         return [
82                                 util.functional.map_list( 
83                                         g.data.list.aou,
84                                         function(obj) { return [ 
85                                                 obj.name() ? obj.shortname() + ' : ' + obj.name() : obj.shortname(), 
86                                                 obj.id(), 
87                                                 ( g.data.hash.aout[ obj.ou_type() ].can_have_users() == 0),
88                                                 ( g.data.hash.aout[ obj.ou_type() ].depth() ),
89                                         ]; }
90                                 ),
91                                 g.data.list.au[0].ws_ou()
92                         ];
93                 }
94
95                 function build_pgt_list() {
96                         return [
97                                 util.functional.map_list( 
98                                         g.data.list.pgt,
99                                         function(obj) { return [ 
100                                                 obj.description() ? obj.name() + ' : ' + obj.description() : obj.name(), 
101                                                 obj.id() 
102                                         ]; }
103                                 )
104                         ];
105                 }
106
107                 function build_cit_list() {
108                         return [
109                                 util.functional.map_list( 
110                                         g.data.list.cit,
111                                         function(obj) { return [ 
112                                                 obj.name(), 
113                                                 obj.id() 
114                                         ]; }
115                                 )
116                         ];
117                 }
118
119                 function build_cnct_list() {
120                         return [
121                                 util.functional.map_list( 
122                                         g.data.list.cnct,
123                                         function(obj) { return [ 
124                                                 obj.name(), 
125                                                 '[' + obj.id() + ',' + obj.circ_duration() + ']'
126                                         ]; }
127                                 )
128                         ];
129                 }
130
131                 function build_asv_list() {
132                         var obj = {};
133                         /* loop through required surveys */
134                         for (var i = 0; i < g.data.list.my_asv.length; i++) {
135                                 dump('i = ' + i + '\n');
136                                 var survey = g.data.list.my_asv[i];
137                                 obj[ survey.name() ] = {};
138                                 obj[ survey.name() ][ 'description' ] = survey.description();
139                                 obj[ survey.name() ][ 'questions' ] = [];
140
141                                 /* loop through survey questions */
142                                 for (var j = 0; j < survey.questions().length; j++) {
143                                         dump('\tj = ' + j + '\n');
144                                         var question = survey.questions()[j];
145                                         var q = {};
146                                         q[ 'question' ] = question.question();
147                                         q[ 'answers' ] = util.functional.map_list( 
148                                                 question.answers(),
149                                                 function(obj) { return [ 
150                                                         obj.answer(), 
151                                                         '[' + obj.id() + ',' 
152                                                         + obj.question() + ',' 
153                                                         + question.survey() + ']'
154                                                 ]; }
155                                         );
156                                         obj[ survey.name() ][ 'questions' ].push( q );
157                                 }
158                         }
159                         return obj;
160                 }
161
162         ]]>
163         </script>
164
165         <vbox flex="1">
166                 <label id="placeholder"/>
167         </vbox>
168 </window>
169