]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/reports/oils_rpt_widget.js
fixed the "between" param op, made the output display limiter an onchange, and made...
[working/Evergreen.git] / Open-ILS / web / reports / oils_rpt_widget.js
1 oilsRptSetSubClass('oilsRptWidget', 'oilsRptObject');
2 oilsRptWidget.OILS_RPT_TRANSFORM_WIDGET = 0;
3 oilsRptWidget.OILS_RPT_OPERATION_WIDGET = 1;
4
5 function oilsRptWidget(args) {
6         this.initWidget(args);
7         this.dest = elem('input',{type:'text'});
8 }
9
10 oilsRptWidget.prototype.initWidget = function(args) {
11         if(!args) return;
12         this.init();
13         this.node       = args.node;
14         this.type       = args.type;
15         this.action = args.action;
16         this.column     = args.column;
17 }
18
19 oilsRptWidget.prototype.getValue = function() {
20         return this.dest.value;
21 }
22
23 oilsRptWidget.prototype.draw = function() {
24         appendClear(this.node, this.dest);
25 }
26
27 /* ----------------------------------------------------------- */
28
29 /* multiple input boxes */
30 oilsRptSetSubClass('oilsRptMultiInputWidget', 'oilsRptWidget');
31 function oilsRptMultiInputWidget(args) {
32         this.initInputWidget(args);
33 }
34
35 oilsRptMultiInputWidget.prototype.initInputWidget = function(args) {
36         if(!args) return;
37         this.initWidget(args);
38         this.count = (args.count) ? args.count : 2;
39         this.dest = [];
40         for( var i = 0; i < this.count; i++ )
41                 this.dest.push(elem('input',{type:'text',size:10}));
42 }
43
44 oilsRptMultiInputWidget.prototype.getValue = function() {
45         var vals = [];
46         for( var i = 0; i < this.dest.length; i++ )
47                 vals.push(this.dest[i].value);
48         return vals;
49 }
50
51 oilsRptMultiInputWidget.prototype.draw = function() {
52         removeChildren(this.node);
53         for( var i = 0; i < this.dest.length; i++ ) {
54                 if( this.label )
55                         this.node.appendChild(this.label[i]);
56                 this.node.appendChild(this.dest[i]);
57         }
58 }
59
60 oilsRptMultiInputWidget.prototype.setLabels = function(labels) {
61         this.labels = labels;   
62 }
63
64
65
66
67 /* ----------------------------------------------------------- */
68
69 oilsRptSetSubClass('oilsRptMultiWidget', 'oilsRptWidget');
70 function oilsRptMultiWidget(args) {
71         this.initMultiWidget(args);
72 }
73
74 oilsRptMultiWidget.prototype.initMultiWidget = function(args) {
75         if(!args) return;
76         this.initWidget(args);
77         this.dest = elem('select',
78                 {multiple:'multiple','class':'oils_rpt_small_info_selector'});
79
80         var obj = this;
81
82         this.addButton = elem('input',{type:'submit',value:"Add"})
83         this.addButton.onclick = this.getSourceCollector();
84         this.delButton = elem('input',{type:'submit',value:"Del"})
85         this.delButton.onclick = function(){obj.removeSelected()};
86 }
87
88 oilsRptMultiWidget.prototype.getValue = function() {
89         var vals = [];
90         for( var i = 0; i < this.dest.options.length; i++ )
91                 vals.push(this.dest.options[i].value);
92         return vals;
93 }
94
95 oilsRptMultiWidget.prototype.removeSelected = function() {
96         oilsDelSelectedItems(this.dest);
97 }
98
99 oilsRptMultiWidget.prototype.addItem = function(name, val) {
100         for( var i = 0; i < this.dest.options.length; i++ ) {
101                 if( this.dest.options[i].value == val ) 
102                         return;
103         }
104         insertSelectorVal(this.dest, -1, name, val);
105 }
106
107 oilsRptMultiWidget.prototype.setSource = function(src) {
108         this.source = src;
109 }
110
111 oilsRptMultiWidget.prototype.drawMultiWidget = function() {
112         appendClear(this.node, this.source);
113         this.node.appendChild(elem('br'))
114         this.node.appendChild(this.addButton);
115         this.node.appendChild(this.delButton);
116         this.node.appendChild(elem('br'))
117         this.node.appendChild(this.dest);
118 }
119
120
121 /* ----------------------------------------------------------- */
122
123 oilsRptSetSubClass('oilsRptInputMultiWidget', 'oilsRptMultiWidget');
124 function oilsRptInputMultiWidget(args) {
125         this.initInputMultiWidget(args);
126 }
127 oilsRptInputMultiWidget.prototype.initInputMultiWidget = function(args) {
128         if(!args) return;
129         this.initMultiWidget(args);
130         this.setSource(elem('input',{type:'text'}));
131 }
132
133 oilsRptInputMultiWidget.prototype.draw = function() {
134         this.drawMultiWidget();
135 }
136
137 oilsRptInputMultiWidget.prototype.getSourceCollector = function() {
138         var obj = this;
139         return function() {
140                 obj.addItem(obj.source.value, obj.source.value);
141         }
142 }
143
144
145 /* ----------------------------------------------------------- */
146
147 oilsRptSetSubClass('oilsRptSelectorMultiWidget', 'oilsRptMultiWidget');
148 function oilsRptSelectorMultiWidget(args) {
149         this.initSelectorMultiWidget(args);
150 }
151 oilsRptSelectorMultiWidget.prototype.initSelectorMultiWidget = function(args) {
152         if(!args) return;
153         this.initMultiWidget(args);
154         this.setSource(
155                 elem('select',{multiple:'multiple', 'class':'oils_rpt_small_info_selector'}));
156 }
157
158 oilsRptSelectorMultiWidget.prototype.getSourceCollector = function() {
159         var obj = this;
160         return function() {
161                 for( var i = 0; i < obj.source.options.length; i++ ) {
162                         if( obj.source.options[i].selected )
163                                 obj.addItem(obj.source.options[i].innerHTML, 
164                                         obj.source.options[i].value);
165                 }
166         }
167 }
168
169 /* ----------------------------------------------------------- */
170
171 oilsRptSetSubClass('oilsRptRemoteWidget', 'oilsRptSelectorMultiWidget');
172 function oilsRptRemoteWidget(args) {
173         this.initRemoteWidget(args);
174 }
175 oilsRptRemoteWidget.prototype.initRemoteWidget = function(args) {
176         if(!args) return;
177         this.initSelectorMultiWidget(args);
178         this.selector = args.selector;
179 }
180
181 oilsRptRemoteWidget.prototype.draw = function() {
182         this.fetch();
183         //this.draw();
184 }
185
186 oilsRptRemoteWidget.prototype.setFetch = function(func) {
187         this.fetch = func;
188 }
189
190
191 /* --------------------------------------------------------------------- */
192
193 /* standalone org widget */
194 function oilsRptMyOrgsWidget(node, orgid) {
195         this.node = node;
196         this.orgid = orgid;
197 }
198
199 oilsRptMyOrgsWidget.prototype.draw = function() {
200         var req = new Request(OILS_RPT_FETCH_ORG_FULL_PATH, this.orgid);
201         var obj = this;
202         req.callback(
203                 function(r) { obj.drawWidget(r.getResultObject()); }
204         );
205         req.send();
206 }
207
208 oilsRptMyOrgsWidget.prototype.drawWidget = function(orglist) {
209         var sel = this.node;
210         for( var i = 0; i < orglist.length; i++ ) {
211                 var org = orglist[i];
212                 var opt = insertSelectorVal( this.node, -1, 
213                         org.name(), org.id(), null, findOrgDepth(org) );
214                 if( org.id() == this.orgid )
215                         opt.selected = true;
216         }
217 }
218
219 oilsRptMyOrgsWidget.prototype.getValue = function() {
220         return getSelectorVal(this.node);
221 }
222
223 /* --------------------------------------------------------------------- */
224
225 oilsRptSetSubClass('oilsRptOrgMultiSelect','oilsRptSelectorMultiWidget');
226 function oilsRptOrgMultiSelect(args) {
227         this.initSelectorMultiWidget(args);
228 }
229
230 oilsRptOrgMultiSelect.prototype.draw = function(org) {
231         if(!org) org = globalOrgTree;
232         var opt = insertSelectorVal( this.source, -1, 
233                 org.shortname(), org.id(), null, findOrgDepth(org) );
234         if( org.id() == oilsRptCurrentOrg )
235                 opt.selected = true;
236         if( org.children() ) {
237                 for( var c = 0; c < org.children().length; c++ )
238                         this.draw(org.children()[c]);
239         }
240         this.drawMultiWidget();
241 }
242
243
244
245
246