9de8b6bfad7aa59c2dc7d8535832fdcb8e2749e1
[Pman.Admin] / Pman.Tab.AdminCountries.bjs
1 {
2     "id": "roo-file-285",
3     "name": "Pman.Tab.AdminCountries",
4     "parent": "Pman.Tab.AdminContactsManager",
5     "title": "Pman.Tab.AdminCountries",
6     "path": "/home/chris/gitlive/Pman.Admin/Pman.Tab.AdminCountries.bjs",
7     "items": [
8         {
9             "listeners": {
10                 "activate": "function (_self)\n{\n    _this.panel = this;\n    if (_this.grid){\n        _this.grid.ds.load({});\n    }\n}"
11             },
12             "background": true,
13             "fitContainer": true,
14             "fitToFrame": true,
15             "region": "west",
16             "tableName": "Person",
17             "title": "Countries",
18             "xtype": "GridPanel",
19             "|xns": "Roo",
20             "items": [
21                 {
22                     "listeners": {
23                         "|render": "function() \n{\n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.Groups;\n    if (_this.panel.active) {\n        _this.grid.ds.load({});\n    }\n}",
24                         "|rowdblclick": "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n    var s = this.getDataSource().getAt(rowIndex);\n    if (s.data.id < 1 ) {\n        return;\n    }\n    _this.dialog.show( s.data, function() {\n        _this.ds.load({});\n    }); \n}\n"
25                     },
26                     "*prop": "grid",
27                     "autoExpandColumn": "country",
28                     "ddGroup": "groupDD",
29                     "enableDrop": true,
30                     "loadMask": true,
31                     "xtype": "Grid",
32                     "|xns": "Roo.grid",
33                     "items": [
34                         {
35                             "listeners": {
36                                 "beforeload": "function (_self, o)\n{\n    o.params = o.params || {};\n    o.params._distinct = 'country';\n    o.params._columns = 'country,country_tr';\n    o.params.limit = 9999;\n    o.params._hideEmptyCountry = 1;\n}",
37                                 "load": "function (_self, records, options)\n{\n    var sm = _this.grid.getSelectionModel();\n        if (!sm.getSelections().length) {\n            sm.selectFirstRow();\n        }\n        Pman.Tab.AdminContacts.grid.footer.onClick('first');\n}"
38                             },
39                             "*prop": "dataSource",
40                             "remoteSort": true,
41                             "xtype": "Store",
42                             "|sortInfo": "{ field : 'country_tr', direction: 'ASC' }",
43                             "|xns": "Roo.data",
44                             "items": [
45                                 {
46                                     "*prop": "proxy",
47                                     "method": "GET",
48                                     "xtype": "HttpProxy",
49                                     "|url": "baseURL + '/Roo/Clipping.php'",
50                                     "|xns": "Roo.data"
51                                 },
52                                 {
53                                     "|xns": "Roo.data",
54                                     "xtype": "JsonReader",
55                                     "totalProperty": "total",
56                                     "root": "data",
57                                     "*prop": "reader",
58                                     "id": "id",
59                                     "|fields": "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'name',\n        'type': 'string'\n    },\n    {\n        'name': 'type',\n        'type': 'int'\n    },\n    {\n        'name': 'leader',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_id',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_office_id',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_name',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_phone',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_fax',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_email',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_company_id',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_role',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_active',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_remarks',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_passwd',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_owner_id',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_lang',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_no_reset_sent',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_action_type',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_project_id',\n        'type': 'int'\n    }\n]"
60                                 }
61                             ]
62                         },
63                         {
64                             "*prop": "colModel[]",
65                             "dataIndex": "country",
66                             "header": "Country",
67                             "width": 200,
68                             "xtype": "ColumnModel",
69                             "|renderer": "function(v,x,r)\n{\n    if(v*1 == -1){\n        return String.format('<b>{0}</b>', r.data.country_tr);\n    }\n    \n    return String.format('{0}', r.data.country_tr);\n}",
70                             "|xns": "Roo.grid"
71                         },
72                         {
73                             "listeners": {
74                                 "afterselectionchange": "function (_self)\n{\n//    Pman.Tab.AdminContacts.grid.footer.onClick('first');\n    var c = Pman.Tab.AdminContactsManager.layout.getRegion('center');\n    c.getActivePanel().grid.footer.onClick('first');\n    \n}"
75                             },
76                             "*prop": "sm",
77                             "singleSelect": true,
78                             "xtype": "RowSelectionModel",
79                             "|xns": "Roo.grid"
80                         },
81                         {
82                             "listeners": {
83                                 "drop": "function (source, e, data)\n{\n    //Roo.log(\"DROP\");\n    \n    var t = Roo.lib.Event.getTarget(e); \n    var ri = _this.grid.view.findRowIndex(t);\n    var rid  = false;\n    if (ri !== false) {\n        rid = _this.grid.getDataSource().getAt(ri).data;\n    }\n    //var s = _this.grid.getSelectionModel().getSelections();\n      \n    //console.log(data);\n    var isFromGroup = _this.grid.getSelectionModel().isSelected(ri);;\n\n    //var isToGroup = rid && rid.id > 0;\n    this.success = false;\n    \n    if (isFromGroup){\n        return;\n    }\n    var targetCountry = rid.country;\n    var action = 'add';\n    \n    if (targetCountry*1 == -1) {\n        action = 'sub';\n        //return 'x-dd-drop-ok-sub'; \n    }\n    // build a list of selections.\n    var sels = [];\n    \n    for (var i=0; i < data.selections.length; i++){\n        var c = data.selections[i].data.countries.split(',');\n        if(c.indexOf(targetCountry) > -1){\n            //Roo.log(\"skipped : \"+data.selections[i].data.id);\n            continue;\n        }\n        //Roo.log(data.selections[i].data);\n        sels.push(data.selections[i].data.id);\n    }\n    \n    if(sels.length < 1){\n        Roo.MessageBox.alert('Error', 'No person add to group');\n        return;\n    }\n    \n    new Pman.Request({\n        url: baseURL + '/Core/GroupCountries.php',\n        params: {\n            action : action,\n            country: (targetCountry != -1) ? targetCountry : _this.grid.getSelectionModel().getSelected().data.country,\n            user_ids : sels.join(',')\n        },\n        method: 'POST',  \n        success : function(res) {\n            \n            //var data = res.data\n            //refreshPager();\n            // \n            // do we need to do anything??\n            //if (isFromGroup) {\n            //    Pman.Tab.AdminContacts.grid.footer.onClick('refresh');\n            //}\n        }, \n        \n        failure: function() {\n            //Ext.get(document.body).unmask();\n            //if (cb) {\n            //    cb.call(false);\n            //}\n             \n        }\n    });\n\n    this.success = true;\n    return;\n\n}",
84                                 "over": "function (source, e, data)\n{\n    //Roo.log(\"dragover\");\n    \n    var t = Roo.lib.Event.getTarget(e);\n    var ri = _this.grid.view.findRowIndex(t);\n    var rid  = false;\n    if (ri !== false) {\n        rid = _this.grid.getDataSource().getAt(ri).data;\n    }\n    \n    var isFromGroup = _this.grid.getSelectionModel().isSelected(ri);\n    \n    //Roo.log(\", isFromGroup:\" + isFromGroup);\n     \n    if (isFromGroup) {\n        this.valid = false;\n        return;\n    }\n    \n    if(rid.country*1 == -1) {\n        this.valid = 'ok-sub'; \n        return;\n    } \n    \n    this.valid = 'ok-add';\n}"
85                             },
86                             "*prop": "dropTarget",
87                             "ddGroup": "groupDD",
88                             "xtype": "DropTarget",
89                             "|xns": "Roo.dd"
90                         }
91                     ]
92                 }
93             ]
94         }
95     ],
96     "permname": "",
97     "modOrder": "001"
98 }