]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/reports/oils_rpt_widget.js
ever more toil
[working/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
30 oilsRptSetSubClass('oilsRptMultiWidget', 'oilsRptWidget');
31 function oilsRptMultiWidget(args) {
32         this.init(args);
33 }
34
35 oilsRptMultiWidget.prototype.init = function(args) {
36         if(!args) return;
37         this.super.init(args);
38         this.dest = elem('select',
39                 {multiple:'multiple','class':'oils_rpt_info_selector'});
40         this.addButton = elem('button',null, 'Add');
41         this.addButton = this.getSourceCollector();
42 }
43
44 oilsRptMultiWidget.prototype.getValue = function() {
45         var vals = [];
46         for( var i = 0; i < this.dest.options.length; i++ )
47                 vals.push(this.dest.options[i].value);
48         return vals;
49 }
50
51 oilsRptMultiWidget.prototype.removeSelected = function() {
52         oilsDeleteSelectedItems(this.dest);
53 }
54
55 oilsRptMultiWidget.prototype.addItem = function(name, val) {
56         for( var i = 0; i < this.dest.options.length; i++ )
57                 if( this.dest.options[i].value == val ) 
58                         return;
59         insertSelectorVal(this.dest, -1, name, val);
60 }
61
62 oilsRptMultiWidget.prototype.setSource = function(src) {
63         this.source = src;
64 }
65
66 oilsRptMultiWidget.prototype.draw = function() {
67         appendClear(this.node, this.source);
68         appendClear(this.node, this.dest);
69 }
70
71
72 /* ----------------------------------------------------------- */
73
74 oilsRptSetSubClass('oilsRptInputMultiWidget', 'oilsRptMultiWidget');
75 function oilsRptInputMultiWidget(args) {
76         this.init(args);
77 }
78 oilsRptInputMultiWidget.prototype.init = function(args) {
79         if(!args) return;
80         this.super.init(args);
81         this.setSource(elem('input',{type:'text'}));
82 }
83
84 oilsRptInputMultiWidget.prototype.addItem = function(name, val) {
85         this.super.addItem(name, val);
86         this.source.value = "";
87         this.source.focus();
88 }
89
90 oilsRptInputMultiWidget.prototype.getSourceCollector = function() {
91         var obj = this;
92         return function() {
93                 obj.addItem(obj.source.value, obj.source.value);
94         }
95 }
96
97 /* ----------------------------------------------------------- */
98
99 oilsRptSetSubClass('oilsRptSelectorMultiWidget', 'oilsRptMultiWidget');
100 function oilsRptSelectorMultiWidget(args) {
101         this.init(args);
102 }
103 oilsRptSelectorMultiWidget.prototype.init = function(args) {
104         if(!args) return;
105         this.super.init(args);
106         this.setSource(
107                 elem('select',{multiple:multiple, 'class':'oils_rpt_info_selector'}));
108 }
109
110 oilsRptSelectorMultiWidget.prototype.getSourceCollector = function() {
111         var obj = this;
112         return function() {
113                 for( var i = 0; i < obj.source.options.length; i++ )
114                         obj.addItem(obj.source.options.name, obj.source.options.value);
115         }
116 }
117
118 /* ----------------------------------------------------------- */
119
120 oilsRptSetSubClass('oilsRptRemoteWidget', 'oilsRptSelectorMultiWidget');
121 function oilsRptRemoteWidget(args) {
122         this.init(args);
123 }
124 oilsRptRemoteWidget.prototype.init = function(args) {
125         if(!args) return;
126         this.super.init(args);
127         this.selector = args.selector;
128 }
129
130 oilsRptRemoteWidget.prototype.draw = function() {
131         this.fetch();
132         this.super.draw();
133 }
134
135 oilsRptRemoteWidget.prototype.setFetch = function(func) {
136         this.fetch = func;
137 }
138
139
140
141
142