DataObjects/Core_notify.php
[Pman.Core] / Pman.Dialog.CoreAutoSavePreview.js
index 51dcd6a..1c9b595 100644 (file)
@@ -36,6 +36,7 @@ Pman.Dialog.CoreAutoSavePreview = {
                     if(typeof(_this.data) != 'undefined'){
                         _this.grid.footer.onClick('first');
                     }
+                    
                 }
             },
             background : false,
@@ -62,8 +63,8 @@ Pman.Dialog.CoreAutoSavePreview = {
                     fitContainer : true,
                     fitToframe : true,
                     region : 'west',
-                    tableName : 'Images',
-                    title : "Images",
+                    tableName : 'Events',
+                    title : "Events",
                     grid : {
                         xtype: 'Grid',
                         xns: Roo.grid,
@@ -75,13 +76,9 @@ Pman.Dialog.CoreAutoSavePreview = {
                                 if (_this.panel.active) {
                                    this.footer.onClick('first');
                                 }
-                            },
-                            rowdblclick : function (_self, rowIndex, e)
-                            {
-                            
                             }
                         },
-                        autoExpandColumn : 'filename',
+                        autoExpandColumn : 'event_when',
                         loadMask : true,
                         sm : {
                             xtype: 'RowSelectionModel',
@@ -91,12 +88,36 @@ Pman.Dialog.CoreAutoSavePreview = {
                                 {
                                     var selected = this.getSelected();
                                     
-                                    if (!selected) {
-                                        _this.viewPanel.setContent("Nothing Selected");
-                                        return;
+                                    _this.source = '';
+                                    
+                                    if(!selected){
+                                       _this.viewPanel.setContent("Please select an saved version on the left"); 
+                                       return;
                                     }
-                                    Roo.log(selected);
-                                    _this.viewPanel.setContent("Data Selected");
+                                    
+                                    _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;
+                                        }
+                                        
+                                        if(!_this.data.successFn){
+                                            Roo.MessageBox.alert('Error', 'Please setup the successFn');
+                                            return;
+                                        }
+                                        
+                                        _this.source = _this.data.successFn(res);
+                                
+                                        _this.viewPanel.setContent(_this.source);
+                                        
+                                    });
                                 }
                             },
                             singleSelect : true
@@ -113,17 +134,30 @@ Pman.Dialog.CoreAutoSavePreview = {
                                         this.removeAll();
                                         return false;
                                     }
-                                    Roo.log(_this.data);
-                                    o.params.action = 'AUTOSAVE';
+                                
+                                    var d = Roo.apply({}, _this.data);
+                                    delete d.successFn;
+                                
+                                    Roo.apply(o.params, d);
+                                    
+                                },
+                                load : function (_self, records, options)
+                                {
+                                    var sm = _this.grid.getSelectionModel();
+                                    if (!sm.getSelections().length) {
+                                        sm.selectFirstRow();
+                                        
+                                        sm.fireEvent('afterselectionchange', sm);
+                                    }
                                 }
                             },
                             remoteSort : true,
-                            sortInfo : { field : 'filename', direction: 'ASC' },
+                            sortInfo : { field : 'event_when', direction: 'DESC' },
                             proxy : {
                                 xtype: 'HttpProxy',
                                 xns: Roo.data,
                                 method : 'GET',
-                                url : baseURL + '/Roo/Images.php'
+                                url : baseURL + '/Roo/Events.php'
                             },
                             reader : {
                                 xtype: 'JsonReader',
@@ -170,6 +204,7 @@ Pman.Dialog.CoreAutoSavePreview = {
                             _this.viewPanel = _self;
                         }
                     },
+                    autoScroll : true,
                     background : false,
                     fitContainer : true,
                     fitToFrame : true,
@@ -202,7 +237,12 @@ Pman.Dialog.CoreAutoSavePreview = {
                     xns: Roo,
                     listeners : {
                         click : function() {
+                        
                             _this.dialog.hide();
+                            
+                            if (_this.callback && _this.source != '') {
+                                _this.callback.call(this, _this.source);
+                            }
                         }
                     },
                     text : "OK"