Pman.Dialog.CoreAutoSavePreview.bjs
[Pman.Core] / Pman.Dialog.CoreAutoSavePreview.js
index 9422612..2f69252 100644 (file)
@@ -36,6 +36,12 @@ Pman.Dialog.CoreAutoSavePreview = {
                     if(typeof(_this.data) != 'undefined'){
                         _this.grid.footer.onClick('first');
                     }
+                    
+                    if (!_this.grid.getSelectionModel().getSelected()) {
+                        _this.source = '';
+                        _this.viewPanel.setContent("Please select a version on the left");
+                    }
+                    
                 }
             },
             background : false,
@@ -62,7 +68,7 @@ Pman.Dialog.CoreAutoSavePreview = {
                     fitContainer : true,
                     fitToframe : true,
                     region : 'west',
-                    tableName : 'Images',
+                    tableName : 'Events',
                     title : "Images",
                     grid : {
                         xtype: 'Grid',
@@ -77,7 +83,7 @@ Pman.Dialog.CoreAutoSavePreview = {
                                 }
                             }
                         },
-                        autoExpandColumn : 'filename',
+                        autoExpandColumn : 'event_when',
                         loadMask : true,
                         sm : {
                             xtype: 'RowSelectionModel',
@@ -87,25 +93,27 @@ Pman.Dialog.CoreAutoSavePreview = {
                                 {
                                     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){
                                         
+                                        _this.source = '';
+                                        
                                         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;
+                                        if(!_this.data.successFn){
+                                            Roo.MessageBox.alert('Error', 'Please setup the successFn');
+                                            return;
+                                        }
+                                        
+                                        _this.source = _this.data.successFn(res);
                                 
                                         _this.viewPanel.setContent(_this.source);
                                         
@@ -126,8 +134,12 @@ 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);
+                                    
                                 }
                             },
                             remoteSort : true,
@@ -219,7 +231,7 @@ Pman.Dialog.CoreAutoSavePreview = {
                         
                             _this.dialog.hide();
                             
-                            if (_this.callback) {
+                            if (_this.callback && _this.source != '') {
                                 _this.callback.call(this, _this.source);
                             }
                         }