Pman.Dialog.CoreAutoSavePreview.bjs
[Pman.Core] / Pman.Dialog.CoreAutoSavePreview.bjs
index 413874b..add9fa5 100644 (file)
@@ -6,6 +6,9 @@
     "path": "/home/edward/gitlive/Pman.Core/Pman.Dialog.CoreAutoSavePreview.bjs",
     "items": [
         {
+            "listeners": {
+                "show": "function (_self)\n{\n    if(typeof(_this.data) != 'undefined'){\n        _this.grid.footer.onClick('first');\n    }\n    \n    if (!_this.grid.getSelectionModel().getSelected()) {\n        _this.source = '';\n        _this.viewPanel.setContent(\"Please select a version on the left\");\n    }\n    \n}"
+            },
             "background": false,
             "closable": false,
             "collapsible": false,
@@ -31,9 +34,9 @@
                 },
                 {
                     "listeners": {
-                        "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n    Roo.log(2);\n        _this.grid.footer.onClick('first');\n    }\n}"
+                        "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
                     },
-                    "background": true,
+                    "background": false,
                     "fitContainer": true,
                     "fitToframe": true,
                     "region": "west",
@@ -44,7 +47,7 @@
                     "items": [
                         {
                             "listeners": {
-                                "|render": "function() { \n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.panel.active) {\n    Roo.log('1');\n       this.footer.onClick('first');\n    }\n}"
+                                "|render": "function() \n{\n    _this.grid = this; \n    \n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}"
                             },
                             "*prop": "grid",
                             "autoExpandColumn": "event_when",
                             "items": [
                                 {
                                     "listeners": {
-                                        "afterselectionchange": "function (_self)\n{\n    \n    if (!this.getSelected()) {\n        _this.viewPanel.setContent(\"Nothing Selected\");\n        return;\n    }\n    \n    _this.viewPanel.setContent(\"data\");\n}"
+                                        "afterselectionchange": "function (_self)\n{\n    var selected = this.getSelected();\n    \n    _this.viewPanel.load( { url : baseURL + \"/Roo/Events\", method : 'GET' }, {_id : selected.data.id, _retrieve_source : 1}, function(oElement, bSuccess, oResponse){\n        \n        _this.source = '';\n        \n        var res = Roo.decode(oResponse.responseText);\n        \n        if(!bSuccess || !res.success){\n            _this.viewPanel.setContent(\"Load data failed?!\");\n        }\n        \n        if(typeof(res.data) === 'string'){\n            _this.viewPanel.setContent(res.data);\n            return;\n        }\n        \n        if(!_this.data.successFn){\n            Roo.MessageBox.alert('Error', 'Please setup the successFn');\n            return;\n        }\n        \n        _this.source = _this.data.successFn(res);\n\n        _this.viewPanel.setContent(_this.source);\n        \n    });\n}"
                                     },
                                     "*prop": "sm",
                                     "singleSelect": true,
                                     "xtype": "RowSelectionModel",
                                     "|xns": "Roo.grid"
                                 },
-                                {
-                                    "*prop": "footer",
-                                    "xtype": "PagingToolbar",
-                                    "pageSize": 25,
-                                    "displayInfo": true,
-                                    "displayMsg": "Displaying Images{0} - {1} of {2}",
-                                    "emptyMsg": "No Images found",
-                                    "|xns": "Roo"
-                                },
                                 {
                                     "listeners": {
-                                        "|beforeload": "function (_self, o)\n{\n    Roo.log(_this.data);\n    o.params = o.parmas || {};\n    o.params.action = 'AUTOSAVE';\n    \n}"
+                                        "beforeload": "function (_self, o)\n{\n    o.params = o.params || {};\n    \n    if(typeof(_this.data) == 'undefined'){\n        this.removeAll();\n        return false;\n    }\n\n    var d = Roo.apply({}, _this.data);\n    delete d.successFn;\n\n    Roo.apply(o.params, d);\n    \n}"
                                     },
                                     "*prop": "dataSource",
                                     "remoteSort": true,
                                     "xtype": "Store",
-                                    "|sortInfo": "{ field: 'event_when', direction: 'DESC'}",
+                                    "|sortInfo": "{ field : 'event_when', direction: 'DESC' }",
                                     "|xns": "Roo.data",
                                     "items": [
-                                        {
-                                            "|xns": "Roo.data",
-                                            "xtype": "JsonReader",
-                                            "totalProperty": "total",
-                                            "root": "data",
-                                            "*prop": "reader",
-                                            "id": "id",
-                                            "|fields": "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_name',\n        'type': 'string'\n    },\n    {\n        'name': 'event_when',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'action',\n        'type': 'string'\n    },\n    {\n        'name': 'ipaddr',\n        'type': 'string'\n    },\n    {\n        'name': 'on_id',\n        'type': 'int'\n    },\n    {\n        'name': 'on_table',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id',\n        'type': 'int'\n    },\n    {\n        'name': 'remarks',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_office_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_name',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_phone',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_fax',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_email',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_company_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_role',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_active',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_remarks',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_passwd',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_owner_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_lang',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_no_reset_sent',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_action_type',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_project_id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_deleted_by',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id_deleted_dt',\n        'type': 'date'\n    }\n]"
-                                        },
                                         {
                                             "*prop": "proxy",
-                                            "xtype": "HttpProxy",
                                             "method": "GET",
-                                            "|url": "baseURL + '/Roo/Events.php'",
-                                            "listeners": {},
-                                            "|xns": "Roo.data"
-                                        }
-                                    ]
-                                },
-                                {
-                                    "*prop": "colModel[]",
-                                    "dataIndex": "event_when",
-                                    "header": "Date",
-                                    "width": 100,
-                                    "xtype": "ColumnModel",
-                                    "|renderer": "function(v) { return v ? v.dateFormat('d/m/Y H:i') : ''; }",
-                                    "|xns": "Roo.grid"
-                                }
-                            ]
-                        }
-                    ]
-                },
-                {
-                    "listeners": {
-                        "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
-                    },
-                    "background": true,
-                    "fitContainer": true,
-                    "fitToframe": true,
-                    "region": "west",
-                    "tableName": "Images",
-                    "title": "Images",
-                    "xtype": "GridPanel",
-                    "|xns": "Roo",
-                    "items": [
-                        {
-                            "*prop": "grid",
-                            "xtype": "Grid",
-                            "autoExpandColumn": "filename",
-                            "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"
-                            },
-                            "|xns": "Roo.grid",
-                            "items": [
-                                {
-                                    "*prop": "dataSource",
-                                    "xtype": "Store",
-                                    "remoteSort": true,
-                                    "|sortInfo": "{ field : 'filename', direction: 'ASC' }",
-                                    "|xns": "Roo.data",
-                                    "items": [
-                                        {
-                                            "*prop": "proxy",
                                             "xtype": "HttpProxy",
-                                            "method": "GET",
-                                            "|url": "baseURL + '/Roo/Images.php'",
+                                            "|url": "baseURL + '/Roo/Events.php'",
                                             "|xns": "Roo.data"
                                         },
                                         {
-                                            "|xns": "Roo.data",
-                                            "xtype": "JsonReader",
-                                            "totalProperty": "total",
-                                            "root": "data",
                                             "*prop": "reader",
                                             "id": "id",
-                                            "|fields": "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'filename',\n        'type': 'string'\n    },\n    {\n        'name': 'ontable',\n        'type': 'string'\n    },\n    {\n        'name': 'onid',\n        'type': 'int'\n    },\n    {\n        'name': 'mimetype',\n        'type': 'string'\n    },\n    {\n        'name': 'width',\n        'type': 'int'\n    },\n    {\n        'name': 'height',\n        'type': 'int'\n    },\n    {\n        'name': 'filesize',\n        'type': 'int'\n    },\n    {\n        'name': 'displayorder',\n        'type': 'int'\n    },\n    {\n        'name': 'language',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id',\n        'type': 'int'\n    },\n    {\n        'name': 'created',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'imgtype',\n        'type': 'string'\n    },\n    {\n        'name': 'linkurl',\n        'type': 'string'\n    },\n    {\n        'name': 'descript',\n        'type': 'string'\n    },\n    {\n        'name': 'title',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_id',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_filename',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_ontable',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_onid',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_mimetype',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_width',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_height',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_filesize',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_displayorder',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_language',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_parent_image_id',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_created',\n        'type': 'date'\n    },\n    {\n        'name': 'parent_image_id_imgtype',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_linkurl',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_descript',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_title',\n        'type': 'string'\n    }\n]"
+                                            "root": "data",
+                                            "totalProperty": "total",
+                                            "xtype": "JsonReader",
+                                            "|fields": "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'event_when',\n        'type': 'string'\n    }\n]",
+                                            "|xns": "Roo.data"
                                         }
                                     ]
                                 },
                                 {
                                     "*prop": "footer",
-                                    "xtype": "PagingToolbar",
+                                    "displayInfo": false,
                                     "pageSize": 25,
-                                    "displayInfo": true,
-                                    "displayMsg": "Displaying Images{0} - {1} of {2}",
-                                    "emptyMsg": "No Images found",
+                                    "xtype": "PagingToolbar",
                                     "|xns": "Roo"
                                 },
                                 {
-                                    "*prop": "toolbar",
-                                    "xtype": "Toolbar",
-                                    "|xns": "Roo",
-                                    "items": [
-                                        {
-                                            "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"
-                                            },
-                                            "|xns": "Roo.Toolbar"
-                                        },
-                                        {
-                                            "text": "Edit",
-                                            "xtype": "Button",
-                                            "cls": "x-btn-text-icon",
-                                            "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
-                                            "listeners": {
-                                                "|click": "function()\n{\n    var s = _this.grid.getSelectionModel().getSelections();\n    if (!s.length || (s.length > 1))  {\n        Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n        return;\n    }\n    if (!_this.dialog) return;\n    _this.dialog.show(s[0].data, function() {\n        _this.grid.footer.onClick('first');\n    }); \n    \n}\n"
-                                            },
-                                            "|xns": "Roo.Toolbar"
-                                        },
-                                        {
-                                            "text": "Delete",
-                                            "cls": "x-btn-text-icon",
-                                            "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
-                                            "xtype": "Button",
-                                            "listeners": {
-                                                "|click": "function()\n{\n     Pman.genericDelete(_this, 'Images'); \n}\n        "
-                                            },
-                                            "|xns": "Roo.Toolbar"
-                                        }
-                                    ]
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Id",
-                                    "width": 75,
-                                    "dataIndex": "id",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Filename",
-                                    "width": 200,
-                                    "dataIndex": "filename",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Ontable",
-                                    "width": 200,
-                                    "dataIndex": "ontable",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Onid",
-                                    "width": 75,
-                                    "dataIndex": "onid",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Mimetype",
-                                    "width": 200,
-                                    "dataIndex": "mimetype",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Width",
-                                    "width": 75,
-                                    "dataIndex": "width",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Height",
-                                    "width": 75,
-                                    "dataIndex": "height",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Filesize",
-                                    "width": 75,
-                                    "dataIndex": "filesize",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Displayorder",
-                                    "width": 75,
-                                    "dataIndex": "displayorder",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Language",
-                                    "width": 200,
-                                    "dataIndex": "language",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Parent image",
-                                    "width": 75,
-                                    "dataIndex": "parent_image_id",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Created",
-                                    "width": 75,
-                                    "dataIndex": "created",
-                                    "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Imgtype",
-                                    "width": 200,
-                                    "dataIndex": "imgtype",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Linkurl",
-                                    "width": 200,
-                                    "dataIndex": "linkurl",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Descript",
-                                    "width": 200,
-                                    "dataIndex": "descript",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
+                                    "*prop": "colModel[]",
+                                    "dataIndex": "event_when",
+                                    "header": "Date",
+                                    "width": 100,
                                     "xtype": "ColumnModel",
-                                    "header": "Title",
-                                    "width": 200,
-                                    "dataIndex": "title",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
+                                    "|renderer": "function(v) { return String.format('{0}', v ? v.format('Y-m-d H:i:s') : ''); }",
+                                    "|xns": "Roo.grid"
                                 }
                             ]
                         }
                     "listeners": {
                         "render": "function (_self)\n{\n    _this.viewPanel = _self;\n}"
                     },
+                    "autoScroll": true,
                     "background": false,
                     "fitContainer": true,
                     "fitToFrame": true,
                 },
                 {
                     "listeners": {
-                        "|click": "function() {\n    _this.dialog.hide();\n}"
+                        "|click": "function() {\n\n    _this.dialog.hide();\n    \n    if (_this.callback && _this.source != '') {\n        _this.callback.call(this, _this.source);\n    }\n}"
                     },
                     "*prop": "buttons[]",
                     "text": "OK",