DataObjects/Core_watch.php
[Pman.Core] / Pman.Dialog.CoreAutoSavePreview.js
index d34dc0a..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,9 +88,11 @@ 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;
                                     }
                                     
                                     _this.viewPanel.load( { url : baseURL + "/Roo/Events", method : 'GET' }, {_id : selected.data.id, _retrieve_source : 1}, function(oElement, bSuccess, oResponse){
@@ -103,13 +102,18 @@ Pman.Dialog.CoreAutoSavePreview = {
                                         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;
+                                        if(!_this.data.successFn){
+                                            Roo.MessageBox.alert('Error', 'Please setup the successFn');
+                                            return;
+                                        }
+                                        
+                                        _this.source = _this.data.successFn(res);
                                 
                                         _this.viewPanel.setContent(_this.source);
                                         
@@ -130,8 +134,21 @@ 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,
@@ -222,7 +239,10 @@ Pman.Dialog.CoreAutoSavePreview = {
                         click : function() {
                         
                             _this.dialog.hide();
-                        
+                            
+                            if (_this.callback && _this.source != '') {
+                                _this.callback.call(this, _this.source);
+                            }
                         }
                     },
                     text : "OK"