]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/reports/oils_rpt_builder_widgets.js
Fix order of oils_i18n_gettext elements
[Evergreen.git] / Open-ILS / web / reports / oils_rpt_builder_widgets.js
1 function oilsRptBuilderWidget(node) {
2         this.init(node);
3 }
4
5 oilsRptBuilderWidget.prototype.init = function(node) {
6         if(!node) return;
7         this.node = node;
8         _debug(this.node.id);
9
10         this.selector = $n(this.node, 'selector');
11 //      this.widgetNode = $n(this.node, 'widget_td');
12         var obj = this;
13         this.selector.onchange = function() { 
14                 obj.showWidgets(
15                         obj.selector.options[obj.selector.selectedIndex]);
16         }
17         //this.hideWidgets();
18 }
19
20
21 /*
22 oilsRptBuilderWidget.prototype.hideWidgets = function(node) {
23         if(!node) node = this.widgetNode;
24         if( node.nodeType != 1 ) return;
25         if( node.getAttribute('widget') ) {
26                 hideMe(node);
27         } else {
28                 var cs = node.childNodes;
29                 for( var i = 0; cs && i < cs.length; i++ )
30                         this.hideWidgets(cs[i]);
31         }
32 }
33
34
35 oilsRptBuilderWidget.prototype.showWidgets = function(opt) {
36         _debug("showing widget with opt value: "+opt.value);
37         this.hideWidgets();
38         var widget = opt.getAttribute('widget');
39         if( widget ) unHideMe($n(this.node, widget));
40 }
41 */
42
43 oilsRptBuilderWidget.prototype.getCurrentOpt = function() {
44         return this.selector.options[this.selector.selectedIndex];
45 }
46
47
48
49
50 /* ------------------------------------------------------------------------- */
51 oilsRptTFormManager.prototype = new oilsRptBuilderWidget();
52 oilsRptTFormManager.prototype.constructor = oilsRptTFormManager;
53 oilsRptTFormManager.baseClass = oilsRptBuilderWidget.prototype.constructor;
54 function oilsRptTFormManager(node) { this.init(node); }
55
56 /* displays the appropriate transforms for the given types and flags */
57 oilsRptTFormManager.prototype.build = function( dtype, show_agg, show_noagg ) {
58         for( var i = 0; i < this.selector.options.length; i++ ) {
59                 var opt = this.selector.options[i];
60                 var t = opt.getAttribute('datatype');
61                 if( t && t != dtype ){
62                         hideMe(opt);
63                 } else {
64                         var ag = opt.getAttribute('aggregate');
65                         if( ag && show_agg )
66                                 unHideMe(opt);
67                         else if( ag && ! show_agg )
68                                 hideMe(opt)
69                         else if( !ag && show_noagg )
70                                 unHideMe(opt);
71                         else hideMe(opt);
72                 }
73         }
74 }
75
76 oilsRptTFormManager.prototype.getCurrentTForm = function() {
77         var opt = this.getCurrentOpt();
78         var data = {
79                 value            : opt.value,
80                 datatype  : opt.getAttribute('datatype'),
81                 aggregate : opt.getAttribute('aggregate'),
82         };
83         //data.params = this.getWidgetParams(data);
84         return data;
85 }
86
87
88 /*
89 oilsRptTFormManager.prototype.getWidgetParams = function(obj) {
90         switch(obj.datatype) {
91                 case 'string' :
92                         switch(obj.value) {
93                                 case 'substring':
94                                         return [ 
95                                                 $n(this.widgetNode, 'string_substring_offset').value,
96                                                 $n(this.widgetNode, 'string_substring_length').value
97                                         ];
98                         }
99         }
100         return null;
101 }
102 */
103
104
105
106
107 /* ------------------------------------------------------------------------- */
108
109 oilsRptOpManager.prototype = new oilsRptBuilderWidget();
110 oilsRptOpManager.prototype.constructor = oilsRptOpManager;
111 oilsRptOpManager.baseClass = oilsRptBuilderWidget.prototype.constructor;
112 function oilsRptOpManager(node) { this.init(node); }
113
114