Pman.Tab.AdminContactsGroup.js
[Pman.Admin] / Pman.Tab.AdminContactsGroup.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5
6
7 // register the module first
8 Pman.on('beforeload', function()
9 {
10     Pman.register({
11         modKey : '001-Pman.Tab.AdminContactsGroup',
12         module : Pman.Tab.AdminContactsGroup,
13         region : 'west',
14         parent : Pman.Tab.AdminContactsManager,
15         name : "Pman.Tab.AdminContactsGroup",
16         disabled : false, 
17         permname: '' 
18     });
19 });
20
21 Pman.Tab.AdminContactsGroup = new Roo.util.Observable({
22
23     panel : false,
24     disabled : false,
25     parentLayout:  false,
26
27     add : function(parentLayout, region)
28     {
29
30         var _this = this;
31         this.parentLayout = parentLayout;
32
33         this.panel = parentLayout.addxtype({
34             xtype: 'GridPanel',
35             xns: Roo,
36             title : "Groups",
37             fitToframe : true,
38             fitContainer : true,
39             tableName : 'Groups',
40             background : true,
41             region : 'center',
42             listeners : {
43                 activate : function() {
44                     _this.panel = this;
45                     if (_this.grid) {
46                         _this.grid.footer.onClick('first');
47                     }
48                 }
49             },
50             grid : {
51                 xtype: 'Grid',
52                 xns: Roo.grid,
53                 autoExpandColumn : 'name',
54                 loadMask : true,
55                 listeners : {
56                     render : function() 
57                     {
58                         _this.grid = this; 
59                         //_this.dialog = Pman.Dialog.FILL_IN
60                         if (_this.panel.active) {
61                            this.footer.onClick('first');
62                         }
63                     },
64                     rowdblclick : function (_self, rowIndex, e)
65                     {
66                         if (!_this.dialog) return;
67                         _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
68                             _this.grid.footer.onClick('first');
69                         }); 
70                     }
71                 },
72                 dataSource : {
73                     xtype: 'Store',
74                     xns: Roo.data,
75                     remoteSort : true,
76                     sortInfo : { field : 'name', direction: 'ASC' },
77                     proxy : {
78                         xtype: 'HttpProxy',
79                         xns: Roo.data,
80                         method : 'GET',
81                         url : baseURL + '/Roo/Groups.php'
82                     },
83                     reader : {
84                         xtype: 'JsonReader',
85                         xns: Roo.data,
86                         totalProperty : 'total',
87                         root : 'data',
88                         id : 'id',
89                         fields : [
90                             {
91                                 'name': 'id',
92                                 'type': 'int'
93                             },
94                             {
95                                 'name': 'name',
96                                 'type': 'string'
97                             },
98                             {
99                                 'name': 'type',
100                                 'type': 'int'
101                             },
102                             {
103                                 'name': 'leader',
104                                 'type': 'int'
105                             },
106                             {
107                                 'name': 'leader_id',
108                                 'type': 'int'
109                             },
110                             {
111                                 'name': 'leader_office_id',
112                                 'type': 'int'
113                             },
114                             {
115                                 'name': 'leader_name',
116                                 'type': 'string'
117                             },
118                             {
119                                 'name': 'leader_phone',
120                                 'type': 'string'
121                             },
122                             {
123                                 'name': 'leader_fax',
124                                 'type': 'string'
125                             },
126                             {
127                                 'name': 'leader_email',
128                                 'type': 'string'
129                             },
130                             {
131                                 'name': 'leader_company_id',
132                                 'type': 'int'
133                             },
134                             {
135                                 'name': 'leader_role',
136                                 'type': 'string'
137                             },
138                             {
139                                 'name': 'leader_active',
140                                 'type': 'int'
141                             },
142                             {
143                                 'name': 'leader_remarks',
144                                 'type': 'string'
145                             },
146                             {
147                                 'name': 'leader_passwd',
148                                 'type': 'string'
149                             },
150                             {
151                                 'name': 'leader_owner_id',
152                                 'type': 'int'
153                             },
154                             {
155                                 'name': 'leader_lang',
156                                 'type': 'string'
157                             },
158                             {
159                                 'name': 'leader_no_reset_sent',
160                                 'type': 'int'
161                             },
162                             {
163                                 'name': 'leader_action_type',
164                                 'type': 'string'
165                             },
166                             {
167                                 'name': 'leader_project_id',
168                                 'type': 'int'
169                             }
170                         ]
171                     }
172                 },
173                 toolbar : {
174                     xtype: 'Toolbar',
175                     xns: Roo,
176                     items : [
177                         {
178                             xtype: 'Button',
179                             xns: Roo.Toolbar,
180                             text : "Manage Groups",
181                             menu : {
182                                 xtype: 'Menu',
183                                 xns: Roo.menu,
184                                 items : [
185                                     {
186                                         xtype: 'Item',
187                                         xns: Roo.menu,
188                                         listeners : {
189                                             click : function()
190                                             {
191                                                 if (!_this.dialog) return;
192                                                 _this.dialog.show( { id : 0 } , function() {
193                                                     _this.grid.footer.onClick('first');
194                                                }); 
195                                             }
196                                         },
197                                         cls : 'x-btn-text-icon',
198                                         text : "Add",
199                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
200                                     },
201                                     {
202                                         xtype: 'Item',
203                                         xns: Roo.menu,
204                                         listeners : {
205                                             click : function()
206                                             {
207                                                 var s = _this.grid.getSelectionModel().getSelections();
208                                                 if (!s.length || (s.length > 1))  {
209                                                     Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
210                                                     return;
211                                                 }
212                                                 if (!_this.dialog) return;
213                                                 _this.dialog.show(s[0].data, function() {
214                                                     _this.grid.footer.onClick('first');
215                                                 }); 
216                                                 
217                                             }
218                                         },
219                                         cls : 'x-btn-text-icon',
220                                         text : "Edit",
221                                         icon : Roo.rootURL + 'images/default/tree/leaf.gif'
222                                     }
223                                 ]
224                             }
225                         },
226                         {
227                             xtype: 'Item',
228                             xns: Roo.Toolbar,
229                             listeners : {
230                                 click : function()
231                                 {
232                                      Pman.genericDelete(_this, 'Groups'); 
233                                 }
234                             },
235                             cls : 'x-btn-text-icon',
236                             text : "Delete",
237                             icon : rootURL + '/Pman/templates/images/trash.gif'
238                         }
239                     ]
240                 },
241                 colModel : [
242                     {
243                         xtype: 'ColumnModel',
244                         xns: Roo.grid,
245                         header : 'Name',
246                         width : 200,
247                         dataIndex : 'name',
248                         renderer : function(v) { return String.format('{0}', v); }
249                     }
250                 ]
251             }
252         });
253         this.layout = this.panel.layout;
254
255     }
256 });