1 oilsRptSetSubClass('oilsRptWidget', 'oilsRptObject');
2 oilsRptWidget.OILS_RPT_TRANSFORM_WIDGET = 0;
3 oilsRptWidget.OILS_RPT_OPERATION_WIDGET = 1;
5 function oilsRptWidget(args) {
7 this.dest = elem('input',{type:'text'});
10 oilsRptWidget.prototype.initWidget = function(args) {
13 this.node = args.node;
14 this.type = args.type;
15 this.action = args.action;
16 this.column = args.column;
19 oilsRptWidget.prototype.getValue = function() {
20 return this.dest.value ;
23 oilsRptWidget.prototype.draw = function() {
24 appendClear(this.node, this.dest);
27 /* ----------------------------------------------------------- */
29 /* multiple input boxes, no separate source, optional box labels */
30 oilsRptSetSubClass('oilsRptMultiInputWidget', 'oilsRptWidget');
31 function oilsRptMultiInputWidget(args) {
32 this.initInputWidget(args);
35 oilsRptMultiInputWidget.prototype.initInputWidget = function(args) {
37 this.initWidget(args);
38 this.count = (args.count) ? args.count : 2;
40 for( var i = 0; i < this.count; i++ )
41 this.dest.push(elem('input',{type:'text',size:10}));
44 oilsRptMultiInputWidget.prototype.getValue = function() {
46 for( var i = 0; i < this.dest.length; i++ )
47 vals.push(this.dest[i].value);
51 oilsRptMultiInputWidget.prototype.draw = function() {
52 removeChildren(this.node);
53 for( var i = 0; i < this.dest.length; i++ ) {
55 this.node.appendChild(this.label[i]);
56 this.node.appendChild(this.dest[i]);
60 oilsRptMultiInputWidget.prototype.setLabels = function(labels) {
67 /* ----------------------------------------------------------- */
69 /* abstract class, multi-select output (dest),
70 add and delete buttons, you provide intput */
71 oilsRptSetSubClass('oilsRptMultiWidget', 'oilsRptWidget');
72 function oilsRptMultiWidget(args) {
73 this.initMultiWidget(args);
76 oilsRptMultiWidget.prototype.initMultiWidget = function(args) {
78 this.initWidget(args);
79 this.dest = elem('select',
80 {multiple:'multiple','class':'oils_rpt_small_info_selector'});
84 this.addButton = elem('input',{type:'submit',value:"Add"})
85 this.addButton.onclick = this.getSourceCollector();
86 this.delButton = elem('input',{type:'submit',value:"Del"})
87 this.delButton.onclick = function(){obj.removeSelected()};
90 oilsRptMultiWidget.prototype.getValue = function() {
92 for( var i = 0; i < this.dest.options.length; i++ )
93 vals.push(this.dest.options[i].value);
97 oilsRptMultiWidget.prototype.removeSelected = function() {
98 oilsDelSelectedItems(this.dest);
101 oilsRptMultiWidget.prototype.addItem = function(name, val) {
102 for( var i = 0; i < this.dest.options.length; i++ ) {
103 if( this.dest.options[i].value == val )
106 insertSelectorVal(this.dest, -1, name, val);
109 oilsRptMultiWidget.prototype.setSource = function(src) {
113 oilsRptMultiWidget.prototype.drawMultiWidget = function() {
114 appendClear(this.node, this.source);
115 this.node.appendChild(elem('br'))
116 this.node.appendChild(this.addButton);
117 this.node.appendChild(this.delButton);
118 this.node.appendChild(elem('br'))
119 this.node.appendChild(this.dest);
123 /* ----------------------------------------------------------- */
125 /* single text box as source, multiwidget output (select) as dest */
126 oilsRptSetSubClass('oilsRptInputMultiWidget', 'oilsRptMultiWidget');
127 function oilsRptInputMultiWidget(args) {
128 this.initInputMultiWidget(args);
130 oilsRptInputMultiWidget.prototype.initInputMultiWidget = function(args) {
132 this.initMultiWidget(args);
133 this.setSource(elem('input',{type:'text'}));
136 oilsRptInputMultiWidget.prototype.draw = function() {
137 this.drawMultiWidget();
140 oilsRptInputMultiWidget.prototype.getSourceCollector = function() {
143 obj.addItem(obj.source.value, obj.source.value);
148 /* ----------------------------------------------------------- */
150 /* multi-select source */
151 oilsRptSetSubClass('oilsRptSelectorMultiWidget', 'oilsRptMultiWidget');
152 function oilsRptSelectorMultiWidget(args) {
153 this.initSelectorMultiWidget(args);
155 oilsRptSelectorMultiWidget.prototype.initSelectorMultiWidget = function(args) {
157 this.initMultiWidget(args);
159 elem('select',{multiple:'multiple', 'class':'oils_rpt_small_info_selector'}));
162 oilsRptSelectorMultiWidget.prototype.getSourceCollector = function() {
165 for( var i = 0; i < obj.source.options.length; i++ ) {
166 if( obj.source.options[i].selected )
167 obj.addItem(obj.source.options[i].innerHTML,
168 obj.source.options[i].value);
173 /* ----------------------------------------------------------- */
176 oilsRptSetSubClass('oilsRptRemoteWidget', 'oilsRptSelectorMultiWidget');
177 function oilsRptRemoteWidget(args) {
178 this.initRemoteWidget(args);
180 oilsRptRemoteWidget.prototype.initRemoteWidget = function(args) {
182 this.initSelectorMultiWidget(args);
183 this.selector = args.selector;
186 oilsRptRemoteWidget.prototype.draw = function() {
191 oilsRptRemoteWidget.prototype.setFetch = function(func) {
196 /* --------------------------------------------------------------------- */
198 /* custom my-orgs picker */
199 function oilsRptMyOrgsWidget(node, orgid) {
204 oilsRptMyOrgsWidget.prototype.draw = function() {
205 var req = new Request(OILS_RPT_FETCH_ORG_FULL_PATH, this.orgid);
208 function(r) { obj.drawWidget(r.getResultObject()); }
213 oilsRptMyOrgsWidget.prototype.drawWidget = function(orglist) {
215 for( var i = 0; i < orglist.length; i++ ) {
216 var org = orglist[i];
217 var opt = insertSelectorVal( this.node, -1,
218 org.name(), org.id(), null, findOrgDepth(org) );
219 if( org.id() == this.orgid )
224 oilsRptMyOrgsWidget.prototype.getValue = function() {
225 return getSelectorVal(this.node);
228 /* --------------------------------------------------------------------- */
230 /* custom all-orgs picker */
231 oilsRptSetSubClass('oilsRptOrgMultiSelect','oilsRptSelectorMultiWidget');
232 function oilsRptOrgMultiSelect(args) {
233 this.initSelectorMultiWidget(args);
235 oilsRptOrgMultiSelect.prototype.draw = function(org) {
236 if(!org) org = globalOrgTree;
237 var opt = insertSelectorVal( this.source, -1,
238 org.shortname(), org.id(), null, findOrgDepth(org) );
239 if( org.id() == oilsRptCurrentOrg )
241 if( org.children() ) {
242 for( var c = 0; c < org.children().length; c++ )
243 this.draw(org.children()[c]);
245 this.drawMultiWidget();
249 /* --------------------------------------------------------------------- */
250 function oilsRptRelDatePicker(args) {
251 this.node = args.node;
252 this.relative = args.relative;
253 this.div = DOM.oils_rpt_relative_date_picker.cloneNode(true);
256 oilsRptRelDatePicker.prototype.draw = function() {
257 this.node.appendChild(this.div);
261 oilsRptRelDatePicker.prototype.getValue = function() {
263 getSelectorVal($n(this.div, 'count')) +
264 getSelectorVal($n(this.div,'type'));
265 if( this.relative ) str = '-'+str;
268 /* --------------------------------------------------------------------- */
277 /* --------------------------------------------------------------------- */
278 /* --------------------------------------------------------------------- */
283 /* ---------------------------------------------------------------------
284 Represents a set of value, an inputWidget collects data and a
285 multi-select displays the data and allows the user to remove items
286 --------------------------------------------------------------------- */
287 function oilsRptSetWidget(args) {
288 this.node = args.node;
289 this.inputWidget = new args.inputWidget(args);
290 this.dest = elem('select',
291 {multiple:'multiple','class':'oils_rpt_small_info_selector'});
294 oilsRptSetWidget.prototype.draw = function() {
296 this.addButton = elem('input',{type:'submit',value:"Add"})
297 this.delButton = elem('input',{type:'submit',value:"Del"})
300 this.addButton.onclick = function() {
301 obj.addDisplayItems(obj.inputWidget.getDisplayValue());
304 this.delButton.onclick = function(){obj.removeSelected()};
306 removeChildren(this.node);
307 this.inputWidget.draw();
308 this.node.appendChild(elem('br'))
309 this.node.appendChild(this.addButton);
310 this.node.appendChild(this.delButton);
311 this.node.appendChild(elem('br'))
312 this.node.appendChild(this.dest);
315 oilsRptSetWidget.prototype.addDisplayItems = function(list) {
316 if( list.constructor != Array ) list = [list];
317 for(var i = 0; i < list.length; i++) {
322 iterate(this.dest.options,
323 function(o){if(o.getAttribute('value') == item.value) {exists = true; return;}});
326 _debug('Inserting SetWidget values ' + js2JSON(item));
327 insertSelectorVal(this.dest, -1, item.label, item.value);
331 oilsRptSetWidget.prototype.removeSelected = function() {
332 oilsDelSelectedItems(this.dest);
335 oilsRptSetWidget.prototype.getValue = function() {
336 return getSelectedSet(this.dest);
340 /* ---------------------------------------------------------------------
341 represents a widget that has start and end values. start and end
342 are gather from start/end widgets
343 --------------------------------------------------------------------- */
344 function oilsRptBetweenWidget(args) {
345 this.node = args.node;
346 this.startWidget = new args.startWidget(args);
347 this.endWidget = new args.endWidget(args);
349 oilsRptBetweenWidget.prototype.draw = function() {
350 removeChildren(this.node);
351 this.startWidget.draw();
352 this.endWidget.draw();
354 oilsRptBetweenWidget.prototype.getValue = function() {
356 this.startWidget.getValue(),
357 this.endWidget.getValue()
362 /* ---------------------------------------------------------------------
363 the most basic text input widget
364 --------------------------------------------------------------------- */
365 function oilsRptTextWidget(args) {
366 this.node = args.node;
367 this.dest = elem('input',{type:'text',size:12});
369 oilsRptTextWidget.prototype.draw = function() {
370 this.node.appendChild(this.dest);
373 /* returns the "real" value for the widget */
374 oilsRptTextWidget.prototype.getValue = function() {
375 return this.dest.value;
378 /* returns the label and "real" value for the widget */
379 oilsRptTextWidget.prototype.getDisplayValue = function() {
380 return { label : this.getValue(), value : this.getValue() };
384 /* --------------------------------------------------------------------- */
386 function oilsRptCalWidget(args) {
387 this.node = args.node;
388 this.calFormat = args.calFormat;
389 this.input = elem('input',{type:'text',size:12});
391 if( args.inputSize ) {
392 this.input.setAttribute('size',args.inputSize);
393 this.input.setAttribute('maxlength',args.inputSize);
397 oilsRptCalWidget.prototype.draw = function() {
398 this.button = DOM.generic_calendar_button.cloneNode(true);
399 this.button.id = oilsNextId();
400 this.input.id = oilsNextId();
402 this.node.appendChild(this.button);
403 this.node.appendChild(this.input);
404 unHideMe(this.button);
406 _debug('making calendar widget with format ' + this.calFormat);
409 inputField : this.input.id,
410 ifFormat : this.calFormat,
411 button : this.button.id,
417 oilsRptCalWidget.prototype.getValue = function() {
418 return this.input.value;
421 oilsRptCalWidget.prototype.getDisplayValue = function() {
422 return { label : this.getValue(), value : this.getValue() };