]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/evergreen/OpenILS/data.js
start of staff client 3
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / evergreen / OpenILS / data.js
1 dump('entering OpenILS/data.js\n');
2
3 if (typeof OpenILS == 'undefined') OpenILS = {};
4 OpenILS.data = function (mw,G) {
5
6         this.mw = mw; this.G = G;
7
8         var obj = this;
9
10         this.chain = [];
11
12         this.chain.push(
13                 function() {
14                         try {
15                                 obj.au = obj.G.network.request(
16                                         'open-ils.search',
17                                         'open-ils.search.actor.user.session',
18                                         [ obj.G.auth.session.key ]
19                                 );
20                         } catch(E) {
21                                 // what should we do?
22                         }
23                 }
24         );
25
26         function a_get(obj,i) { return [i, obj[i]]; }  // funkiness with loops and closures
27
28         for (var i in this._cacheable_fm_objects) {
29                 var classname = a_get(this._cacheable_fm_objects,i)[0];
30                 var data = a_get(this._cacheable_fm_objects,i)[1];
31                 var app = data[0]; var method = data[1]; var params = data[2];
32                 this.chain.push(
33                         function() {
34                                 try {
35                                         obj.list[classname] = obj.G.network.request( app, method, params);
36                                         // store an offline copy
37                                 } catch(E) {
38                                         // try offline
39                                 }
40                                 //obj.hash[classname] = convert_object_list_to_hash( obj.list[classname] );
41                         }
42                 );
43         }
44
45         /*
46         var other_fm_objects = {
47                 'my_aou' : [ 
48                         'open-ils.actor', 
49                         'open-ils.actor.org_unit.full_path.retrieve', 
50                         [ obj.G.auth.session.key ] 
51                 ],
52                 'my_actsc' : [ 
53                         'open-ils.circ', 
54                         'open-ils.circ.stat_cat.actor.retrieve.all', 
55                         [ obj.G.auth.session.key, obj.au.home_ou.id() ] 
56                 ]
57         }
58         */
59
60         return this;
61 };
62
63 OpenILS.data.prototype = {
64
65         'list' : {},
66         'hash' : {},
67
68         'init' : function () {
69
70                 if (typeof this.on_complete == 'function') {
71
72                         this.chain.push( this.on_complete );
73                 }
74
75                 JSAN.use('util.exec');
76                 util.exec.chain( this.chain );
77         },
78
79         '_cacheable_fm_objects' : {
80
81                 'pgt' : [ 'open-ils.actor', 'open-ils.actor.groups.retrieve', [] ],
82                 'cit' : [ 'open-ils.actor', 'open-ils.actor.user.ident_types.retrieve', [] ],
83                 'cst' : [ 'open-ils.actor', 'open-ils.actor.standings.retrieve', [] ],
84                 'acpl' : [ 'open-ils.search', 'open-ils.search.config.copy_location.retrieve.all', [] ],
85                 'ccs' : [ 'open-ils.search', 'open-ils.search.config.copy_status.retrieve.all', [] ],
86                 'aou' : [ 'open-ils.actor', 'open-ils.actor.org_tree.retrieve', [] ],
87                 'aout' : [ 'open-ils.actor', 'open-ils.actor.org_types.retrieve', [] ]  
88         }
89
90 }
91
92 dump('exiting OpenILS/data.js\n');