Pman.Tab.AdminContactsGroupRight.bjs
authorAlan Knowles <alan@roojs.com>
Fri, 14 Sep 2012 06:09:05 +0000 (14:09 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 14 Sep 2012 06:09:05 +0000 (14:09 +0800)
Pman.Tab.AdminContactsGroupRight.js

Pman.Tab.AdminContactsGroupRight.bjs
Pman.Tab.AdminContactsGroupRight.js

index 8ea9756..67f539d 100644 (file)
@@ -36,7 +36,7 @@
                             "listeners": {
                                 "beforeload": "function (_self, o)\n{\n    if (!o.params) {\n        o.params = {}\n    }\n    var s = Pman.Tab.AdminContactsGroup.grid.getSelectionModel().getSelections();\n    if (!s.length) {\n        o.params.group_id = -1;\n    } else {\n        o.params.group_id = s[0].data.id;\n    }\n    if (o.params.group_id < 0) {\n        _this.grid.getView().el.mask(\"You can not set permissions for that group\");\n        return false;\n    }\n    _this.grid.getView().el.unmask();\n    return true;\n  \n}",
                                 "update": "function (_self, record, operation)\n{\n    if (operation != 'commit') {\n        return;\n    }\n    // only used to change active status.\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/GroupRights.php',\n        method :'POST',\n        params : {\n            id : record.data.id,\n            active: record.data.active\n            \n        },\n        success : function() {\n            // do nothing\n            \n            _this.grid.ds.remove(record);\n            \n        },\n        failure : function() \n        {\n            Roo.MessageBox.alert(\"Error\", \"saving failed\", function() {\n                _this.grid.footer.onClick('first');\n            });\n        }\n    });\n}",
-                                "load": "function (_self, records, options)\n{\n    _this.dataUpdate = {};\n    Roo.each(records, function(e){\n        _this.dataUpdate[e.id] = e.accessmask;\n    \n        var k = e.data.accessmask.split('');\n        \n        Roo.each(k, function(ee){\n            e.set('accessmask_'+ee, 1);\n        });\n        if(e.data.accessmask == e.data.FullMask){\n            e.set('accessmask_AA', 1);\n        }\n    });\n}"
+                                "load": "function (_self, records, options)\n{\n    _this.dataUpdate = {};\n    var fmask = 'ADEPS'.split('');\n    \n    Roo.each(records, function(e){\n        _this.dataUpdate[e.id] = e.accessmask;\n    \n        var k = e.data.accessmask.split('');\n        var rm = e.data.FullMask.split('');\n        \n        Roo.each(full, function(ee){\n            if (rm.indexOf(ee) < 0) {\n                e.set('accessmask_'+ee, -1);          \n                return;\n            }\n            \n            e.set('accessmask_'+ee, (k.indexOf(ee) < 0) ? 0 : 1);\n        });\n        \n        if(e.data.accessmask == e.data.FullMask){\n            e.set('accessmask_AA', 1);\n        }\n    });\n}"
                             },
                             "*prop": "dataSource",
                             "remoteSort": true,
index 65416bf..9c32ac4 100644 (file)
@@ -140,14 +140,23 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                         load : function (_self, records, options)
                         {
                             _this.dataUpdate = {};
+                            var fmask = 'ADEPS'.split('');
+                            
                             Roo.each(records, function(e){
                                 _this.dataUpdate[e.id] = e.accessmask;
                             
                                 var k = e.data.accessmask.split('');
+                                var rm = e.data.FullMask.split('');
                                 
-                                Roo.each(k, function(ee){
-                                    e.set('accessmask_'+ee, 1);
+                                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);
                                 }