]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/reports/oils_rpt_widget.js
made the folder window more generic, showing contents via fm_table objects
[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.init(args);
7         this.dest = elem('input',{type:'text'});
8 }
9
10 oilsRptWidget.prototype.init = function(args) {
11         if(!args) return;
12         this.super.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 oilsRptSetSubClass('oilsRptMultiInputWidget', 'oilsRptWidget');
30 function oilsRptMultiInputWidget(args) {
31         this.init(args);
32 }
33
34 oilsRptMultiInputWidget.prototype.init = function(args) {
35         if(!args) return;
36         this.super.init(args);
37         this.count = (args.count) ? args.count : 2;
38         this.dest = [];
39         for( var i = 0; i < this.count; i++ )
40                 this.dest.push(elem('input',{type:'text'}));
41 }
42
43 oilsRptMultiInputWidget.prototype.getValue = function() {
44         var vals = [];
45         for( var i = 0; i < this.dest.length; i++ )
46                 vals.push(this.dest.value);
47         return vals;
48 }
49
50 oilsRptMultiInputWidget.prototype.draw = function() {
51         removeChildren(this.node);
52         for( var i = 0; i < this.dest.length; i++ ) {
53                 this.node.appendChild(this.label[i]);
54                 this.node.appendChild(this.dest[i]);
55         }
56 }
57
58 oilsRptMultiInputWidget.prototype.setLabels = function(labels) {
59         this.labels = labels;   
60 }
61
62
63
64
65 /* ----------------------------------------------------------- */
66
67 oilsRptSetSubClass('oilsRptMultiWidget', 'oilsRptWidget');
68 function oilsRptMultiWidget(args) {
69         this.init(args);
70 }
71
72 oilsRptMultiWidget.prototype.init = function(args) {
73         if(!args) return;
74         this.super.init(args);
75         this.dest = elem('select',
76                 {multiple:'multiple','class':'oils_rpt_info_selector'});
77         this.addButton = elem('button',null, 'Add');
78         this.addButton = this.getSourceCollector();
79 }
80
81 oilsRptMultiWidget.prototype.getValue = function() {
82         var vals = [];
83         for( var i = 0; i < this.dest.options.length; i++ )
84                 vals.push(this.dest.options[i].value);
85         return vals;
86 }
87
88 oilsRptMultiWidget.prototype.removeSelected = function() {
89         oilsDeleteSelectedItems(this.dest);
90 }
91
92 oilsRptMultiWidget.prototype.addItem = function(name, val) {
93         for( var i = 0; i < this.dest.options.length; i++ )
94                 if( this.dest.options[i].value == val ) 
95                         return;
96         insertSelectorVal(this.dest, -1, name, val);
97 }
98
99 oilsRptMultiWidget.prototype.setSource = function(src) {
100         this.source = src;
101 }
102
103 oilsRptMultiWidget.prototype.draw = function() {
104         appendClear(this.node, this.source);
105         appendClear(this.node, this.dest);
106 }
107
108
109 /* ----------------------------------------------------------- */
110
111 oilsRptSetSubClass('oilsRptInputMultiWidget', 'oilsRptMultiWidget');
112 function oilsRptInputMultiWidget(args) {
113         this.init(args);
114 }
115 oilsRptInputMultiWidget.prototype.init = function(args) {
116         if(!args) return;
117         this.super.init(args);
118         this.setSource(elem('input',{type:'text'}));
119 }
120
121 oilsRptInputMultiWidget.prototype.addItem = function(name, val) {
122         this.super.addItem(name, val);
123         this.source.value = "";
124         this.source.focus();
125 }
126
127 oilsRptInputMultiWidget.prototype.getSourceCollector = function() {
128         var obj = this;
129         return function() {
130                 obj.addItem(obj.source.value, obj.source.value);
131         }
132 }
133
134 /* ----------------------------------------------------------- */
135
136 oilsRptSetSubClass('oilsRptSelectorMultiWidget', 'oilsRptMultiWidget');
137 function oilsRptSelectorMultiWidget(args) {
138         this.init(args);
139 }
140 oilsRptSelectorMultiWidget.prototype.init = function(args) {
141         if(!args) return;
142         this.super.init(args);
143         this.setSource(
144                 elem('select',{multiple:multiple, 'class':'oils_rpt_info_selector'}));
145 }
146
147 oilsRptSelectorMultiWidget.prototype.getSourceCollector = function() {
148         var obj = this;
149         return function() {
150                 for( var i = 0; i < obj.source.options.length; i++ )
151                         obj.addItem(obj.source.options.name, obj.source.options.value);
152         }
153 }
154
155 /* ----------------------------------------------------------- */
156
157 oilsRptSetSubClass('oilsRptRemoteWidget', 'oilsRptSelectorMultiWidget');
158 function oilsRptRemoteWidget(args) {
159         this.init(args);
160 }
161 oilsRptRemoteWidget.prototype.init = function(args) {
162         if(!args) return;
163         this.super.init(args);
164         this.selector = args.selector;
165 }
166
167 oilsRptRemoteWidget.prototype.draw = function() {
168         this.fetch();
169         this.super.draw();
170 }
171
172 oilsRptRemoteWidget.prototype.setFetch = function(func) {
173         this.fetch = func;
174 }
175
176
177
178
179