Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleMetric.bjs
index c4e4221..733f542 100644 (file)
@@ -21,7 +21,7 @@
                 {
                     "listeners": {
                         "|render": "function() \n{\n    _this.grid = this; \n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
-                        "beforeedit": "function (e)\n{\n    Roo.log(e);\n}"
+                        "afteredit": "function (e)\n{\n    if(e.originalValue == e.value || !e.value.length){\n        return false;\n    }\n    \n    e.record.commit();\n}"
                     },
                     "*prop": "grid",
                     "autoExpandColumn": "metric_value",
@@ -32,7 +32,8 @@
                     "items": [
                         {
                             "listeners": {
-                                "beforeload": "function (_self, o){\n    o.params = o.params || {};\n    \n    var s = _this.searchBox.getValue();\n    \n    if(!s || !s.length){\n        return;\n    }\n    \n    o.params['search[name]'] = s;\n}\n"
+                                "beforeload": "function (_self, o){\n    o.params = o.params || {};\n    \n    var s = _this.searchBox.getValue();\n    \n    if(!s || !s.length){\n        return;\n    }\n    \n    o.params['search[name]'] = s;\n}\n",
+                                "update": "function (_self, record, operation)\n{\n    if (operation != Roo.data.Record.COMMIT) {\n        return;\n    }\n\n    if (!record.data.metric_name.length || !record.data.metric_value.length) {\n        return;\n    }\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/Metric',\n        method : 'POST',\n        params : record.data,\n        success : function(res) {\n            _this.grid.footer.onClick('refresh');\n        }\n    });\n    \n}"
                             },
                             "*prop": "dataSource",
                             "remoteSort": true,
                                 },
                                 {
                                     "listeners": {
-                                        "|click": "function()\n{\n\n   Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {\n        _this.grid.footer.onClick('first');\n   }); \n}\n"
+                                        "|click": "function()\n{\n    \n    var nr = _this.grid.ds.reader.newRow({\n        metric_id : 0,\n        metric_name : '',\n        metric_value : '',\n        metric_module : ''\n    });\n    \n    _this.grid.stopEditing();\n    _this.grid.ds.insert(0, nr); \n    _this.grid.startEditing(0, 0);\n}\n"
                                     },
                                     "cls": "x-btn-text-icon",
                                     "text": "Add",
                                     "xtype": "Button",
                                     "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
                                     "|xns": "Roo.Toolbar"
+                                },
+                                {
+                                    "listeners": {
+                                        "|click": "function ()\n{   \n    var cs = _this.grid.getSelectionModel().getSelectedCell();\n    \n    if (!cs) {\n        Roo.MessageBox.alert(\"Error\", \"Select a cell\");\n        return;\n    }\n    _this.grid.stopEditing();\n \n    var r = _this.grid.ds.getAt(cs[0]);\n    \n    Roo.MessageBox.confirm(\"Confirm\", \"Are you sure you want to delete this metric?\", function (v){\n        if (v != 'yes') {\n            return;\n        }\n        \n        new Pman.Request({\n            url : baseURL + '/Roo/Metric',\n            method : 'POST',\n            params : {\n                _delete : r.data.id\n            },\n            success : function(res) {\n                _this.grid.footer.onClick('refresh');\n            }\n        });\n    });\n}"
+                                    },
+                                    "cls": "x-btn-text-icon",
+                                    "text": "Remove",
+                                    "xtype": "Button",
+                                    "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
+                                    "|xns": "Roo.Toolbar"
                                 }
                             ]
                         },
                             "xtype": "PagingToolbar",
                             "|xns": "Roo"
                         },
-                        {
-                            "*prop": "colModel[]",
-                            "dataIndex": "metric_id",
-                            "header": "ID",
-                            "width": 75,
-                            "xtype": "ColumnModel",
-                            "|renderer": "function(v) { return String.format('{0}', v); }",
-                            "|xns": "Roo.grid"
-                        },
                         {
                             "*prop": "colModel[]",
                             "dataIndex": "metric_name",
                             "header": "Name",
-                            "width": 150,
+                            "width": 250,
                             "xtype": "ColumnModel",
                             "|renderer": "function(v) { return String.format('{0}', v); }",
                             "|xns": "Roo.grid",
                             "width": 150,
                             "xtype": "ColumnModel",
                             "|renderer": "function(v) { return String.format('{0}', v); }",
-                            "|xns": "Roo.grid"
+                            "|xns": "Roo.grid",
+                            "items": [
+                                {
+                                    "|xns": "Roo.grid",
+                                    "xtype": "GridEditor",
+                                    "*prop": "editor",
+                                    "items": [
+                                        {
+                                            "*prop": "field",
+                                            "allowBlank": false,
+                                            "xtype": "TextField",
+                                            "|xns": "Roo.form"
+                                        }
+                                    ]
+                                }
+                            ]
                         },
                         {
                             "*prop": "colModel[]",
                             "width": 100,
                             "xtype": "ColumnModel",
                             "|renderer": "function(v) { return String.format('{0}', v); }",
-                            "|xns": "Roo.grid"
+                            "|xns": "Roo.grid",
+                            "items": [
+                                {
+                                    "|xns": "Roo.grid",
+                                    "xtype": "GridEditor",
+                                    "*prop": "editor",
+                                    "items": [
+                                        {
+                                            "*prop": "field",
+                                            "allowBlank": false,
+                                            "xtype": "TextField",
+                                            "|xns": "Roo.form"
+                                        }
+                                    ]
+                                }
+                            ]
                         }
                     ]
                 }