Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleMetric.js
index c227083..ac138f6 100644 (file)
@@ -1 +1,301 @@
-0
\ No newline at end of file
+//<script type="text/javascript">
+
+// Auto generated file - created by app.Builder.js- do not edit directly (at present!)
+
+Pman.Tab.XtupleMetric = new Roo.XComponent({
+    part     :  ["Xtuple","Metric"],
+    order    : '900-Pman.Tab.XtupleMetric',
+    region   : 'center',
+    parent   : 'Pman.Tab.Admin',
+    name     : "unnamed module",
+    disabled : false, 
+    permname : '', 
+    _tree : function()
+    {
+        var _this = this;
+        var MODULE = this;
+        return {
+            xtype: 'GridPanel',
+            xns: Roo,
+            listeners : {
+                activate : function() {
+                    _this.panel = this;
+                    if (_this.grid) {
+                        _this.grid.footer.onClick('first');
+                    }
+                }
+            },
+            background : true,
+            fitContainer : true,
+            fitToframe : true,
+            region : 'center',
+            tableName : 'metric',
+            title : "Metric",
+            grid : {
+                xtype: 'EditorGrid',
+                xns: Roo.grid,
+                listeners : {
+                    render : function() 
+                    {
+                        _this.grid = this; 
+                        if (_this.panel.active) {
+                           this.footer.onClick('first');
+                        }
+                    },
+                    afteredit : function (e)
+                    {
+                        if(e.originalValue == e.value || !e.value.length){
+                            return false;
+                        }
+                        
+                        e.record.commit();
+                    }
+                },
+                autoExpandColumn : 'metric_value',
+                clicksToEdit : 1,
+                loadMask : true,
+                dataSource : {
+                    xtype: 'Store',
+                    xns: Roo.data,
+                    listeners : {
+                        beforeload : function (_self, o){
+                            o.params = o.params || {};
+                            
+                            var s = _this.searchBox.getValue();
+                            
+                            if(!s || !s.length){
+                                return;
+                            }
+                            
+                            o.params['search[name]'] = s;
+                        },
+                        update : function (_self, record, operation)
+                        {
+                            if (operation != Roo.data.Record.COMMIT) {
+                                return;
+                            }
+                        
+                            if (!record.data.metric_name.length || !record.data.metric_value.length) {
+                                return;
+                            }
+                            
+                            new Pman.Request({
+                                url : baseURL + '/Roo/Metric',
+                                method : 'POST',
+                                params : record.data,
+                                success : function(res) {
+                                    _this.grid.footer.onClick('refresh');
+                                }
+                            });
+                            
+                        }
+                    },
+                    remoteSort : true,
+                    sortInfo : { field : 'metric_name', direction: 'ASC' },
+                    proxy : {
+                        xtype: 'HttpProxy',
+                        xns: Roo.data,
+                        method : 'GET',
+                        timeout : 90000,
+                        url : baseURL + '/Xtuple/Roo/Metric.php'
+                    },
+                    reader : {
+                        xtype: 'JsonReader',
+                        xns: Roo.data,
+                        id : 'metric_id',
+                        root : 'data',
+                        totalProperty : 'total',
+                        fields : [
+                            {
+                                'name': 'metric_id',
+                                'type': 'int'
+                            },
+                            {
+                                'name': 'metric_name',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'metric_value',
+                                'type': 'string'
+                            },
+                            {
+                                'name': 'metric_module',
+                                'type': 'string'
+                            }
+                        ]
+                    }
+                },
+                toolbar : {
+                    xtype: 'Toolbar',
+                    xns: Roo,
+                    items : [
+                        {
+                            xtype: 'TextField',
+                            xns: Roo.form,
+                            listeners : {
+                                specialkey : function (_self, e)
+                                {
+                                  _this.grid.footer.onClick('first');
+                                },
+                                render : function (_self)
+                                {
+                                    _this.searchBox = _self;
+                                }
+                            }
+                        },
+                        {
+                            xtype: 'Button',
+                            xns: Roo.Toolbar,
+                            listeners : {
+                                click : function (_self, e)
+                                {
+                                    _this.grid.footer.onClick('first');
+                                }
+                            },
+                            cls : 'x-btn-icon',
+                            icon : rootURL + '/Pman/templates/images/search.gif'
+                        },
+                        {
+                            xtype: 'Button',
+                            xns: Roo.Toolbar,
+                            listeners : {
+                                click : function (_self, e)
+                                {
+                                    _this.searchBox.setValue('');
+                                    _this.grid.footer.onClick('first');\r
+                                }
+                            },
+                            cls : 'x-btn-icon',
+                            icon : rootURL + '/Pman/templates/images/edit-clear.gif'
+                        },
+                        {
+                            xtype: 'Fill',
+                            xns: Roo.Toolbar
+                        },
+                        {
+                            xtype: 'Button',
+                            xns: Roo.Toolbar,
+                            listeners : {
+                                click : function()
+                                {
+                                    
+                                    var nr = _this.grid.ds.reader.newRow({
+                                        metric_id : 0,
+                                        metric_name : '',
+                                        metric_value : '',
+                                        metric_module : ''
+                                    });
+                                    
+                                    _this.grid.stopEditing();
+                                    _this.grid.ds.insert(0, nr); 
+                                    _this.grid.startEditing(0, 0);
+                                }
+                            },
+                            cls : 'x-btn-text-icon',
+                            text : "Add",
+                            icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
+                        },
+                        {
+                            xtype: 'Button',
+                            xns: Roo.Toolbar,
+                            listeners : {
+                                click : function ()
+                                {   
+                                    var cs = _this.grid.getSelectionModel().getSelectedCell();
+                                    
+                                    if (!cs) {
+                                        Roo.MessageBox.alert("Error", "Select a cell");
+                                        return;
+                                    }
+                                    _this.grid.stopEditing();
+                                 
+                                    var r = _this.grid.ds.getAt(cs[0]);
+                                    
+                                    Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete this metric?", function (v){
+                                        if (v != 'yes') {
+                                            return;
+                                        }
+                                        
+                                        new Pman.Request({
+                                            url : baseURL + '/Roo/Metric',
+                                            method : 'POST',
+                                            params : {
+                                                _delete : r.data.id
+                                            },
+                                            success : function(res) {
+                                                _this.grid.footer.onClick('refresh');
+                                            }
+                                        });
+                                    });
+                                }
+                            },
+                            cls : 'x-btn-text-icon',
+                            text : "Remove",
+                            icon : rootURL + '/Pman/templates/images/trash.gif'
+                        }
+                    ]
+                },
+                footer : {
+                    xtype: 'PagingToolbar',
+                    xns: Roo,
+                    displayInfo : true,
+                    emptyMsg : "No Metric found",
+                    pageSize : 50
+                },
+                colModel : [
+                    {
+                        xtype: 'ColumnModel',
+                        xns: Roo.grid,
+                        dataIndex : 'metric_name',
+                        header : 'Name',
+                        width : 250,
+                        renderer : function(v) { return String.format('{0}', v); },
+                        editor : {
+                            xtype: 'GridEditor',
+                            xns: Roo.grid,
+                            field : {
+                                xtype: 'TextField',
+                                xns: Roo.form,
+                                allowBlank : false
+                            }
+                        }
+                    },
+                    {
+                        xtype: 'ColumnModel',
+                        xns: Roo.grid,
+                        dataIndex : 'metric_value',
+                        header : 'Value',
+                        width : 150,
+                        renderer : function(v) { return String.format('{0}', v); },
+                        editor : {
+                            xtype: 'GridEditor',
+                            xns: Roo.grid,
+                            field : {
+                                xtype: 'TextField',
+                                xns: Roo.form,
+                                allowBlank : false
+                            }
+                        }
+                    },
+                    {
+                        xtype: 'ColumnModel',
+                        xns: Roo.grid,
+                        dataIndex : 'metric_module',
+                        header : 'Module',
+                        width : 100,
+                        renderer : function(v) { return String.format('{0}', v); },
+                        editor : {
+                            xtype: 'GridEditor',
+                            xns: Roo.grid,
+                            field : {
+                                xtype: 'TextField',
+                                xns: Roo.form,
+                                allowBlank : false
+                            }
+                        }
+                    }
+                ]
+            }
+        };
+    }
+});