Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleReports.bjs
index 79834c1..32528ed 100644 (file)
@@ -1,5 +1,5 @@
 {
-    "id": "roo-file-527",
+    "id": "roo-file-384",
     "name": "Pman.Tab.XtupleReports",
     "parent": "Pman.Tab.Admin",
     "title": "",
                         },
                         {
                             "*prop": "east",
+                            "split": true,
                             "title": "Versions",
                             "titlebar": true,
-                            "width": 150,
+                            "width": 200,
                             "xtype": "LayoutRegion",
                             "|xns": "Roo"
                         },
@@ -44,7 +45,7 @@
                                 {
                                     "listeners": {
                                         "|render": "function() \n{\n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
-                                        "|rowdblclick": "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\n        _this.grid.footer.onClick('first');\n    }); \n}\n"
+                                        "rowdblclick": "function (_self, rowIndex, e)\n{\n    var rec = this.ds.getAt(rowIndex);\n    new Pman.Download({\n        url : baseURL + '/Roo/Report/' + rec.data.report_name +'-' + rec.data.report_id + '.rpt',\n        method : 'GET',\n        params : {\n            _id : rec.data.report_id,\n            _download : 1\n        }\n    });\n    Roo.MessageBox.alert(\"Downloading\",\n    \n       \"Report template is downloading - use \" +\n           '<a target=\"_new\" href=\"http://sourceforge.net/projects/openrpt/files/openrpt/\">' + \n           \"report writer to edit this\" + \n           '</a>'\n       );\n           \n    \n    \n}"
                                     },
                                     "*prop": "grid",
                                     "autoExpandColumn": "report_descrip",
                                     "|xns": "Roo.grid",
                                     "items": [
                                         {
+                                            "listeners": {
+                                                "beforeload": "function (_self, options)\n{\n    options.params['search[name]'] = _this.searchName.getValue();\n    options.params._max_versions = 1;\n}"
+                                            },
                                             "*prop": "dataSource",
-                                            "xtype": "Store",
                                             "remoteSort": true,
+                                            "xtype": "Store",
                                             "|sortInfo": "{ field : 'report_name', direction: 'ASC' }",
                                             "|xns": "Roo.data",
                                             "items": [
                                                 }
                                             ]
                                         },
+                                        {
+                                            "listeners": {
+                                                "afterselectionchange": "function (_self)\n{\n    _this.vgrid.footer.onClick('first');\n}"
+                                            },
+                                            "*prop": "sm",
+                                            "singleSelect": true,
+                                            "xtype": "RowSelectionModel",
+                                            "|xns": "Roo.grid"
+                                        },
                                         {
                                             "*prop": "footer",
                                             "xtype": "PagingToolbar",
                                             "items": [
                                                 {
                                                     "listeners": {
-                                                        "render": "function (_self)\n{\n    _this.searchName = _self;\n}"
+                                                        "render": "function (_self)\n{\n    _this.searchName = _self;\n}",
+                                                        "specialkey": "function (_self, e)\n{\n    _this.grid.footer.onClick('first');\n}"
                                                     },
                                                     "xtype": "TextField",
                                                     "|xns": "Roo.form"
                                                     "xtype": "Fill"
                                                 },
                                                 {
-                                                    "text": "Add",
-                                                    "xtype": "Button",
-                                                    "cls": "x-btn-text-icon",
-                                                    "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
                                                     "listeners": {
-                                                        "|click": "function()\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( { id : 0 } , function() {\n        _this.grid.footer.onClick('first');\n   }); \n}\n"
+                                                        "click": "function (_self, e)\n{\n    \n    var sel = _this.grid.selModel.getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a report\");\n        return;\n    }\n    \n    Pman.Dialog.Image.show(\n       {\n            _url : baseURL+'/Xtuple/Import/Report',\n             onid : sel.data.report_id\n             \n            \n       },\n       function (data) {\n            Roo.MessageBox.alert(\"Notice\", \"Updated\");\n            _this.grid.footer.onClick('refresh');\n       }\n   );\n}"
                                                     },
+                                                    "text": "Upload New version",
+                                                    "xtype": "Button",
                                                     "|xns": "Roo.Toolbar"
                                                 }
                                             ]
                             ]
                         },
                         {
-                            "|xns": "Roo",
-                            "xtype": "GridPanel",
-                            "title": "report",
-                            "fitToframe": true,
-                            "fitContainer": true,
-                            "tableName": "report",
-                            "background": true,
-                            "region": "center",
                             "listeners": {
-                                "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
+                                "|activate": "function() {\n    _this.vpanel = this;\n    if (_this.vgrid) {\n        _this.vgrid.footer.onClick('first');\n    }\n}"
                             },
+                            "background": false,
+                            "fitContainer": true,
+                            "fitToframe": true,
+                            "region": "east",
+                            "tableName": "report",
+                            "title": "report",
+                            "xtype": "GridPanel",
+                            "|xns": "Roo",
                             "items": [
                                 {
-                                    "*prop": "grid",
-                                    "xtype": "Grid",
-                                    "autoExpandColumn": "report_name",
-                                    "loadMask": true,
                                     "listeners": {
-                                        "|render": "function() \n{\n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
-                                        "|rowdblclick": "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\n        _this.grid.footer.onClick('first');\n    }); \n}\n"
+                                        "|render": "function() \n{\n    _this.vgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.vpanel.active) {\n       this.footer.onClick('first');\n    }\n}",
+                                        "|rowdblclick": "function (_self, rowIndex, e)\n{\n    var rec = this.ds.getAt(rowIndex);\n    new Pman.Download({\n        url : baseURL + '/Roo/Report/' + rec.data.report_name +'-' + rec.data.report_id + '.rpt',\n        method : 'GET',\n        params : {\n            _id : rec.data.report_id,\n            _download : 1\n        }\n    });\n    Roo.MessageBox.alert(\"Downloading\",\n    \n       \"Report template is downloading - use \" +\n           '<a target=\"_new\" href=\"http://sourceforge.net/projects/openrpt/files/openrpt/\">' + \n           \"report writer to edit this\" + \n           '</a>'\n       );\n           \n    \n    \n}"
                                     },
+                                    "*prop": "grid",
+                                    "autoExpandColumn": "Report loaddate",
+                                    "loadMask": true,
+                                    "xtype": "Grid",
                                     "|xns": "Roo.grid",
                                     "items": [
                                         {
+                                            "listeners": {
+                                                "beforeload": "function (_self, options)\n{\n    if (!_this.grid) {\n        return false;\n    } \n    var sel  = _this.grid.selModel.getSelected();\n    if (!sel) {\n        this.removeAll();\n        return false;\n    }\n    options.params.report_name = sel.data.report_name;\n    \n    \n}"
+                                            },
                                             "*prop": "dataSource",
-                                            "xtype": "Store",
                                             "remoteSort": true,
-                                            "|sortInfo": "{ field : 'report_name', direction: 'ASC' }",
+                                            "xtype": "Store",
+                                            "|sortInfo": "{ field : 'report_grade', direction: 'DESC' }",
                                             "|xns": "Roo.data",
                                             "items": [
                                                 {
                                             "|xns": "Roo"
                                         },
                                         {
-                                            "xtype": "ColumnModel",
-                                            "header": "Report grade",
-                                            "width": 75,
+                                            "*prop": "colModel[]",
                                             "dataIndex": "report_grade",
+                                            "header": "Version",
+                                            "width": 20,
+                                            "xtype": "ColumnModel",
                                             "|renderer": "function(v) { return String.format('{0}', v); }",
-                                            "|xns": "Roo.grid",
-                                            "*prop": "colModel[]"
+                                            "|xns": "Roo.grid"
                                         },
                                         {
-                                            "xtype": "ColumnModel",
-                                            "header": "Report loaddate",
-                                            "width": 75,
+                                            "*prop": "colModel[]",
                                             "dataIndex": "report_loaddate",
-                                            "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
-                                            "|xns": "Roo.grid",
-                                            "*prop": "colModel[]"
+                                            "header": "Created",
+                                            "width": 200,
+                                            "xtype": "ColumnModel",
+                                            "|renderer": "function(v,x,r) { \n    var vv =   Date.parseDate(r.json.report_loaddate.split('.')[0], 'Y-m-d H:i:s').format('d/M/Y h:ia');\n    return String.format('{0}', vv); \n\n    }",
+                                            "|xns": "Roo.grid"
                                         }
                                     ]
                                 }