]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/search_form.js
toward patron search
[Evergreen.git] / Open-ILS / xul / staff_client / server / patron / search_form.js
1 dump('entering patron/search_form.js\n');
2
3 if (typeof patron == 'undefined') patron = {};
4 patron.search_form = function (params) {
5
6         JSAN.use('util.error'); this.error = new util.error();
7         JSAN.use('main.network'); this.network = new main.network();
8         this.w = window;
9 }
10
11 patron.search_form.prototype = {
12
13         'init' : function( params ) {
14
15                 var obj = this;
16
17                 obj.session = params['session'];
18
19                 JSAN.use('OpenILS.data'); this.OpenILS = {}; 
20                 obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
21
22                 JSAN.use('main.controller'); obj.controller = new main.controller();
23                 obj.controller.init(
24                         {
25                                 control_map : {
26                                         'cmd_broken' : [
27                                                 ['command'],
28                                                 function() { alert('Not Yet Implemented'); }
29                                         ],
30                                         'cmd_patron_search_submit' : [
31                                                 ['command'],
32                                                 function() {
33                                                         var query = '';
34                                                         for (var i = 0; i < obj.controller.render_list.length; i++) {
35                                                                 var id = obj.controller.render_list[i][0];
36                                                                 var node = document.getElementById(id);
37                                                                 if (node && node.value != '') {
38                                                                         if (query == '') {
39                                                                                 query += '?';
40                                                                         } else {
41                                                                                 query += '&';
42                                                                         }
43                                                                         query += id + '=' + window.escape(node.value);
44                                                                         dump('id = ' + id + '  value = ' + node.value + '\n');
45                                                                 }
46                                                         }
47                                                         if (typeof obj.on_submit == 'function') {
48                                                                 obj.on_submit(query);
49                                                         }
50                                                         if (typeof window.xulG == 'object' 
51                                                                 && typeof window.xulG.on_submit == 'function') {
52                                                                 obj.error.sdump('D_PATRON','patron.search_form: Calling external .on_submit()\n');
53                                                                 window.xulG.on_submit(query);
54                                                         } else {
55                                                                 obj.error.sdump('D_PATRON','patron.search_form: No external .on_query()\n');
56                                                         }
57
58                                                 }
59                                         ],
60                                         'cmd_patron_search_clear' : [
61                                                 ['command'],
62                                                 function() { obj.controller.render(); }
63                                         ],
64                                         'family_name' : [
65                                                 ['render'],
66                                                 function(e) {
67                                                         return function() {
68                                                                 if (params.query&&params.query.family_name) {
69                                                                         e.value = params.query.family_name;
70                                                                 } else {
71                                                                         e.value = '';
72                                                                 }
73                                                         };
74                                                 }
75                                         ],
76                                         'first_given_name' : [
77                                                 ['render'],
78                                                 function(e) {
79                                                         return function() {
80                                                                 if (params.query&&params.query.first_given_name) {
81                                                                         e.value = params.query.first_given_name;
82                                                                 } else {
83                                                                         e.value = '';
84                                                                 }
85                                                         };
86                                                 }
87                                         ],
88                                         'second_given_name' : [
89                                                 ['render'],
90                                                 function(e) {
91                                                         return function() {
92                                                                 if (params.query&&params.query.second_given_name) {
93                                                                         e.value = params.query.second_gtiven_name;
94                                                                 } else {
95                                                                         e.value = '';
96                                                                 }
97                                                         };
98                                                 }
99                                         ],
100                                         'email' : [
101                                                 ['render'],
102                                                 function(e) {
103                                                         return function() {
104                                                                 if (params.query&&params.query.email) {
105                                                                         e.value = params.query.email;
106                                                                 } else {
107                                                                         e.value = '';
108                                                                 }
109                                                         };
110                                                 }
111                                         ],
112                                         'phone' : [
113                                                 ['render'],
114                                                 function(e) {
115                                                         return function() {
116                                                                 if (params.query&&params.query.phone) {
117                                                                         e.value = params.query.phone;
118                                                                 } else {
119                                                                         e.value = '';
120                                                                 }
121                                                         };
122                                                 }
123                                         ],
124                                         'ident' : [
125                                                 ['render'],
126                                                 function(e) {
127                                                         return function() {
128                                                                 if (params.query&&params.query.ident) {
129                                                                         e.value = params.query.ident;
130                                                                 } else {
131                                                                         e.value = '';
132                                                                 }
133                                                         };
134                                                 }
135                                         ],
136                                         'street1' : [
137                                                 ['render'],
138                                                 function(e) {
139                                                         return function() {
140                                                                 if (params.query&&params.query.street1) {
141                                                                         e.value = params.query.street1;
142                                                                 } else {
143                                                                         e.value = '';
144                                                                 }
145                                                         };
146                                                 }
147                                         ],
148                                         'street2' : [
149                                                 ['render'],
150                                                 function(e) {
151                                                         return function() {
152                                                                 if (params.query&&params.query.street2) {
153                                                                         e.value = params.query.street2;
154                                                                 } else {
155                                                                         e.value = '';
156                                                                 }
157                                                         };
158                                                 }
159                                         ],
160                                         'city' : [
161                                                 ['render'],
162                                                 function(e) {
163                                                         return function() {
164                                                                 if (params.query&&params.query.city) {
165                                                                         e.value = params.query.city;
166                                                                 } else {
167                                                                         e.value = '';
168                                                                 }
169                                                         };
170                                                 }
171                                         ],
172                                         'state' : [
173                                                 ['render'],
174                                                 function(e) {
175                                                         return function() {
176                                                                 if (params.query&&params.query.state) {
177                                                                         e.value = params.query.state;
178                                                                 } else {
179                                                                         e.value = '';
180                                                                 }
181                                                         };
182                                                 }
183                                         ],
184                                         'post_code' : [
185                                                 ['render'],
186                                                 function(e) {
187                                                         return function() {
188                                                                 if (params.query&&params.query.post_code) {
189                                                                         e.value = params.query.post_code;
190                                                                 } else {
191                                                                         e.value = '';
192                                                                 }
193                                                         };
194                                                 }
195                                         ],
196                                 }
197                         }
198                 );
199
200         },
201
202         'on_submit' : function(q) {
203                 var msg = 'Query = ' + q;
204                 this.error.sdump('D_PATRON', msg);
205         },
206
207 }
208
209 dump('exiting patron/search_form.js\n');