Pman.Tab.AdminContactsGroupRight.bjs
authorChris <chris@roojs.com>
Wed, 12 Sep 2012 09:32:37 +0000 (17:32 +0800)
committerChris <chris@roojs.com>
Wed, 12 Sep 2012 09:32:37 +0000 (17:32 +0800)
Pman.Tab.AdminContactsGroupRight.js

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

index 3d4aa0e..3c78b15 100644 (file)
@@ -35,7 +35,7 @@
                     "items": [
                         {
                             "listeners": {
-                                "beforeload": "function (_self, o)\n{\n    if(!_this.active_company_button.pressed){\n        o.params['!company_id_comptype'] = 'OWNER';\n    }\n    \n    o.params['query[search]'] = _this.searchBox.getValue();\n    \n    if (!_this.activeButton) {return; false;}\n    \n    if (_this.companyCombo &&   _this.companyCombo.getValue()) {\n        o.params.company_id =   _this.companyCombo.getValue();\n    }\n    \n    \n    o.params.active = _this.activeButton.pressed ? 0 : 1;\n    \n    if(_this.active_company_button.pressed){\n        o.params.company_id = 0;\n    }\n    if (!Pman.Tab.AdminContactsGroup) { \n        return false;\n    }\n    \n    \n    if (Pman.Tab.AdminContactsGroup && Pman.Tab.AdminContactsGroup.grid) {\n        var tms = Pman.Tab.AdminContactsGroup.grid.getSelectionModel().getSelected();\n        \n        if (!tms) {\n            return false;\n        }\n        o.params['query[in_group]'] = tms.data.id;\n        o.params['query[type]'] = 2; // group type..\n        \n    }\n    //o.params['query[name]'] = _this.searchBox.getValue();\n  \n}",
+                                "beforeload": "function (_self, o)\n{\n    if (!o.params) {\n        o.params = {}\n    }\n    var s = Pman.Tab.Groups.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/Person.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}"
                             },
                             "*prop": "dataSource",
index bed3b4a..d55b11f 100644 (file)
@@ -81,40 +81,21 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                     listeners : {
                         beforeload : function (_self, o)
                         {
-                            if(!_this.active_company_button.pressed){
-                                o.params['!company_id_comptype'] = 'OWNER';
+                            if (!o.params) {
+                                o.params = {}
                             }
-                            
-                            o.params['query[search]'] = _this.searchBox.getValue();
-                            
-                            if (!_this.activeButton) {return; false;}
-                            
-                            if (_this.companyCombo &&   _this.companyCombo.getValue()) {
-                                o.params.company_id =   _this.companyCombo.getValue();
+                            var s = Pman.Tab.Groups.grid.getSelectionModel().getSelections();
+                            if (!s.length) {
+                                o.params.group_id = -1;
+                            } else {
+                                o.params.group_id = s[0].data.id;
                             }
-                            
-                            
-                            o.params.active = _this.activeButton.pressed ? 0 : 1;
-                            
-                            if(_this.active_company_button.pressed){
-                                o.params.company_id = 0;
-                            }
-                            if (!Pman.Tab.AdminContactsGroup) { 
+                            if (o.params.group_id < 0) {
+                                _this.grid.getView().el.mask("You can not set permissions for that group");
                                 return false;
                             }
-                            
-                            
-                            if (Pman.Tab.AdminContactsGroup && Pman.Tab.AdminContactsGroup.grid) {
-                                var tms = Pman.Tab.AdminContactsGroup.grid.getSelectionModel().getSelected();
-                                
-                                if (!tms) {
-                                    return false;
-                                }
-                                o.params['query[in_group]'] = tms.data.id;
-                                o.params['query[type]'] = 2; // group type..
-                                
-                            }
-                            //o.params['query[name]'] = _this.searchBox.getValue();
+                            _this.grid.getView().el.unmask();
+                            return true;
                           
                         },
                         update : function (_self, record, operation)