Pman.Tab.AdminContactsGroupRight.bjs
[Pman.Admin] / Pman.Tab.AdminContactsGroupRight.js
index ba8227b..7c2c6fd 100644 (file)
@@ -94,7 +94,9 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                             if (!o.params) {
                                 o.params = {}
                             }
+                                _this.group_id = 0;
                             var s = Pman.Tab.AdminContactsGroup.grid.getSelectionModel().getSelections();
+                        
                             if (!s.length) {
                                 o.params.group_id = -1;
                             } else {
@@ -104,6 +106,7 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                                 _this.grid.getView().el.mask("You can not set permissions for that group");
                                 return false;
                             }
+                            _this.group_id = id;    
                             _this.grid.getView().el.unmask();
                             return true;
                           
@@ -139,11 +142,24 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                         },
                         load : function (_self, records, options)
                         {
+                            _this.dataUpdate = {};
+                            var full = 'ADEPS'.split('');
+                            
                             Roo.each(records, function(e){
+                                _this.dataUpdate[e.id] = e.data.accessmask;
+                            
                                 var k = e.data.accessmask.split('');
-                                Roo.each(k, function(ee){
-                                    e.set('accessmask_'+ee, 1);
+                                var rm = e.data.FullMask.split('');
+                                
+                                Roo.each(full, function(ee){
+                                    if (rm.indexOf(ee) < 0) {
+                                        e.set('accessmask_'+ee, -1);          
+                                        return;
+                                    }
+                                    
+                                    e.set('accessmask_'+ee, (k.indexOf(ee) < 0) ? 0 : 1);
                                 });
+                                
                                 if(e.data.accessmask == e.data.FullMask){
                                     e.set('accessmask_AA', 1);
                                 }
@@ -218,12 +234,16 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                                 click : function (_self, e)
                                 {
                                     
+                                    var params = { group_id : _this.group_id };
+                                    for(var i in _this.dataUpdate) {
+                                        params['dataUpdate[' + i + ']'] = _this.dataUpdate[i];
+                                    }
+                                    //Roo.log(params);return;
+                                    
                                     new Pman.Request({
-                                        url : baseURL + '/GroupRights.php',
+                                        url : baseURL + '/Admin/GroupRights.php',
                                         method :'POST',
-                                        params : {
-                                            dataUpdate : _this.dataUpdate
-                                        },
+                                        params : params,
                                         success : function() {
                                             // do nothing
                                             
@@ -295,6 +315,9 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                         header : 'Add',
                         width : 75,
                         renderer : function(v) {  
+                            if (v < 0) {
+                                return '';
+                            }
                             var state = v> 0 ?  '-checked' : '';
                         
                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
@@ -308,6 +331,9 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                         header : 'Edit',
                         width : 75,
                         renderer : function(v) {  
+                           if (v < 0) {
+                                return '';
+                            }
                             var state = v> 0 ?  '-checked' : '';
                         
                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
@@ -321,6 +347,9 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                         header : 'Delete',
                         width : 75,
                         renderer : function(v) {  
+                            if (v < 0) {
+                                return '';
+                            }
                             var state = v> 0 ?  '-checked' : '';
                         
                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
@@ -334,6 +363,10 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                         header : 'List/View',
                         width : 75,
                         renderer : function(v) {  
+                            
+                            if (v < 0) {
+                                return '';
+                            }
                             var state = v> 0 ?  '-checked' : '';
                         
                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
@@ -348,6 +381,10 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                         width : 75,
                         renderer : function(v,x,r) {  
                             
+                            
+                            if (v < 0) {
+                                return '';
+                            }
                             var state = v> 0 ?  '-checked' : '';
                         
                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';