Pman.Dialog.CoreAutoSavePreview.bjs
[Pman.Core] / Pman.Dialog.CoreAutoSavePreview.js
index d1e1307..c7c08a2 100644 (file)
@@ -30,6 +30,14 @@ Pman.Dialog.CoreAutoSavePreview = {
         this.dialog = Roo.factory({
             xtype: 'LayoutDialog',
             xns: Roo,
+            listeners : {
+                show : function (_self)
+                {
+                    if(typeof(_this.data) != 'undefined'){
+                        _this.grid.footer.onClick('first');
+                    }
+                }
+            },
             background : false,
             closable : false,
             collapsible : false,
@@ -38,16 +46,162 @@ Pman.Dialog.CoreAutoSavePreview = {
             resizable : false,
             title : "Saved Version",
             width : 800,
+            items : [
+                {
+                    xtype: 'GridPanel',
+                    xns: Roo,
+                    listeners : {
+                        activate : function() {
+                            _this.panel = this;
+                            if (_this.grid) {
+                                _this.grid.footer.onClick('first');
+                            }
+                        }
+                    },
+                    background : false,
+                    fitContainer : true,
+                    fitToframe : true,
+                    region : 'west',
+                    tableName : 'Images',
+                    title : "Images",
+                    grid : {
+                        xtype: 'Grid',
+                        xns: Roo.grid,
+                        listeners : {
+                            render : function() 
+                            {
+                                _this.grid = this; 
+                                
+                                if (_this.panel.active) {
+                                   this.footer.onClick('first');
+                                }
+                            },
+                            rowdblclick : function (_self, rowIndex, e)
+                            {
+                            
+                            }
+                        },
+                        autoExpandColumn : 'filename',
+                        loadMask : true,
+                        sm : {
+                            xtype: 'RowSelectionModel',
+                            xns: Roo.grid,
+                            listeners : {
+                                afterselectionchange : function (_self)
+                                {
+                                    var selected = this.getSelected();
+                                    
+                                    if (!selected) {
+                                        _this.viewPanel.setContent("Nothing Selected");
+                                        return;
+                                    }
+                                    
+                                    _this.viewPanel.load( { url : baseURL + "/Roo/Events", method : 'GET' }, {_id : selected.data.id, _retrieve_source : 1}, function(oElement, bSuccess, oResponse){
+                                        
+                                        var res = Roo.decode(oResponse.responseText);
+                                        
+                                        if(!bSuccess || !res.success){
+                                            _this.viewPanel.setContent("Load data failed?!");
+                                        }
+                                
+                                        if(typeof(res.data) !== 'string'){
+                                            _this.viewPanel.setContent(res.data);
+                                            return;
+                                        }
+                                        
+                                        _this.source = res.data.POST.source;
+                                        _this.viewPanel.setContent(_this.source);
+                                        
+                                    });
+                                }
+                            },
+                            singleSelect : true
+                        },
+                        dataSource : {
+                            xtype: 'Store',
+                            xns: Roo.data,
+                            listeners : {
+                                beforeload : function (_self, o)
+                                {
+                                    o.params = o.params || {};
+                                    
+                                    if(typeof(_this.data) == 'undefined'){
+                                        this.removeAll();
+                                        return false;
+                                    }
+                                    Roo.log(_this.data);
+                                    o.params.action = 'AUTOSAVE';
+                                }
+                            },
+                            remoteSort : true,
+                            sortInfo : { field : 'event_when', direction: 'DESC' },
+                            proxy : {
+                                xtype: 'HttpProxy',
+                                xns: Roo.data,
+                                method : 'GET',
+                                url : baseURL + '/Roo/Events.php'
+                            },
+                            reader : {
+                                xtype: 'JsonReader',
+                                xns: Roo.data,
+                                id : 'id',
+                                root : 'data',
+                                totalProperty : 'total',
+                                fields : [
+                                    {
+                                        'name': 'id',
+                                        'type': 'int'
+                                    },
+                                    {
+                                        'name': 'event_when',
+                                        'type': 'string'
+                                    }
+                                ]
+                            }
+                        },
+                        footer : {
+                            xtype: 'PagingToolbar',
+                            xns: Roo,
+                            displayInfo : false,
+                            pageSize : 25
+                        },
+                        colModel : [
+                            {
+                                xtype: 'ColumnModel',
+                                xns: Roo.grid,
+                                dataIndex : 'event_when',
+                                header : 'Date',
+                                width : 100,
+                                renderer : function(v) { return String.format('{0}', v ? v.format('Y-m-d H:i:s') : ''); }
+                            }
+                        ]
+                    }
+                },
+                {
+                    xtype: 'ContentPanel',
+                    xns: Roo,
+                    listeners : {
+                        render : function (_self)
+                        {
+                            _this.viewPanel = _self;
+                        }
+                    },
+                    autoScroll : true,
+                    background : false,
+                    fitContainer : true,
+                    fitToFrame : true,
+                    region : 'center'
+                }
+            ],
             center : {
                 xtype: 'LayoutRegion',
-                xns: Roo,
-                titlebar : false
+                xns: Roo
             },
             west : {
                 xtype: 'LayoutRegion',
                 xns: Roo,
                 split : true,
-                width : 300
+                width : 200
             },
             buttons : [
                 {