Pman.Tab.AdminContacts.bjs
authorAlan Knowles <alan@akbkhome.com>
Mon, 24 Oct 2011 03:13:46 +0000 (11:13 +0800)
committerAlan Knowles <alan@akbkhome.com>
Mon, 24 Oct 2011 03:13:46 +0000 (11:13 +0800)
Pman.Tab.AdminContacts.bjs
Pman.Tab.AdminContacts.js
Pman.Tab.AdminContacts.js

Pman.Tab.AdminContacts.bjs
Pman.Tab.AdminContacts.js

index 69a1b3e..3e3b687 100644 (file)
@@ -1,5 +1,5 @@
 {
-    "id": "roo-file-2",
+    "id": "roo-file-88",
     "name": "Pman.Tab.AdminContacts",
     "parent": "Pman.Tab.AdminContactsManager",
     "title": "Pman.Tab.AdminContacts",
@@ -35,7 +35,7 @@
                     "items": [
                         {
                             "listeners": {
-                                "beforeload": "function (_self, o)\n{\n  \n    o.params['!company_id_comptype'] = 'OWNER';\n    o.params['query[search]'] = _this.searchBox.getValue();\n    \n    if (!_this.activeButton) {return; false;}\n    \n    \n    o.params.active = _this.activeButton.pressed ? 0 : 1;\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    \n}",
+                                "beforeload": "function (_self, o)\n{\n  \n    o.params['!company_id_comptype'] = 'OWNER';\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    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}",
                                 "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",
                                     "xtype": "TextField",
                                     "|xns": "Roo.form"
                                 },
+                                {
+                                    "listeners": {
+                                        "render": "function (_self)\n{\n  _this.companyCombo = _self;\n}"
+                                    },
+                                    "displayField": "name",
+                                    "editable": true,
+                                    "emptyText": "Select Company",
+                                    "forceSelection": true,
+                                    "hiddenName": "company_id",
+                                    "listWidth": 400,
+                                    "loadingText": "Searching...",
+                                    "minChars": 2,
+                                    "name": "company_name",
+                                    "pageSize": 20,
+                                    "qtip": "Select Companies",
+                                    "queryParam": "query[name]",
+                                    "selectOnFocus": true,
+                                    "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> </div>",
+                                    "triggerAction": "all",
+                                    "typeAhead": true,
+                                    "valueField": "id",
+                                    "width": 150,
+                                    "xtype": "ComboBox",
+                                    "|xns": "Roo.form",
+                                    "items": [
+                                        {
+                                            "*prop": "store",
+                                            "xtype": "Store",
+                                            "|xns": "Roo.data",
+                                            "remoteSort": true,
+                                            "|sortInfo": "{ direction : 'ASC', field: 'id' }",
+                                            "listeners": {
+                                                "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
+                                            },
+                                            "items": [
+                                                {
+                                                    "*prop": "proxy",
+                                                    "xtype": "HttpProxy",
+                                                    "method": "GET",
+                                                    "|xns": "Roo.data",
+                                                    "|url": "baseURL + '/Roo/Companies.php'"
+                                                },
+                                                {
+                                                    "*prop": "reader",
+                                                    "xtype": "JsonReader",
+                                                    "|xns": "Roo.data",
+                                                    "id": "id",
+                                                    "root": "data",
+                                                    "totalProperty": "total",
+                                                    "|fields": "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"code\",\"type\":\"string\"}]"
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                },
                                 {
                                     "listeners": {
                                         "|click": "function (_self, e)\n{\n_this.grid.footer.onClick('first');\n}"
index a081436..18f74a6 100644 (file)
@@ -8,6 +8,7 @@
 Pman.on('beforeload', function()
 {
     Pman.register({
+        part :  ["Admin","Contacts"],
         modKey : '001-Pman.Tab.AdminContacts',
         module : Pman.Tab.AdminContacts,
         region : 'center',
@@ -103,6 +104,10 @@ Pman.Tab.AdminContacts = new Roo.util.Observable({
                             
                             if (!_this.activeButton) {return; false;}
                             
+                             if (_this.companyCombo &&   _this.companyCombo.getValue()) {
+                                o.params.company_id =   _this.companyCombo.getValue();
+                            }
+                            
                             
                             o.params.active = _this.activeButton.pressed ? 0 : 1;
                             if (!Pman.Tab.AdminContactsGroup) { 
@@ -122,7 +127,6 @@ Pman.Tab.AdminContacts = new Roo.util.Observable({
                             }
                             //o.params['query[name]'] = _this.searchBox.getValue();
                           
-                            
                         },
                         update : function (_self, record, operation)
                         {
@@ -481,8 +485,8 @@ Pman.Tab.AdminContacts = new Roo.util.Observable({
                     xns: Roo,
                     pageSize : 25,
                     displayInfo : true,
-                    displayMsg : 'Displaying Person{0} - {1} of {2}',
-                    emptyMsg : 'No Person found',
+                    displayMsg : "Displaying Person{0} - {1} of {2}",
+                    emptyMsg : "No Person found",
                     items : [
                         {
                             xtype: 'TextItem',
@@ -523,6 +527,60 @@ Pman.Tab.AdminContacts = new Roo.util.Observable({
                                 }
                             }
                         },
+                        {
+                            xtype: 'ComboBox',
+                            xns: Roo.form,
+                            listeners : {
+                                render : function (_self)
+                                {
+                                  _this.companyCombo = _self;
+                                }
+                            },
+                            displayField : 'name',
+                            editable : true,
+                            emptyText : "Select Company",
+                            forceSelection : true,
+                            hiddenName : 'company_id',
+                            listWidth : 400,
+                            loadingText : "Searching...",
+                            minChars : 2,
+                            name : 'company_name',
+                            pageSize : 20,
+                            qtip : "Select Companies",
+                            queryParam : 'query[name]',
+                            selectOnFocus : true,
+                            tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
+                            triggerAction : 'all',
+                            typeAhead : true,
+                            valueField : 'id',
+                            width : 150,
+                            store : {
+                                xtype: 'Store',
+                                xns: Roo.data,
+                                remoteSort : true,
+                                sortInfo : { direction : 'ASC', field: 'id' },
+                                listeners : {
+                                    beforeload : function (_self, o){
+                                        o.params = o.params || {};
+                                        // set more here
+                                    }
+                                },
+                                proxy : {
+                                    xtype: 'HttpProxy',
+                                    xns: Roo.data,
+                                    method : 'GET',
+                                    url : baseURL + '/Roo/Companies.php'
+                                },
+                                reader : {
+                                    xtype: 'JsonReader',
+                                    xns: Roo.data,
+                                    id : 'id',
+                                    root : 'data',
+                                    totalProperty : 'total',
+                                    fields : [{"name":"id","type":"int"},{"name":"code","type":"string"}]
+                                }
+                            }
+                        },
                         {
                             xtype: 'Button',
                             xns: Roo.Toolbar,