DataObjects/Core_person_signup.php
[Pman.Core] / Pman.Dialog.CoreAutoSavePreview.js
index 3b9dc02..1c9b595 100644 (file)
@@ -30,6 +30,15 @@ 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,
@@ -50,44 +59,105 @@ Pman.Dialog.CoreAutoSavePreview = {
                             }
                         }
                     },
-                    background : true,
+                    background : false,
                     fitContainer : true,
                     fitToframe : true,
                     region : 'west',
-                    tableName : 'Images',
-                    title : "Images",
+                    tableName : 'Events',
+                    title : "Events",
                     grid : {
                         xtype: 'Grid',
                         xns: Roo.grid,
-                        autoExpandColumn : 'filename',
-                        loadMask : true,
                         listeners : {
                             render : function() 
                             {
                                 _this.grid = this; 
-                                //_this.dialog = Pman.Dialog.FILL_IN
+                                
                                 if (_this.panel.active) {
                                    this.footer.onClick('first');
                                 }
-                            },
-                            rowdblclick : function (_self, rowIndex, e)
-                            {
-                                if (!_this.dialog) return;
-                                _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
-                                    _this.grid.footer.onClick('first');
-                                }); 
                             }
                         },
+                        autoExpandColumn : 'event_when',
+                        loadMask : true,
+                        sm : {
+                            xtype: 'RowSelectionModel',
+                            xns: Roo.grid,
+                            listeners : {
+                                afterselectionchange : function (_self)
+                                {
+                                    var selected = this.getSelected();
+                                    
+                                    _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){
+                                        
+                                        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
+                        },
                         dataSource : {
                             xtype: 'Store',
                             xns: Roo.data,
+                            listeners : {
+                                beforeload : function (_self, o)
+                                {
+                                    o.params = o.params || {};
+                                    
+                                    if(typeof(_this.data) == 'undefined'){
+                                        this.removeAll();
+                                        return false;
+                                    }
+                                
+                                    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',
@@ -110,10 +180,8 @@ Pman.Dialog.CoreAutoSavePreview = {
                         footer : {
                             xtype: 'PagingToolbar',
                             xns: Roo,
-                            pageSize : 25,
-                            displayInfo : true,
-                            displayMsg : "Displaying Images{0} - {1} of {2}",
-                            emptyMsg : "No Images found"
+                            displayInfo : false,
+                            pageSize : 25
                         },
                         colModel : [
                             {
@@ -136,6 +204,7 @@ Pman.Dialog.CoreAutoSavePreview = {
                             _this.viewPanel = _self;
                         }
                     },
+                    autoScroll : true,
                     background : false,
                     fitContainer : true,
                     fitToFrame : true,
@@ -168,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"