]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/items.js
toward more fleshed out items out interface
[Evergreen.git] / Open-ILS / xul / staff_client / server / patron / items.js
1 dump('entering patron.items.js\n');
2
3 if (typeof patron == 'undefined') patron = {};
4 patron.items = function (params) {
5
6         JSAN.use('util.error'); this.error = new util.error();
7         JSAN.use('util.network'); this.network = new util.network();
8         this.OpenILS = {}; JSAN.use('OpenILS.data'); this.OpenILS.data = new OpenILS.data(); this.OpenILS.data.init({'via':'stash'});
9 }
10
11 patron.items.prototype = {
12
13         'init' : function( params ) {
14
15                 var obj = this;
16
17                 obj.session = params['session'];
18                 obj.patron_id = params['patron_id'];
19
20                 JSAN.use('circ.util');
21                 var columns = circ.util.columns( 
22                         { 
23                                 'title' : { 'hidden' : false, 'flex' : '3' },
24                                 'due_date' : { 'hidden' : false },
25                                 'renewal_remaining' : { 'hidden' : false },
26                         } 
27                 );
28
29                 JSAN.use('util.list'); obj.list = new util.list('items_list');
30                 obj.list.init(
31                         {
32                                 'columns' : columns,
33                                 'map_row_to_column' : circ.util.std_map_row_to_column(),
34                         }
35                 );
36                 
37                 JSAN.use('util.controller'); obj.controller = new util.controller();
38                 obj.controller.init(
39                         {
40                                 'control_map' : {
41                                         'cmd_broken' : [
42                                                 ['command'],
43                                                 function() { alert('Not Yet Implemented'); }
44                                         ],
45                                         'cmd_item_print' : [
46                                                 ['command'],
47                                                 function() {
48                                                 }
49                                         ],
50                                         'cmd_item_renew' : [
51                                                 ['command'],
52                                                 function() {
53                                                 }
54                                         ],
55                                         'cmd_item_checkin' : [
56                                                 ['command'],
57                                                 function() {
58                                                 }
59                                         ],
60                                         'cmd_show_catalog' : [
61                                                 ['command'],
62                                                 function() {
63                                                 }
64                                         ],
65                                 }
66                         }
67                 );
68
69                 obj.retrieve();
70
71         },
72
73         'retrieve' : function() {
74                 var obj = this;
75                 if (window.xulG && window.xulG.checkouts) {
76                         obj.checkouts = window.xulG.checkouts;
77                 } else {
78                         obj.checkouts = obj.network.request(
79                                 api.blob_checkouts_retrieve.app,
80                                 api.blob_checkouts_retrieve.method,
81                                 [ obj.session, obj.patron_id ]
82                         );
83                                 
84                 }
85
86                 function gen_list_append(checkout) {
87                         return function() {
88                                 obj.list.append(
89                                         {
90                                                 'row' : {
91                                                         'my' : {
92                                                                 'circ' : checkout.circ,
93                                                                 'mvr' : checkout.record,
94                                                                 'acp' : checkout.copy
95                                                         }
96                                                 }
97                                         }
98                                 );
99                         };
100                 }
101
102                 JSAN.use('util.exec'); var exec = new util.exec();
103                 var rows = [];
104                 for (var i in obj.checkouts) {
105                         rows.push( gen_list_append(obj.checkouts[i]) );
106                 }
107                 exec.chain( rows );
108         },
109 }
110
111 dump('exiting patron.items.js\n');