]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/util.js
patron.utils
[Evergreen.git] / Open-ILS / xul / staff_client / server / patron / util.js
1 dump('entering patron/util.js\n');
2
3 if (typeof patron == 'undefined') var patron = {};
4 patron.util = {};
5
6 patron.util.EXPORT_OK   = [ 
7         'columns', 'std_map_row_to_column', 'retrieve_au_by_id'
8 ];
9 patron.util.EXPORT_TAGS = { ':all' : patron.util.EXPORT_OK };
10
11 patron.util.columns = function(modify) {
12         
13         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
14
15         function getString(s) { return data.entities[s]; }
16
17         var c = [];
18         for (var i = 0; i < c.length; i++) {
19                 if (modify[ c[i].id ]) {
20                         for (var j in modify[ c[i].id ]) {
21                                 c[i][j] = modify[ c[i].id ][j];
22                         }
23                 }
24         }
25         return c;
26 }
27
28 patron.util.std_map_row_to_column = function() {
29         return function(row,col) {
30                 // row contains { 'my' : { 'acp' : {}, 'patron' : {}, 'mvr' : {} } }
31                 // col contains one of the objects listed above in columns
32                 
33                 var obj = {}; obj.OpenILS = {}; 
34                 JSAN.use('util.error'); obj.error = new util.error();
35                 JSAN.use('OpenILS.data'); obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
36
37                 var my = row.my;
38                 var value;
39                 try { 
40                         value = eval( col.render );
41                 } catch(E) {
42                         obj.error.sdump('D_ERROR','map_row_to_column: ' + E);
43                         value = '???';
44                 }
45                 return value;
46         }
47 }
48
49 patron.util.retrieve_au_by_id = function(session, id) {
50 }
51
52 dump('exiting patron/util.js\n');