Fix #7123 - getting abra ready to test
[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                                     var nr = _this.grid.ds.reader.newRow({
183                                         metric_id : 0,
184                                         metric_name : '',
185                                         metric_value : '',
186                                         metric_module : ''
187                                     });
188                                     
189                                     _this.grid.stopEditing();
190                                     _this.grid.ds.insert(0, nr); 
191                                     _this.grid.startEditing(0, 0);
192                                 }
193                             },
194                             cls : 'x-btn-text-icon',
195                             text : "Add",
196                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
197                         },
198                         {
199                             xtype: 'Button',
200                             xns: Roo.Toolbar,
201                             listeners : {
202                                 click : function ()
203                                 {   
204                                     var cs = _this.grid.getSelectionModel().getSelectedCell();
205                                     
206                                     if (!cs) {
207                                         Roo.MessageBox.alert("Error", "Select a cell");
208                                         return;
209                                     }
210                                     _this.grid.stopEditing();
211                                  
212                                     var r = _this.grid.ds.getAt(cs[0]);
213                                     
214                                     Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete this metric?", function (v){
215                                         if (v != 'yes') {
216                                             return;
217                                         }
218                                         
219                                         new Pman.Request({
220                                             url : baseURL + '/Roo/Metric',
221                                             method : 'POST',
222                                             params : {
223                                                 _delete : r.data.id
224                                             },
225                                             success : function(res) {
226                                                 _this.grid.footer.onClick('refresh');
227                                             }
228                                         });
229                                     });
230                                 }
231                             },
232                             cls : 'x-btn-text-icon',
233                             text : "Remove",
234                             icon : rootURL + '/Pman/templates/images/trash.gif'
235                         }
236                     ]
237                 },
238                 footer : {
239                     xtype: 'PagingToolbar',
240                     xns: Roo,
241                     displayInfo : true,
242                     emptyMsg : "No Metric found",
243                     pageSize : 50
244                 },
245                 colModel : [
246                     {
247                         xtype: 'ColumnModel',
248                         xns: Roo.grid,
249                         dataIndex : 'metric_name',
250                         header : 'Name',
251                         width : 250,
252                         renderer : function(v) { return String.format('{0}', v); },
253                         editor : {
254                             xtype: 'GridEditor',
255                             xns: Roo.grid,
256                             field : {
257                                 xtype: 'TextField',
258                                 xns: Roo.form,
259                                 allowBlank : false
260                             }
261                         }
262                     },
263                     {
264                         xtype: 'ColumnModel',
265                         xns: Roo.grid,
266                         dataIndex : 'metric_value',
267                         header : 'Value',
268                         width : 150,
269                         renderer : function(v) { return String.format('{0}', v); },
270                         editor : {
271                             xtype: 'GridEditor',
272                             xns: Roo.grid,
273                             field : {
274                                 xtype: 'TextField',
275                                 xns: Roo.form,
276                                 allowBlank : false
277                             }
278                         }
279                     },
280                     {
281                         xtype: 'ColumnModel',
282                         xns: Roo.grid,
283                         dataIndex : 'metric_module',
284                         header : 'Module',
285                         width : 100,
286                         renderer : function(v) { return String.format('{0}', v); },
287                         editor : {
288                             xtype: 'GridEditor',
289                             xns: Roo.grid,
290                             field : {
291                                 xtype: 'TextField',
292                                 xns: Roo.form,
293                                 allowBlank : false
294                             }
295                         }
296                     }
297                 ]
298             }
299         };
300     }
301 });