DataObjects/Core_person_signup.php
[Pman.Core] / Pman.Dialog.CoreAutoSavePreview.js
index c744795..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,
@@ -60,9 +69,10 @@ Pman.Dialog.CoreAutoSavePreview = {
                         xtype: 'Grid',
                         xns: Roo.grid,
                         listeners : {
-                            render : function() { 
+                            render : function() 
+                            {
                                 _this.grid = this; 
-                                //_this.dialog = Pman.Dialog.FILL_IN
+                                
                                 if (_this.panel.active) {
                                    this.footer.onClick('first');
                                 }
@@ -76,13 +86,38 @@ Pman.Dialog.CoreAutoSavePreview = {
                             listeners : {
                                 afterselectionchange : function (_self)
                                 {
+                                    var selected = this.getSelected();
+                                    
+                                    _this.source = '';
                                     
-                                    if (!this.getSelected()) {
-                                        this.viewPanel.setContent("Nothing Selected");
-                                        return;
+                                    if(!selected){
+                                       _this.viewPanel.setContent("Please select an saved version on the left"); 
+                                       return;
                                     }
                                     
-                                    this.viewPanel.setContent("data");
+                                    _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
@@ -93,144 +128,59 @@ Pman.Dialog.CoreAutoSavePreview = {
                             listeners : {
                                 beforeload : function (_self, o)
                                 {
-                                    Roo.log(_this.data);
-                                    o.params = o.parmas || {};
-                                    o.action = 'AUTOSAVE'
+                                    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: 'event_when', direction: 'DESC'},
+                            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,
-                                totalProperty : 'total',
-                                root : 'data',
                                 id : 'id',
+                                root : 'data',
+                                totalProperty : 'total',
                                 fields : [
                                     {
                                         'name': 'id',
                                         'type': 'int'
                                     },
-                                    {
-                                        'name': 'person_name',
-                                        'type': 'string'
-                                    },
                                     {
                                         'name': 'event_when',
-                                        'type': 'date',
-                                        'dateFormat': 'Y-m-d'
-                                    },
-                                    {
-                                        'name': 'action',
                                         'type': 'string'
-                                    },
-                                    {
-                                        'name': 'ipaddr',
-                                        'type': 'string'
-                                    },
-                                    {
-                                        'name': 'on_id',
-                                        'type': 'int'
-                                    },
-                                    {
-                                        'name': 'on_table',
-                                        'type': 'string'
-                                    },
-                                    {
-                                        'name': 'person_id',
-                                        'type': 'int'
-                                    },
-                                    {
-                                        'name': 'remarks',
-                                        'type': 'string'
-                                    },
-                                    {
-                                        'name': 'person_id_id',
-                                        'type': 'int'
-                                    },
-                                    {
-                                        'name': 'person_id_office_id',
-                                        'type': 'int'
-                                    },
-                                    {
-                                        'name': 'person_id_name',
-                                        'type': 'string'
-                                    },
-                                    {
-                                        'name': 'person_id_phone',
-                                        'type': 'string'
-                                    },
-                                    {
-                                        'name': 'person_id_fax',
-                                        'type': 'string'
-                                    },
-                                    {
-                                        'name': 'person_id_email',
-                                        'type': 'string'
-                                    },
-                                    {
-                                        'name': 'person_id_company_id',
-                                        'type': 'int'
-                                    },
-                                    {
-                                        'name': 'person_id_role',
-                                        'type': 'string'
-                                    },
-                                    {
-                                        'name': 'person_id_active',
-                                        'type': 'int'
-                                    },
-                                    {
-                                        'name': 'person_id_remarks',
-                                        'type': 'string'
-                                    },
-                                    {
-                                        'name': 'person_id_passwd',
-                                        'type': 'string'
-                                    },
-                                    {
-                                        'name': 'person_id_owner_id',
-                                        'type': 'int'
-                                    },
-                                    {
-                                        'name': 'person_id_lang',
-                                        'type': 'string'
-                                    },
-                                    {
-                                        'name': 'person_id_no_reset_sent',
-                                        'type': 'int'
-                                    },
-                                    {
-                                        'name': 'person_id_action_type',
-                                        'type': 'string'
-                                    },
-                                    {
-                                        'name': 'person_id_project_id',
-                                        'type': 'int'
-                                    },
-                                    {
-                                        'name': 'person_id_deleted_by',
-                                        'type': 'int'
-                                    },
-                                    {
-                                        'name': 'person_id_deleted_dt',
-                                        'type': 'date'
                                     }
                                 ]
-                            },
-                            proxy : {
-                                xtype: 'HttpProxy',
-                                xns: Roo.data,
-                                method : 'GET',
-                                url : baseURL + '/Roo/Events.php'
                             }
                         },
                         footer : {
                             xtype: 'PagingToolbar',
                             xns: Roo,
-                            displayInfo : true,
-                            displayMsg : "{0} - {1} of {2}",
-                            emptyMsg : "Nothing found",
+                            displayInfo : false,
                             pageSize : 25
                         },
                         colModel : [
@@ -240,7 +190,7 @@ Pman.Dialog.CoreAutoSavePreview = {
                                 dataIndex : 'event_when',
                                 header : 'Date',
                                 width : 100,
-                                renderer : function(v) { return v ? v.dateFormat('d/m/Y H:i') : ''; }
+                                renderer : function(v) { return String.format('{0}', v ? v.format('Y-m-d H:i:s') : ''); }
                             }
                         ]
                     }
@@ -254,8 +204,10 @@ Pman.Dialog.CoreAutoSavePreview = {
                             _this.viewPanel = _self;
                         }
                     },
+                    autoScroll : true,
                     background : false,
                     fitContainer : true,
+                    fitToFrame : true,
                     region : 'center'
                 }
             ],
@@ -285,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"