Pman.Tab.AdminContactsGroupRight.bjs
[Pman.Admin] / Pman.Tab.AdminContactsGroupRight.bjs
index 4d93d7b..9624223 100644 (file)
     "path": "/home/chris/gitlive/Pman.Admin/Pman.Tab.AdminContactsGroupRight.bjs",
     "items": [
         {
-            "region": "east",
+            "listeners": {
+                "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
+            },
+            "autoScroll": true,
+            "background": true,
+            "fitContainer": true,
+            "fitToframe": true,
+            "region": "center",
+            "tableName": "Person",
             "title": "Rights",
             "xtype": "GridPanel",
-            "|xns": "Roo"
+            "|xns": "Roo",
+            "items": [
+                {
+                    "listeners": {
+                        "|render": "function() \n{\n    _this.grid = this; \n    if (!_this.dialog) {\n        _this.dialog = Pman.Dialog.PersonEdit;\n        \n    }\n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
+                        "|rowdblclick": "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {\n        _this.grid.footer.onClick('first');\n    }); \n}\n",
+                        "cellclick": "function (_self, rowIndex, columnIndex, e)\n{\n\n        var di = this.colModel.getDataIndex(columnIndex);\n        var i = di.split('_').shift();\n        var k = di.split('_').pop();\n        if (i != 'accessmask') {\n            return;\n        }\n        var rec = _this.grid.ds.getAt(rowIndex);\n        if(k == 'AA'){\n            var fm = rec.data.FullMask.split('');\n            Roo.each(fm, function(e){\n                rec.set(i+'_'+e, rec.data[i+'_'+k] ? 0 : 1);\n            });\n        } \n        rec.set(i+'_'+k, rec.data[i+'_'+k] ? 0 : 1);\n        \n        //rec.commit();\n         \n        \n}"
+                    },
+                    "*prop": "grid",
+                    "ddGroup": "groupDD",
+                    "enableDrag": true,
+                    "loadMask": true,
+                    "xtype": "Grid",
+                    "|xns": "Roo.grid",
+                    "items": [
+                        {
+                            "listeners": {
+                                "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/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}"
+                            },
+                            "*prop": "dataSource",
+                            "remoteSort": true,
+                            "xtype": "Store",
+                            "|sortInfo": "{ field : 'id', direction: 'ASC' }",
+                            "|xns": "Roo.data",
+                            "items": [
+                                {
+                                    "*prop": "proxy",
+                                    "method": "GET",
+                                    "xtype": "HttpProxy",
+                                    "|url": "baseURL + '/Admin/GroupRights.php'",
+                                    "|xns": "Roo.data"
+                                },
+                                {
+                                    "*prop": "reader",
+                                    "id": "id",
+                                    "root": "data",
+                                    "totalProperty": "total",
+                                    "xtype": "JsonReader",
+                                    "|fields": "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'rightname',\n        'type': 'string'\n    },\n    {\n        'name': 'descript',\n        'type': 'string'\n    },\n    {\n        'name': 'accessmask',\n        'type': 'string'\n    },\n    {\n        'name': 'FullMask',\n        'type': 'string'\n    },\n    {\n        'name': 'group_id',\n        'type': 'int'\n    }\n]",
+                                    "|xns": "Roo.data"
+                                }
+                            ]
+                        },
+                        {
+                            "*prop": "footer",
+                            "xtype": "PagingToolbar",
+                            "pageSize": 25,
+                            "displayInfo": true,
+                            "displayMsg": "Displaying Person{0} - {1} of {2}",
+                            "emptyMsg": "No Person found",
+                            "|xns": "Roo",
+                            "items": [
+                                {
+                                    "text": "Drag person to add or remove from group",
+                                    "xtype": "TextItem",
+                                    "|xns": "Roo.Toolbar"
+                                }
+                            ]
+                        },
+                        {
+                            "*prop": "toolbar",
+                            "xtype": "Toolbar",
+                            "|xns": "Roo",
+                            "items": [
+                                {
+                                    "text": "Search",
+                                    "xtype": "TextItem",
+                                    "|xns": "Roo.Toolbar"
+                                },
+                                {
+                                    "listeners": {
+                                        "render": "function (_self)\n{\n    _this.searchBox = _self;\n}",
+                                        "show": "function (_self,e)\n{\n    if (e.getCharCode() != 13) {\n        return;\n    }\n    _this.grid.footer.onClick('first');\n}",
+                                        "specialkey": "function (_self, e)\n{\n  if (e.getKey() == 13) {\n    _this.grid.footer.onClick('first');\n  }\n}"
+                                    },
+                                    "xtype": "TextField",
+                                    "|xns": "Roo.form"
+                                },
+                                {
+                                    "listeners": {
+                                        "render": "function (_self)\n{\n  _this.companyCombo = _self;\n}",
+                                        "select": "function (combo, record, index)\n{\n   _this.grid.footer.onClick.defer(300,_this.grid.footer,[ 'first'] );\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": [
+                                        {
+                                            "listeners": {
+                                                "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
+                                            },
+                                            "*prop": "store",
+                                            "remoteSort": true,
+                                            "xtype": "Store",
+                                            "|sortInfo": "{ direction : 'ASC', field: 'name' }",
+                                            "|xns": "Roo.data",
+                                            "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\"}]"
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                },
+                                {
+                                    "|xns": "Roo.Toolbar",
+                                    "xtype": "Fill"
+                                }
+                            ]
+                        },
+                        {
+                            "*prop": "colModel[]",
+                            "dataIndex": "accessmask_AA",
+                            "header": "All",
+                            "sortable": false,
+                            "width": 50,
+                            "xtype": "ColumnModel",
+                            "|renderer": "function(v,x,r) {\n    var state = v> 0 ?  '-checked' : '';\n\n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n}",
+                            "|xns": "Roo.grid"
+                        },
+                        {
+                            "*prop": "colModel[]",
+                            "dataIndex": "rightname",
+                            "header": "Module",
+                            "sortable": false,
+                            "width": 150,
+                            "xtype": "ColumnModel",
+                            "|renderer": "function(v,x,r) {\n    if(!v){\n        return;\n    }\n    return String.format('<span qtip=\"{1}\">{0}</span>', v.split('.').shift(), v);\n}",
+                            "|xns": "Roo.grid"
+                        },
+                        {
+                            "*prop": "colModel[]",
+                            "dataIndex": "descript",
+                            "header": "Permission",
+                            "sortable": false,
+                            "width": 300,
+                            "xtype": "ColumnModel",
+                            "|renderer": "function(v,x,r)\n{\n    if (r.json.descript && r.json.descript.length) {\n        return String.format('{0}',r.json.descript);\n    }\n    \n    return '???' + v;\n}",
+                            "|xns": "Roo.grid"
+                        },
+                        {
+                            "*prop": "colModel[]",
+                            "dataIndex": "accessmask_A",
+                            "header": "Add",
+                            "width": 75,
+                            "xtype": "ColumnModel",
+                            "|renderer": "function(v) {  \n    var state = v> 0 ?  '-checked' : '';\n\n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n                \n }",
+                            "|xns": "Roo.grid"
+                        },
+                        {
+                            "*prop": "colModel[]",
+                            "dataIndex": "accessmask_E",
+                            "header": "Edit",
+                            "width": 75,
+                            "xtype": "ColumnModel",
+                            "|renderer": "function(v) {  \n    var state = v> 0 ?  '-checked' : '';\n\n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n                \n }",
+                            "|xns": "Roo.grid"
+                        },
+                        {
+                            "*prop": "colModel[]",
+                            "dataIndex": "accessmask_D",
+                            "header": "Delete",
+                            "width": 75,
+                            "xtype": "ColumnModel",
+                            "|renderer": "function(v) {  \n    var state = v> 0 ?  '-checked' : '';\n\n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n                \n }",
+                            "|xns": "Roo.grid"
+                        },
+                        {
+                            "*prop": "colModel[]",
+                            "dataIndex": "accessmask_S",
+                            "header": "List/View",
+                            "width": 75,
+                            "xtype": "ColumnModel",
+                            "|renderer": "function(v) {  \n    var state = v> 0 ?  '-checked' : '';\n\n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n                \n }",
+                            "|xns": "Roo.grid"
+                        },
+                        {
+                            "*prop": "colModel[]",
+                            "dataIndex": "accessmask_P",
+                            "header": "Print/Export",
+                            "width": 75,
+                            "xtype": "ColumnModel",
+                            "|renderer": "function(v,x,r) {  \n    Roo.log(x);\n    Roo.log(r);\n    r.data.accesmask\n    var state = v> 0 ?  '-checked' : '';\n\n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n                \n }",
+                            "|xns": "Roo.grid"
+                        }
+                    ]
+                }
+            ]
         }
     ],
     "permname": "",