Pman.Tab.AdminContactsGroupRight.bjs
[Pman.Admin] / Pman.Tab.AdminContactsGroupRight.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
6     part     :  ["Admin","ContactsGroupRight"],
7     order    : '001-Pman.Tab.AdminContactsGroupRight',
8     region   : 'center',
9     parent   : 'Pman.Tab.AdminContactsManager',
10     name     : "unnamed module",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'GridPanel',
19             xns: Roo,
20             listeners : {
21                 activate : function() {
22                     _this.panel = this;
23                     if (_this.grid) {
24                         _this.grid.footer.onClick('first');
25                     }
26                 }
27             },
28             autoScroll : true,
29             background : true,
30             fitContainer : true,
31             fitToframe : true,
32             region : 'center',
33             tableName : 'Person',
34             title : "Rights",
35             grid : {
36                 xtype: 'Grid',
37                 xns: Roo.grid,
38                 listeners : {
39                     render : function() 
40                     {
41                         _this.grid = this; 
42                         if (!_this.dialog) {
43                             _this.dialog = Pman.Dialog.PersonEdit;
44                             
45                         }
46                         //_this.dialog = Pman.Dialog.FILL_IN
47                         if (_this.panel.active) {
48                            this.footer.onClick('first');
49                         }
50                     },
51                     rowdblclick : function (_self, rowIndex, e)
52                     {
53                         if (!_this.dialog) return;
54                         _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
55                             _this.grid.footer.onClick('first');
56                         }); 
57                     },
58                     cellclick : function (_self, rowIndex, columnIndex, e)
59                     {
60                     
61                             var di = this.colModel.getDataIndex(columnIndex);
62                             var i = di.split('_').shift();
63                             var k = di.split('_').pop();
64                             
65                             if (i != 'accessmask') {
66                                 return;
67                             }
68                     
69                             var rec = _this.grid.ds.getAt(rowIndex);
70                             Roo.log(di);
71                             Roo.log(rec);
72                             rec.set(i+'_'+k, rec.data[i+'_'+k] ? 0 : 1);
73                             //rec.commit();
74                              
75                             
76                     }
77                 },
78                 ddGroup : 'groupDD',
79                 enableDrag : true,
80                 loadMask : true,
81                 dataSource : {
82                     xtype: 'Store',
83                     xns: Roo.data,
84                     listeners : {
85                         beforeload : function (_self, o)
86                         {
87                             if (!o.params) {
88                                 o.params = {}
89                             }
90                             var s = Pman.Tab.Groups.grid.getSelectionModel().getSelections();
91                             if (!s.length) {
92                                 o.params.group_id = -1;
93                             } else {
94                                 o.params.group_id = s[0].data.id;
95                             }
96                             if (o.params.group_id < 0) {
97                                 _this.grid.getView().el.mask("You can not set permissions for that group");
98                                 return false;
99                             }
100                             _this.grid.getView().el.unmask();
101                             return true;
102                           
103                         },
104                         update : function (_self, record, operation)
105                         {
106                             if (operation != 'commit') {
107                                 return;
108                             }
109                             // only used to change active status.
110                             
111                             new Pman.Request({
112                                 url : baseURL + '/Roo/Person.php',
113                                 method :'POST',
114                                 params : {
115                                     id : record.data.id,
116                                     active: record.data.active
117                                     
118                                 },
119                                 success : function() {
120                                     // do nothing
121                                     
122                                     _this.grid.ds.remove(record);
123                                     
124                                 },
125                                 failure : function() 
126                                 {
127                                     Roo.MessageBox.alert("Error", "saving failed", function() {
128                                         _this.grid.footer.onClick('first');
129                                     });
130                                 }
131                             });
132                         }
133                     },
134                     remoteSort : true,
135                     sortInfo : { field : 'id', direction: 'ASC' },
136                     proxy : {
137                         xtype: 'HttpProxy',
138                         xns: Roo.data,
139                         method : 'GET',
140                         url : baseURL + '/Admin/GroupRights.php'
141                     },
142                     reader : {
143                         xtype: 'JsonReader',
144                         xns: Roo.data,
145                         id : 'id',
146                         root : 'data',
147                         totalProperty : 'total',
148                         fields : [
149                             {
150                                 'name': 'id',
151                                 'type': 'int'
152                             },
153                             {
154                                 'name': 'rightname',
155                                 'type': 'string'
156                             },
157                             {
158                                 'name': 'descript',
159                                 'type': 'string'
160                             },
161                             {
162                                 'name': 'accessmask',
163                                 'type': 'string'
164                             },
165                             {
166                                 'name': 'FullMask',
167                                 'type': 'string'
168                             },
169                             {
170                                 'name': 'group_id',
171                                 'type': 'int'
172                             }
173                         ]
174                     }
175                 },
176                 footer : {
177                     xtype: 'PagingToolbar',
178                     xns: Roo,
179                     pageSize : 25,
180                     displayInfo : true,
181                     displayMsg : "Displaying Person{0} - {1} of {2}",
182                     emptyMsg : "No Person found",
183                     items : [
184                         {
185                             xtype: 'TextItem',
186                             xns: Roo.Toolbar,
187                             text : "Drag person to add or remove from group"
188                         }
189                     ]
190                 },
191                 toolbar : {
192                     xtype: 'Toolbar',
193                     xns: Roo,
194                     items : [
195                         {
196                             xtype: 'TextItem',
197                             xns: Roo.Toolbar,
198                             text : "Search"
199                         },
200                         {
201                             xtype: 'TextField',
202                             xns: Roo.form,
203                             listeners : {
204                                 render : function (_self)
205                                 {
206                                     _this.searchBox = _self;
207                                 },
208                                 show : function (_self,e)
209                                 {
210                                     if (e.getCharCode() != 13) {
211                                         return;
212                                     }
213                                     _this.grid.footer.onClick('first');
214                                 },
215                                 specialkey : function (_self, e)
216                                 {
217                                   if (e.getKey() == 13) {
218                                     _this.grid.footer.onClick('first');
219                                   }
220                                 }
221                             }
222                         },
223                         {
224                             xtype: 'ComboBox',
225                             xns: Roo.form,
226                             listeners : {
227                                 render : function (_self)
228                                 {
229                                   _this.companyCombo = _self;
230                                 },
231                                 select : function (combo, record, index)
232                                 {
233                                    _this.grid.footer.onClick.defer(300,_this.grid.footer,[ 'first'] );
234                                 }
235                             },
236                             displayField : 'name',
237                             editable : true,
238                             emptyText : "Select Company",
239                             forceSelection : true,
240                             hiddenName : 'company_id',
241                             listWidth : 400,
242                             loadingText : "Searching...",
243                             minChars : 2,
244                             name : 'company_name',
245                             pageSize : 20,
246                             qtip : "Select Companies",
247                             queryParam : 'query[name]',
248                             selectOnFocus : true,
249                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
250                             triggerAction : 'all',
251                             typeAhead : true,
252                             valueField : 'id',
253                             width : 150,
254                             store : {
255                                 xtype: 'Store',
256                                 xns: Roo.data,
257                                 listeners : {
258                                     beforeload : function (_self, o){
259                                         o.params = o.params || {};
260                                         // set more here
261                                     }
262                                 },
263                                 remoteSort : true,
264                                 sortInfo : { direction : 'ASC', field: 'name' },
265                                 proxy : {
266                                     xtype: 'HttpProxy',
267                                     xns: Roo.data,
268                                     method : 'GET',
269                                     url : baseURL + '/Roo/Companies.php'
270                                 },
271                                 reader : {
272                                     xtype: 'JsonReader',
273                                     xns: Roo.data,
274                                     id : 'id',
275                                     root : 'data',
276                                     totalProperty : 'total',
277                                     fields : [{"name":"id","type":"int"},{"name":"code","type":"string"}]
278                                 }
279                             }
280                         },
281                         {
282                             xtype: 'Fill',
283                             xns: Roo.Toolbar
284                         }
285                     ]
286                 },
287                 colModel : [
288                     {
289                         xtype: 'ColumnModel',
290                         xns: Roo.grid,
291                         dataIndex : 'accessmask_AA',
292                         header : 'All',
293                         sortable : false,
294                         width : 50,
295                         renderer : function(v,x,r) {
296                             var state = v> 0 ?  '-checked' : '';
297                         
298                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
299                         }
300                     },
301                     {
302                         xtype: 'ColumnModel',
303                         xns: Roo.grid,
304                         dataIndex : 'rightname',
305                         header : 'Module',
306                         sortable : false,
307                         width : 150,
308                         renderer : function(v,x,r) {
309                             if(!v){
310                                 return;
311                             }
312                             return String.format('<span qtip="{1}">{0}</span>', v.split('.').shift(), v);
313                         }
314                     },
315                     {
316                         xtype: 'ColumnModel',
317                         xns: Roo.grid,
318                         dataIndex : 'descript',
319                         header : 'Permission',
320                         sortable : false,
321                         width : 300,
322                         renderer : function(v,x,r)
323                         {
324                             if (r.json.descript && r.json.descript.length) {
325                                 return String.format('{0}',r.json.descript);
326                             }
327                             
328                             return '???' + v;
329                         }
330                     },
331                     {
332                         xtype: 'ColumnModel',
333                         xns: Roo.grid,
334                         dataIndex : 'accessmask_A',
335                         header : 'Add',
336                         width : 75,
337                         renderer : function(v) {  
338                             var state = v> 0 ?  '-checked' : '';
339                         
340                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
341                                         
342                          }
343                     },
344                     {
345                         xtype: 'ColumnModel',
346                         xns: Roo.grid,
347                         dataIndex : 'accessmask_E',
348                         header : 'Edit',
349                         width : 75,
350                         renderer : function(v) {  
351                             var state = v> 0 ?  '-checked' : '';
352                         
353                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
354                                         
355                          }
356                     },
357                     {
358                         xtype: 'ColumnModel',
359                         xns: Roo.grid,
360                         dataIndex : 'accessmask_D',
361                         header : 'Delete',
362                         width : 75,
363                         renderer : function(v) {  
364                             var state = v> 0 ?  '-checked' : '';
365                         
366                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
367                                         
368                          }
369                     },
370                     {
371                         xtype: 'ColumnModel',
372                         xns: Roo.grid,
373                         dataIndex : 'accessmask_S',
374                         header : 'List/View',
375                         width : 75,
376                         renderer : function(v) {  
377                             var state = v> 0 ?  '-checked' : '';
378                         
379                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
380                                         
381                          }
382                     },
383                     {
384                         xtype: 'ColumnModel',
385                         xns: Roo.grid,
386                         dataIndex : 'accessmask_P',
387                         header : 'Print/Export',
388                         width : 75,
389                         renderer : function(v) {  
390                             var state = v> 0 ?  '-checked' : '';
391                         
392                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
393                                         
394                          }
395                     }
396                 ]
397             }
398         };
399     }
400 });