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 /* --------------------------------------------------------------------- */
279 /* --------------------------------------------------------------------- */
280 /* --------------------------------------------------------------------- */
282 function oilsRptAtomicWidget(args) {
283 this.node = args.node;
284 this.source = args.source;
285 this.dest = elem('input',{type:'text',size:12});
287 oilsRptAtomicWidget.prototype.draw = function() {
289 appendClear(this.node, this.source);
290 appendClear(this.node, this.dest);
292 oilsRptAtomicWidget.prototype.getValue = function() {
293 return this.dest.value;
295 /* --------------------------------------------------------------------- */
296 function oilsRptListWidget(args) {
297 this.node = args.node;
298 this.source = args.source;
299 this.dest = elem('select',
300 {multiple:'multiple','class':'oils_rpt_small_info_selector'});
302 oilsRptListWidget.prototype.draw = function() {
303 appendClear(this.source);
304 appendClear(this.dest);
306 oilsRptListWidget.prototype.getValue = function() {
307 return getSelectedList(this.dest);
309 /* --------------------------------------------------------------------- */
310 function oilsRptBetweenWidget(args) {
311 this.node = args.node;
312 this.startSource = args.startSource;
313 this.endSource = args.endSource;
314 this.dest = elem('select',
315 {multiple:'multiple','class':'oils_rpt_small_info_selector'});
317 oilsRptBetweenWidget.prototype.draw = function() {
318 appendClear(this.startSource);
319 appendClear(this.endSource);
320 appendClear(this.dest);
322 oilsRptBetweenWidget.prototype.getValue = function() {
323 return getSelectedList(this.dest);