Pman.Dialog.CoreNotifyRecur.bjs
[Pman.Core] / Pman.Dialog.CoreNotifyRecur.js
index 243a860..b638b86 100644 (file)
@@ -30,6 +30,12 @@ Pman.Dialog.CoreNotifyRecur = {
         this.dialog = Roo.factory({
             xtype: 'LayoutDialog',
             xns: Roo,
+            listeners : {
+                show : function (_self)
+                {
+                    _this.grid.ds.load({});
+                }
+            },
             height : 500,
             modal : true,
             resizable : false,
@@ -62,7 +68,7 @@ Pman.Dialog.CoreNotifyRecur = {
                                 _this.grid = this; 
                                 //_this.dialog = Pman.Dialog.FILL_IN
                                 if (_this.panel.active) {
-                                   this.footer.onClick('first');
+                                //   this.footer.onClick('first');
                                 }
                             },
                             rowdblclick : function (_self, rowIndex, e)
@@ -94,9 +100,9 @@ Pman.Dialog.CoreNotifyRecur = {
                                         url : baseURL + '/Roo/Core_notify_recur',
                                         method :'POST',
                                         params : record.data,
-                                        success : function()
+                                        success : function(data)
                                         {
-                                            //??
+                                            Roo.log(data);
                                         },
                                         failure : function() {
                                             Roo.MessageBox.alert("Error", "There was a problem saving");
@@ -111,7 +117,7 @@ Pman.Dialog.CoreNotifyRecur = {
                                     if (!_this.data) {
                                         return false;
                                     }
-                                    o.params =  Roo.apply(o.params, {
+                                    o.params =  Roo.apply(o.params || {}, {
                                         person_id : _this.data.person_id,
                                         onid : _this.data.onid,
                                         ontable : _this.data.ontable,
@@ -185,14 +191,6 @@ Pman.Dialog.CoreNotifyRecur = {
                                 ]
                             }
                         },
-                        footer : {
-                            xtype: 'PagingToolbar',
-                            xns: Roo,
-                            pageSize : 25,
-                            displayInfo : true,
-                            displayMsg : "Displaying core_notify_recur{0} - {1} of {2}",
-                            emptyMsg : "No core_notify_recur found"
-                        },
                         toolbar : {
                             xtype: 'Toolbar',
                             xns: Roo,
@@ -238,15 +236,35 @@ Pman.Dialog.CoreNotifyRecur = {
                                 {
                                     xtype: 'Button',
                                     xns: Roo.Toolbar,
-                                    text : "Delete",
-                                    cls : 'x-btn-text-icon',
-                                    icon : rootURL + '/Pman/templates/images/trash.gif',
                                     listeners : {
                                         click : function()
                                         {
-                                             Pman.genericDelete(_this, 'core_notify_recur'); 
+                                             _this.grid.stopEditing();
+                                             var s = _this.grid.selModel.getSelectedCell()
+                                             if (!s) {
+                                                Roo.MessageBox.alert("Error", "Select row");
+                                                return;
+                                            }
+                                            
+                                            new Pman.Request({
+                                                url : baseURL + '/Roo/core_notify_recur',
+                                                method : 'POST',
+                                                params : {
+                                                    _delete : _this.grid.ds.getAt(s[0]).data.id,
+                                                }, 
+                                                success : function() {
+                                                    _this.grid.ds.load({});
+                                                },
+                                                failure : function() {
+                                                    Roo.MessageBox.alert("Error", "Deleting failed - try reloading");
+                                                }
+                                           });
+                                            
                                         }
-                                    }
+                                    },
+                                    cls : 'x-btn-text-icon',
+                                    text : "Delete",
+                                    icon : rootURL + '/Pman/templates/images/trash.gif'
                                 }
                             ]
                         },
@@ -291,6 +309,30 @@ Pman.Dialog.CoreNotifyRecur = {
                                 width : 100,
                                 renderer : function(v,x,r) { 
                                     
+                                    if (v.length) {
+                                     
+                                        var cm = _this.grid.colModel;
+                                       
+                                        var ci = cm.getColumnByDataIndex(this.name);
+                                       
+                                         var tv = [];
+                                        var vals = Roo.decode(v);
+                                        Roo.each(vals, function(k) {
+                                            var r = this.findRecord(this.valueField, k);
+                                            if(r){
+                                                tv.push(r.data[this.displayField]);
+                                            }else if(this.valueNotFoundText !== undefined){
+                                                tv.push( this.valueNotFoundText );
+                                            }
+                                        },ci.editor.field);
+                                
+                                        r.data[this.name + '_name'] = tv.join(', ');
+                                        return String.format('{0}',tv.join(', '));
+                                
+                                        
+                                    
+                                    }
+                                    r.data[this.name + '_name'] = '';
                                     return String.format('{0}', r.data.freq_day_name || v); 
                                     
                                 },
@@ -335,6 +377,31 @@ Pman.Dialog.CoreNotifyRecur = {
                                 width : 250,
                                 renderer : function(v,x,r) { 
                                     
+                                 
+                                    if (v.length) {
+                                     
+                                        var cm = _this.grid.colModel;
+                                       
+                                        var ci = cm.getColumnByDataIndex(this.name);
+                                       
+                                         var tv = [];
+                                        var vals = Roo.decode(v);
+                                        Roo.each(vals, function(k) {
+                                            var r = this.findRecord(this.valueField, k);
+                                            if(r){
+                                                tv.push(r.data[this.displayField]);
+                                            }else if(this.valueNotFoundText !== undefined){
+                                                tv.push( this.valueNotFoundText );
+                                            }
+                                        },ci.editor.field);
+                                
+                                         r.data[this.name + '_name'] = tv.join(', ');
+                                        return String.format('{0}',tv.join(', '));
+                                
+                                        
+                                    
+                                    }
+                                        r.data[this.name + '_name'] = '';
                                     return String.format('{0}', r.data.freq_hour_name || v); 
                                     
                                 },
@@ -460,6 +527,12 @@ Pman.Dialog.CoreNotifyRecur = {
                 {
                     xtype: 'Button',
                     xns: Roo,
+                    listeners : {
+                        click : function (_self, e)
+                        {
+                            _this.dialog.hide();
+                        }
+                    },
                     text : "Done"
                 }
             ]