LP#1329503 text input repairs
[working/Evergreen.git] / Open-ILS / web / reports / oils_rpt_widget.js
1 /* --------------------------------------------------------------------- 
2         Represents a set of values, an inputWidget collects data and a 
3         multi-select displays the data and allows the user to remove items
4         --------------------------------------------------------------------- */
5 function oilsRptSetWidget(args) {
6         this.node = args.node;
7     this.seedValue = args.value;
8         this.inputWidget = new args.inputWidget(args);
9     this.readonly = Boolean(args.readonly);
10     this.asyncInput = args.async;
11         this.dest = elem('select',
12                 {multiple:'multiple','class':'oils_rpt_small_info_selector'});
13     this.dest.disabled = this.readonly;
14 }
15
16 oilsRptSetWidget.prototype.draw = function() {
17
18         this.addButton = elem('input',{type:'submit',value:"Add"})
19         this.delButton = elem('input',{type:'submit',value:"Del"})
20         this.addButton.disabled = this.readonly;
21         this.delButton.disabled = this.readonly;
22
23         var obj = this;
24         this.addButton.onclick = function() {
25                 obj.addDisplayItems(obj.inputWidget.getDisplayValue());
26         if (obj.inputWidget instanceof oilsRptTextWidget) {
27             // clear the value
28             obj.inputWidget.dest.value = '';
29         }
30         }
31
32         this.delButton.onclick = function(){obj.removeSelected()};
33
34         removeChildren(this.node);
35
36     var this_ = this;
37     var post_draw = function() {
38         if (this_.seedValue && this_.seedValue.length) {
39             if (this_.inputWidget instanceof oilsRptTextWidget) {
40                 // add each seed value to the input widget, then 
41                 // propagate the value into our multiselect.
42                 // when done, clear the value from the text widget.
43                 dojo.forEach(this_.seedValue, function(val) {
44                     this_.inputWidget.dest.value = val;
45                     this_.addButton.onclick();
46                 });
47                 this_.inputWidget.dest.value = '';
48
49             } else {
50                 this_.addButton.onclick();
51             }
52         }
53     }
54
55         this.inputWidget.draw(null, post_draw);
56         this.node.appendChild(elem('br'))
57         this.node.appendChild(this.addButton);
58         this.node.appendChild(this.delButton);
59         this.node.appendChild(elem('br'))
60         this.node.appendChild(this.dest);
61
62     if (!this.asyncInput) post_draw();
63
64 }
65
66 oilsRptSetWidget.prototype.addDisplayItems = function(list) {
67         if( list.constructor != Array ) list = [list];
68         for(var i = 0; i < list.length; i++) {
69                 var item = list[i];
70
71                 /* no dupes */
72                 var exists = false;
73                 iterate(this.dest.options, 
74                         function(o){if(o.getAttribute('value') == item.value) {exists = true; return;}});
75                 if(exists) continue;
76
77                 _debug('Inserting SetWidget values ' + js2JSON(item));
78                 insertSelectorVal(this.dest, -1, item.label, this.objToStr(item.value));
79         }
80 }
81
82 oilsRptSetWidget.prototype.removeSelected = function() {
83         oilsDelSelectedItems(this.dest);
84 }
85
86 oilsRptSetWidget.prototype.getValue = function() {
87         var vals = [];
88         var obj = this;
89         iterate(this.dest, function(i){vals.push(obj.strToObj(i.getAttribute('value')))});
90         return vals;
91 }
92
93 oilsRptSetWidget.prototype.objToStr = function(obj) {
94         if( typeof obj == 'string' ) return obj;
95         //return ':'+obj.transform+':'+obj.params[0];
96         var str = ':'+obj.transform;
97         for( var i = 0; i < obj.params.length; i++ ) 
98                 str += ':' + obj.params[i];
99         _debug("objToStr(): built string " + str);
100         return str;
101
102 }
103
104 oilsRptSetWidget.prototype.strToObj = function(str) {
105         if( str.match(/^:.*/) ) {
106                 var parts = str.split(/:/);
107                 _debug("strToObj(): " + str + ' : ' + parts);
108                 parts.shift();
109                 var tform = parts.shift();
110                 //var tform = str.replace(/^:(.*):.*/,'$1');
111                 //var param = str.replace(/^:.*:(.*)/,'$1');
112                 return { transform : tform, params : parts };
113         }
114         return str;
115 }
116
117
118 /* --------------------------------------------------------------------- 
119         represents a widget that has start and end values.  start and end
120         are gathered from start/end widgets
121         --------------------------------------------------------------------- */
122 function oilsRptBetweenWidget(args) {
123         this.node = args.node;
124         var seedValue = args.value;
125         if (seedValue) args.value = seedValue[0];
126         this.startWidget = new args.startWidget(args);
127         if (seedValue) args.value = seedValue[1];
128         this.endWidget = new args.endWidget(args);
129 }
130 oilsRptBetweenWidget.prototype.draw = function() {
131         removeChildren(this.node);
132         this.startWidget.draw();
133         this.node.appendChild(elem('hr'));
134         this.node.appendChild(elem('div',
135                 {style:'text-align:center;width:100%;font-weight:bold'},' - And - '));
136         this.node.appendChild(elem('hr'));
137         this.endWidget.draw();
138 }
139 oilsRptBetweenWidget.prototype.getValue = function() {
140         return [
141                 this.startWidget.getValue(),
142                 this.endWidget.getValue()
143         ];
144 }
145
146
147
148
149 /* --------------------------------------------------------------------- 
150         ATOMIC WIDGETS
151         --------------------------------------------------------------------- */
152
153
154 /* --------------------------------------------------------------------- 
155         Atomic text input widget
156         --------------------------------------------------------------------- */
157 function oilsRptTextWidget(args) {
158         this.node = args.node;
159     this.seedValue = args.value;
160         this.dest = elem('input',{type:'text',size:12});
161     this.dest.disabled = Boolean(args.readonly);
162         oilsRptMonitorWidget(this.dest);
163 }
164 oilsRptTextWidget.prototype.draw = function() {
165         this.node.appendChild(this.dest);
166     if (this.seedValue) {
167         this.dest.value = this.seedValue;
168         this.dest.onchange(); // validation
169     }
170 }
171
172 /* returns the "real" value for the widget */
173 oilsRptTextWidget.prototype.getValue = function() {
174         return this.dest.value;
175 }
176
177 /* returns the label and "real" value for the widget */
178 oilsRptTextWidget.prototype.getDisplayValue = function() {
179         return { label : this.getValue(), value : this.getValue() };
180 }
181
182
183
184 /* --------------------------------------------------------------------- 
185         Atomic bool input widget
186         --------------------------------------------------------------------- */
187 function oilsRptBoolWidget(args) {
188         this.node = args.node;
189     this.seedValue = args.value;
190         this.selector = elem('select');
191         insertSelectorVal(this.selector, -1,'True','t');
192         insertSelectorVal(this.selector, -1,'False','f');
193     this.selector.disabled = Boolean(args.readonly);
194 }
195
196 oilsRptBoolWidget.prototype.draw = function() {
197         this.node.appendChild(this.selector);
198     if (this.seedValue)  
199         setSelector(this.selector, this.seedValue);
200 }
201
202 /* returns the "real" value for the widget */
203 oilsRptBoolWidget.prototype.getValue = function() {
204         return getSelectorVal(this.selector);
205 }
206
207 /* returns the label and "real" value for the widget */
208 oilsRptBoolWidget.prototype.getDisplayValue = function() {
209         var val = getSelectorVal(this.selector);
210         var label = 'True';
211         if (val == 'f') labal = 'False';
212         return { label : label, value : val };
213 }
214
215
216 /* If you monitor a text widget with this function, it 
217         will style the input differently to indicate the
218         field needs data.  If a regex is provided, it will
219         style the field differently until the data matches 
220         the regex.  The style comes from OILS_RPT_INVALID_DATA. */
221 function oilsRptMonitorWidget(input, regex) {
222         addCSSClass(input, OILS_RPT_INVALID_DATA);
223         var func = function() {
224                 var val = input.value;
225                 if(!val) {
226                         addCSSClass(input, OILS_RPT_INVALID_DATA);
227                 } else {
228                         if( regex ) {
229                                 if( val && val.match(regex) ) 
230                                         removeCSSClass(input, OILS_RPT_INVALID_DATA);
231                                 else
232                                         addCSSClass(input, OILS_RPT_INVALID_DATA);
233                         } else {
234                                 removeCSSClass(input, OILS_RPT_INVALID_DATA);
235                         }
236                 }
237         }
238
239         input.onkeyup = func;
240         input.onchange = func;
241 }
242
243
244
245
246 /* --------------------------------------------------------------------- 
247         Atomic calendar widget
248         --------------------------------------------------------------------- */
249 function oilsRptCalWidget(args) {
250         this.node = args.node;
251         this.calFormat = args.calFormat;
252         this.input = elem('input',{type:'text',size:12});
253     this.seedValue = args.value;
254     this.input.disabled = Boolean(args.readonly);
255
256         oilsRptMonitorWidget(this.input, args.regex);
257
258         if( args.inputSize ) {
259                 this.input.setAttribute('size',args.inputSize);
260                 this.input.setAttribute('maxlength',args.inputSize);
261         }
262 }
263
264 oilsRptCalWidget.prototype.draw = function() {
265         this.button = DOM.generic_calendar_button.cloneNode(true);
266         this.button.id = oilsNextId();
267         this.input.id = oilsNextId();
268
269         this.node.appendChild(this.button);
270         this.node.appendChild(this.input);
271         unHideMe(this.button);
272
273         _debug('making calendar widget with format ' + this.calFormat);
274
275         Calendar.setup({
276                 inputField      : this.input.id,
277                 ifFormat                : this.calFormat,
278                 button          : this.button.id,
279                 align                   : "Tl", 
280                 singleClick     : true
281         });
282
283     if (this.seedValue) {
284         this.input.value = this.seedValue;
285         this.input.onchange(); // validation
286     }
287 }
288
289 oilsRptCalWidget.prototype.getValue = function() {
290         return this.input.value;
291 }
292
293 oilsRptCalWidget.prototype.getDisplayValue = function() {
294         return { label : this.getValue(), value : this.getValue() };
295 }
296
297
298 /* --------------------------------------------------------------------- 
299         Atomic org widget
300         --------------------------------------------------------------------- */
301 function oilsRptOrgSelector(args) {
302         this.node = args.node;
303     this.seedValue = args.value;
304         this.selector = elem('select',
305                 {multiple:'multiple','class':'oils_rpt_small_info_selector'});
306     this.selector.disabled = Boolean(args.readonly);
307 }
308
309 oilsRptOrgSelector.prototype.draw = function(org) {
310         if(!org) org = globalOrgTree;
311         var opt = insertSelectorVal( this.selector, -1, 
312                 org.shortname(), org.id(), null, findOrgDepth(org) );
313         if( org.id() == oilsRptCurrentOrg && !this.seedValue)
314                 opt.selected = true;
315         
316         /* sometimes we need these choices 
317         if( !isTrue(findOrgType(org.ou_type()).can_have_vols()) )
318                 opt.disabled = true;
319                 */
320
321         if( org.children() ) {
322                 for( var c = 0; c < org.children().length; c++ )
323                         this.draw(org.children()[c]);
324         }
325         this.node.appendChild(this.selector);
326
327     if (this.seedValue) {
328         if (dojo.isArray(this.seedValue)) {
329             for (var i = 0; i < this.selector.options.length; i++) {
330                 var opt = this.selector.options[i];
331                 if (this.seedValue.indexOf(opt.value) > -1)
332                     opt.selected = true;
333             }
334         } else {
335             setSelector(this.selector, this.seedValue);
336         }
337     }
338 }
339
340 oilsRptOrgSelector.prototype.getValue = function() {
341         var vals = [];
342         iterate(this.selector, /* XXX this.selector.options?? */
343                 function(o){
344                         if( o.selected )
345                                 vals.push(o.getAttribute('value'))
346                 }
347         );
348         return vals;
349 }
350
351 oilsRptOrgSelector.prototype.getDisplayValue = function() {
352         var vals = [];
353         iterate(this.selector,
354                 function(o){
355                         if( o.selected )
356                                 vals.push({ label : o.innerHTML, value : o.getAttribute('value')});
357                 }
358         );
359         return vals;
360 }
361
362
363 /* --------------------------------------------------------------------- 
364         Atomic age widget
365         --------------------------------------------------------------------- */
366 function oilsRptAgeWidget(args) {
367         this.node = args.node;
368     this.seedValue = args.value;
369         this.count = elem('select');
370         this.type = elem('select');
371     this.count.disabled = Boolean(args.readonly);
372     this.type.disabled = Boolean(args.readonly);
373 }
374
375 oilsRptAgeWidget.prototype.draw = function() {
376
377         //insertSelectorVal(this.count, -1, ' -- Select One -- ', '');
378         for( var i = 1; i < 25; i++ )
379                 insertSelectorVal(this.count, -1, i, i);
380
381         //insertSelectorVal(this.type, -1, ' -- Select One -- ', '');
382         insertSelectorVal(this.type, -1, rpt_strings.WIDGET_DAYS, 'days');
383         insertSelectorVal(this.type, -1, rpt_strings.WIDGET_MONTHS, 'months');
384         insertSelectorVal(this.type, -1, rpt_strings.WIDGET_YEARS, 'years');
385         this.node.appendChild(this.count);
386         this.node.appendChild(this.type);
387
388     if (this.seedValue) { 
389         // e.g. "2months"
390         var count = this.seedValue.match(/(\d+)([^\d]+)/)[1];
391         var type = this.seedValue.match(/(\d+)([^\d]+)/)[2];
392         setSelector(this.count, count);
393         setSelector(this.type, type);
394     }
395 }
396
397 oilsRptAgeWidget.prototype.getValue = function() {
398         var count = getSelectorVal(this.count);
399         var type = getSelectorVal(this.type);
400         return count+''+type;
401 }
402
403 oilsRptAgeWidget.prototype.getDisplayValue = function() {
404         var val = { value : this.getValue() };
405         var label = getSelectorVal(this.count) + ' ';
406         for( var i = 0; i < this.type.options.length; i++ ) {
407                 var opt = this.type.options[i];
408                 if( opt.selected )
409                         label += opt.innerHTML;
410         }
411         val.label = label;
412         return val;
413 }
414
415
416
417 /* --------------------------------------------------------------------- 
418         Atomic substring picker
419         --------------------------------------------------------------------- */
420 function oilsRptSubstrWidget(args) {
421         this.node = args.node
422     this.seedValue = args.value;
423         this.data = elem('input',{type:'text',size:12})
424         this.offset = elem('input',{type:'text',size:5})
425         this.length = elem('input',{type:'text',size:5})
426     this.offset.disabled = Boolean(args.readonly);
427     this.length.disabled = Boolean(args.readonly);
428 }
429
430 oilsRptSubstrWidget.prototype.draw = function() {
431         this.node.appendChild(text('string: '))
432         this.node.appendChild(this.data);
433         this.node.appendChild(elem('br'));
434         this.node.appendChild(text('offset: '))
435         this.node.appendChild(this.offset);
436         this.node.appendChild(elem('br'));
437         this.node.appendChild(text('length: '))
438         this.node.appendChild(this.length);
439
440     if (this.seedValue) { 
441         // TODO: unested; substring currently not supported.
442         this.data.value = this.seedValue[0];
443         this.offset.value = this.seedValue[1];
444         this.length.value = this.seedValue[2];
445     }
446 }
447
448 oilsRptSubstrWidget.prototype.getValue = function() {
449         return {
450                 transform : 'substring',
451                 params : [ this.data.value, this.offset.value, this.length.value ]
452         };
453 }
454
455 oilsRptSubstrWidget.prototype.getDisplayValue = function() {
456         return {
457                 label : this.data.value + ' : ' + this.offset.value + ' : ' + this.length.value,
458                 value : this.getValue()
459         };
460 }
461
462
463 /* --------------------------------------------------------------------- 
464         Atomic number picker
465         --------------------------------------------------------------------- */
466 function oilsRptNumberWidget(args) {
467         this.node = args.node;
468     this.seedValue = args.value;
469         this.size = args.size || 32;
470         this.start = args.start;
471         this.selector = elem('select');
472     this.selector.disabled = Boolean(args.readonly);
473 }
474 oilsRptNumberWidget.prototype.draw = function() {
475         //insertSelectorVal(this.selector, -1, ' -- Select One -- ', '');
476         for( var i = this.start; i < (this.size + this.start); i++ )
477                 insertSelectorVal(this.selector, -1, i, i);
478         this.node.appendChild(this.selector);
479         var obj = this;
480
481     if (this.seedValue)
482         setSelector(this.selector, this.seedValue);
483 }
484
485 oilsRptNumberWidget.prototype.getValue = function() {
486         return getSelectorVal(this.selector);
487 }
488
489 oilsRptNumberWidget.prototype.getDisplayValue = function() {
490         return { label : this.getValue(), value : this.getValue() };
491 }
492
493 function oilsRptNullWidget(args) {
494     this.node = args.node;
495     this.type = args.type;
496 }
497 oilsRptNullWidget.prototype.draw = function() {}
498 oilsRptNullWidget.prototype.getValue = function() {
499     return null;
500 }
501
502 function oilsRptTemplateWidget(args) {
503     this.node = args.node;
504     this.value = args.value;
505 }
506 oilsRptTemplateWidget.prototype.draw = function() {
507     this.node.appendChild(text(''+this.value));
508 }
509
510 /* --------------------------------------------------------------------- 
511         Relative dates widget
512         -------------------------------------------------------------------- */
513 function oilsRptTruncPicker(args) {
514         this.node = args.node;
515         this.type = args.type;
516     this.seedValue = args.value;
517         this.realSpan = elem('span');
518         this.relSpan = elem('span');
519         hideMe(this.relSpan);
520         args.node = this.realSpan;
521         this.calWidget = new oilsRptCalWidget(args);
522         args.node = this.node;
523
524         this.selector = elem('select');
525         insertSelectorVal(this.selector,-1,rpt_strings.WIDGET_REAL_DATE,1);
526         insertSelectorVal(this.selector,-1,rpt_strings.WIDGET_RELATIVE_DATE,2);
527     this.selector.disabled = Boolean(args.readonly);
528
529         this.numberPicker = 
530                 new oilsRptNumberWidget(
531             {node:this.relSpan,size:90,start:1,readonly:args.readonly});
532
533         this.label = 'Day(s)';
534         if(this.type == 'month') this.label = rpt_strings.WIDGET_MONTHS;
535         if(this.type == 'quarter') this.label = rpt_strings.WIDGET_QUARTERS;
536         if(this.type == 'year') this.label = rpt_strings.WIDGET_YEARS;
537         if(this.type == 'date') this.label = rpt_strings.WIDGET_DAYS;
538 }
539
540 oilsRptTruncPicker.prototype.draw = function() {
541         this.node.appendChild(this.selector);
542         this.node.appendChild(this.realSpan);
543         this.node.appendChild(this.relSpan);
544         this.calWidget.draw();
545         this.numberPicker.draw();
546         this.relSpan.appendChild(text(this.label+' ago'));
547
548         var obj = this;
549         this.selector.onchange = function() {
550                 if( getSelectorVal(obj.selector) == 1 ) {
551                         unHideMe(obj.realSpan);
552                         hideMe(obj.relSpan);
553                 } else {
554                         unHideMe(obj.relSpan);
555                         hideMe(obj.realSpan);
556                 }
557         }
558
559     if (seed = this.seedValue) {
560         if (typeof seed == 'string') {
561             this.calWidget.value = seed;
562         } else {
563             // relative date transform
564             if (seed.transform.match(/relative/)) {
565                 setSelector(this.selector, 2)
566                 setSelector(this.numberPicker.selector, 
567                     Math.abs(seed.params[0]));
568                             unHideMe(this.relSpan);
569                             hideMe(this.realSpan);
570             }
571         }
572     }
573 }
574
575 oilsRptTruncPicker.prototype.getValue = function() {
576         if( getSelectorVal(this.selector) == 2) {
577                 var val = this.numberPicker.getValue();
578                 var tform = 'relative_' + this.type;
579                 return { transform : tform, params : ['-'+val] };
580         }
581         return this.calWidget.getValue();
582 }
583
584 oilsRptTruncPicker.prototype.getDisplayValue = function() {
585         if( getSelectorVal(this.selector) == 2) {
586                 var num = this.numberPicker.getValue();
587                 return { label : num +' '+this.label+' ago', value : this.getValue() };
588         }
589         return this.calWidget.getDisplayValue();
590 }
591
592
593 /* --------------------------------------------------------------------- 
594         Atomic remote object picker
595         --------------------------------------------------------------------- */
596
597 function oilsRptRemoteWidget(args) {
598         this.node       = args.node;
599         this.class      = args.class;
600         this.field      = args.field;
601         this.column = args.column;
602     this.seedValue = args.value;
603         this.source = elem('select',
604                 {multiple:'multiple','class':'oils_rpt_small_info_selector'});
605     this.source.disabled = Boolean(args.readonly);
606 }
607
608 // selected is unused
609 oilsRptRemoteWidget.prototype.draw = function(selected, callback) {
610         var orgcol;
611         iterate(oilsIDL[this.class].fields,
612                 function(i) {
613                         if(i.type == 'link' && i.class == 'aou') 
614                                 orgcol = i.name;
615                 }
616         );
617
618         if(orgcol) _debug("found org column for remote widget: " + orgcol);
619
620         var orgs = [];
621         iterate(oilsRptMyOrgs,function(i){orgs.push(i.id());});
622         var req = new Request(OILS_RPT_MAGIC_FETCH, SESSION, {
623                 hint:this.class,
624                 org_column : orgcol,
625                 org : orgs
626         }); 
627
628         var obj = this;
629         this.node.appendChild(this.source);
630         req.callback(function(r){
631         // render selects values from seed data if necessary
632         obj.render(r.getResultObject());
633         if (callback) {
634             // presence of a callback suggests there is a container widget
635             // (e.g. SetWidget) for tracking our values.  Callback lets 
636             // the container extract the selected values, then we deselect
637             // in the input widget (us) since it's redundant.
638             callback();
639             dojo.forEach(obj.source.options, function(o) {
640                 o.selected = false;
641             });
642         }
643     });
644         req.send();
645 }
646
647 oilsRptRemoteWidget.prototype.render = function(objs) {
648         var selector = this.field.selector;
649         objs.sort(
650                 function(a,b){
651                         if (a[selector]() > b[selector]())
652                                 return 1;
653                         else
654                                 return -1;
655                 });
656         for( var i = 0; i < objs.length; i++ ) {
657                 var obj = objs[i];
658                 var label = obj[this.field.selector]();
659                 var value = obj[this.column]();
660                 _debug("inserted remote object "+label + ' : ' + value);
661                 var opt = insertSelectorVal(this.source, -1, label, value);
662         if (this.seedValue && (
663                 this.seedValue.indexOf(Number(value)) > -1 
664                 || this.seedValue.indexOf(''+value) > -1
665             )) {
666             opt.selected = true;
667         }
668         }
669 }
670
671 oilsRptRemoteWidget.prototype.getDisplayValue = function() {
672         var vals = [];
673         iterate(this.source,
674                 function(o){
675                         if( o.selected )
676                                 vals.push({ label : o.innerHTML, value : o.getAttribute('value')});
677                 }
678         );
679         return vals;
680 }
681
682 oilsRptRemoteWidget.prototype.getValue = function() {
683         var vals = [];
684         iterate(this.source,
685                 function(o){
686                         if( o.selected )
687                                 vals.push(o.getAttribute('value'))
688                 }
689         );
690         return vals;
691 }
692
693
694
695
696 /* --------------------------------------------------------------------- 
697         CUSTOM WIDGETS
698         --------------------------------------------------------------------- */
699
700 /* --------------------------------------------------------------------- 
701         custom my-orgs picker 
702         --------------------------------------------------------------------- */
703 function oilsRptMyOrgsWidget(node, orgid, maxorg) {
704         _debug('fetching my orgs with max org of ' + maxorg);
705         this.node = node;
706         this.orgid = orgid;
707         this.maxorg = maxorg || 1;
708         this.active = true;
709         if( maxorg < 1 ) {
710                 this.node.disabled = true;
711                 this.active = false;
712         }
713 }
714
715 oilsRptMyOrgsWidget.prototype.draw = function() {
716         if(!oilsRptMyOrgs) {
717                 var req = new Request(OILS_RPT_FETCH_ORG_FULL_PATH, this.orgid);
718                 var obj = this;
719                 req.callback(
720                         function(r) { obj.drawWidget(r.getResultObject()); }
721                 );
722                 req.send();
723         } else {
724                 this.drawWidget(oilsRptMyOrgs);
725         }
726 }
727
728 oilsRptMyOrgsWidget.prototype.drawWidget = function(orglist) {
729         var sel = this.node;
730         var started = false;
731         oilsRptMyOrgs = orglist;
732         for( var i = 0; i < orglist.length; i++ ) {
733                 var org = orglist[i];
734                 var opt = insertSelectorVal( this.node, -1, 
735                         org.name(), org.id(), null, findOrgDepth(org) );
736                 if( org.id() == this.orgid )
737                         opt.selected = true;
738                 if(!started) {
739                         if( org.id() == this.maxorg ) 
740                                 started = true;
741                         else opt.disabled = true;
742                 }
743         }
744 }
745
746 oilsRptMyOrgsWidget.prototype.getValue = function() {
747         return getSelectorVal(this.node);
748 }
749
750