Pman.Tab.XtupleMetric.bjs
[Pman.Xtuple] / Pman.Tab.XtupleMetric.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Tab.XtupleMetric = new Roo.XComponent({
6     part     :  ["Xtuple","Metric"],
7     order    : '900-Pman.Tab.XtupleMetric',
8     region   : 'center',
9     parent   : 'Pman.Tab.Admin',
10     name     : "unnamed module",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'GridPanel',
19             xns: Roo,
20             listeners : {
21                 activate : function() {
22                     _this.panel = this;
23                     if (_this.grid) {
24                         _this.grid.footer.onClick('first');
25                     }
26                 }
27             },
28             background : true,
29             fitContainer : true,
30             fitToframe : true,
31             region : 'center',
32             tableName : 'metric',
33             title : "Metric",
34             grid : {
35                 xtype: 'EditorGrid',
36                 xns: Roo.grid,
37                 listeners : {
38                     render : function() 
39                     {
40                         _this.grid = this; 
41                         if (_this.panel.active) {
42                            this.footer.onClick('first');
43                         }
44                     },
45                     afteredit : function (e)
46                     {
47                         if(e.originalValue == e.value || !e.value.length){
48                             return false;
49                         }
50                         
51                         e.record.commit();
52                     }
53                 },
54                 autoExpandColumn : 'metric_value',
55                 clicksToEdit : 1,
56                 loadMask : true,
57                 dataSource : {
58                     xtype: 'Store',
59                     xns: Roo.data,
60                     listeners : {
61                         beforeload : function (_self, o){
62                             o.params = o.params || {};
63                             
64                             var s = _this.searchBox.getValue();
65                             
66                             if(!s || !s.length){
67                                 return;
68                             }
69                             
70                             o.params['search[name]'] = s;
71                         },
72                         update : function (_self, record, operation)
73                         {
74                             if (operation != Roo.data.Record.COMMIT) {
75                                 return;
76                             }
77                         
78                             if (!record.data.metric_name.length || !record.data.metric_value.length) {
79                                 return;
80                             }
81                             
82                             new Pman.Request({
83                                 url : baseURL + '/Roo/Metric',
84                                 method : 'POST',
85                                 params : record.data,
86                                 success : function(res) {
87                                     _this.grid.footer.onClick('refresh');
88                                 }
89                             });
90                             
91                         }
92                     },
93                     remoteSort : true,
94                     sortInfo : { field : 'metric_name', direction: 'ASC' },
95                     proxy : {
96                         xtype: 'HttpProxy',
97                         xns: Roo.data,
98                         method : 'GET',
99                         timeout : 90000,
100                         url : baseURL + '/Xtuple/Roo/Metric.php'
101                     },
102                     reader : {
103                         xtype: 'JsonReader',
104                         xns: Roo.data,
105                         id : 'metric_id',
106                         root : 'data',
107                         totalProperty : 'total',
108                         fields : [
109                             {
110                                 'name': 'metric_id',
111                                 'type': 'int'
112                             },
113                             {
114                                 'name': 'metric_name',
115                                 'type': 'string'
116                             },
117                             {
118                                 'name': 'metric_value',
119                                 'type': 'string'
120                             },
121                             {
122                                 'name': 'metric_module',
123                                 'type': 'string'
124                             }
125                         ]
126                     }
127                 },
128                 toolbar : {
129                     xtype: 'Toolbar',
130                     xns: Roo,
131                     items : [
132                         {
133                             xtype: 'TextField',
134                             xns: Roo.form,
135                             listeners : {
136                                 specialkey : function (_self, e)
137                                 {
138                                   _this.grid.footer.onClick('first');
139                                 },
140                                 render : function (_self)
141                                 {
142                                     _this.searchBox = _self;
143                                 }
144                             }
145                         },
146                         {
147                             xtype: 'Button',
148                             xns: Roo.Toolbar,
149                             listeners : {
150                                 click : function (_self, e)
151                                 {
152                                     _this.grid.footer.onClick('first');
153                                 }
154                             },
155                             cls : 'x-btn-icon',
156                             icon : rootURL + '/Pman/templates/images/search.gif'
157                         },
158                         {
159                             xtype: 'Button',
160                             xns: Roo.Toolbar,
161                             listeners : {
162                                 click : function (_self, e)
163                                 {
164                                     _this.searchBox.setValue('');
165                                     _this.grid.footer.onClick('first');\r
166                                 }
167                             },
168                             cls : 'x-btn-icon',
169                             icon : rootURL + '/Pman/templates/images/edit-clear.gif'
170                         },
171                         {
172                             xtype: 'Fill',
173                             xns: Roo.Toolbar
174                         },
175                         {
176                             xtype: 'Button',
177                             xns: Roo.Toolbar,
178                             listeners : {
179                                 click : function()
180                                 {
181                                 
182                                    Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {
183                                         _this.grid.footer.onClick('first');
184                                    }); 
185                                 }
186                             },
187                             cls : 'x-btn-text-icon',
188                             text : "Add",
189                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
190                         }
191                     ]
192                 },
193                 footer : {
194                     xtype: 'PagingToolbar',
195                     xns: Roo,
196                     displayInfo : true,
197                     emptyMsg : "No Metric found",
198                     pageSize : 50
199                 },
200                 colModel : [
201                     {
202                         xtype: 'ColumnModel',
203                         xns: Roo.grid,
204                         dataIndex : 'metric_name',
205                         header : 'Name',
206                         width : 250,
207                         renderer : function(v) { return String.format('{0}', v); },
208                         editor : {
209                             xtype: 'GridEditor',
210                             xns: Roo.grid,
211                             field : {
212                                 xtype: 'TextField',
213                                 xns: Roo.form,
214                                 allowBlank : false
215                             }
216                         }
217                     },
218                     {
219                         xtype: 'ColumnModel',
220                         xns: Roo.grid,
221                         dataIndex : 'metric_value',
222                         header : 'Value',
223                         width : 150,
224                         renderer : function(v) { return String.format('{0}', v); },
225                         editor : {
226                             xtype: 'GridEditor',
227                             xns: Roo.grid,
228                             field : {
229                                 xtype: 'TextField',
230                                 xns: Roo.form,
231                                 allowBlank : false
232                             }
233                         }
234                     },
235                     {
236                         xtype: 'ColumnModel',
237                         xns: Roo.grid,
238                         dataIndex : 'metric_module',
239                         header : 'Module',
240                         width : 100,
241                         renderer : function(v) { return String.format('{0}', v); },
242                         editor : {
243                             xtype: 'GridEditor',
244                             xns: Roo.grid,
245                             field : {
246                                 xtype: 'TextField',
247                                 xns: Roo.form,
248                                 allowBlank : false
249                             }
250                         }
251                     }
252                 ]
253             }
254         };
255     }
256 });