Pman.Tab.AdminWatches.bjs
[Pman.Admin] / Pman.Tab.AdminWatches.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.AdminWatches = new Roo.XComponent({
6     part     :  ["Admin","Watches"],
7     order    : '860-Pman.Tab.AdminWatches',
8     region   : 'center',
9     parent   : 'Pman.Tab.AdminWatchNotify',
10     name     : "Pman.Tab.AdminWatches",
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 : false,
29             background : true,
30             fitContainer : true,
31             fitToframe : true,
32             region : 'center',
33             tableName : 'core_watch',
34             title : (function() {Roo.log('title') ;Roo.log(_this); return _this.title || "Watches"; })(),
35             grid : {
36                 xtype: 'Grid',
37                 xns: Roo.grid,
38                 listeners : {
39                     render : function() 
40                     {
41                         _this.grid = this; 
42                         _this.dialog = Pman.Dialog.AdminWatch;
43                         if (_this.panel.active) {
44                            this.footer.onClick('first');
45                         }
46                     },
47                     rowdblclick : function (_self, rowIndex, e)
48                     {
49                         if (!_this.dialog) return;
50                         _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
51                             _this.grid.footer.onClick('first');
52                         }); 
53                     }
54                 },
55                 autoExpandColumn : 'person_id_name',
56                 loadMask : true,
57                 dataSource : {
58                     xtype: 'Store',
59                     xns: Roo.data,
60                     listeners : {
61                         beforeload : function (_self, options)
62                         {
63                                 var val = _this.affectSel.getValue();
64                                 if (val.length) {
65                                     options.params.ontable = val;
66                                 }
67                                 if (_this.requestArgs) { 
68                                     Roo.apply(options.params, _this.requestArgs);
69                                 }
70                                 
71                         }
72                     },
73                     remoteSort : true,
74                     sortInfo : { field : 'ontable', direction: 'ASC' },
75                     proxy : {
76                         xtype: 'HttpProxy',
77                         xns: Roo.data,
78                         method : 'GET',
79                         url : baseURL + '/Roo/core_watch.php'
80                     },
81                     reader : {
82                         xtype: 'JsonReader',
83                         xns: Roo.data,
84                         totalProperty : 'total',
85                         root : 'data',
86                         id : 'id',
87                         fields : [
88                             {
89                                 'name': 'id',
90                                 'type': 'int'
91                             },
92                             {
93                                 'name': 'ontable',
94                                 'type': 'string'
95                             },
96                             {
97                                 'name': 'onid',
98                                 'type': 'int'
99                             },
100                             {
101                                 'name': 'person_id',
102                                 'type': 'int'
103                             },
104                             {
105                                 'name': 'event',
106                                 'type': 'string'
107                             },
108                             {
109                                 'name': 'medium',
110                                 'type': 'string'
111                             },
112                             {
113                                 'name': 'active',
114                                 'type': 'int'
115                             },
116                             {
117                                 'name': 'person_id_id',
118                                 'type': 'int'
119                             },
120                             {
121                                 'name': 'person_id_office_id',
122                                 'type': 'int'
123                             },
124                             {
125                                 'name': 'person_id_name',
126                                 'type': 'string'
127                             },
128                             {
129                                 'name': 'person_id_phone',
130                                 'type': 'string'
131                             },
132                             {
133                                 'name': 'person_id_fax',
134                                 'type': 'string'
135                             },
136                             {
137                                 'name': 'person_id_email',
138                                 'type': 'string'
139                             },
140                             {
141                                 'name': 'person_id_company_id',
142                                 'type': 'int'
143                             },
144                             {
145                                 'name': 'person_id_role',
146                                 'type': 'string'
147                             },
148                             {
149                                 'name': 'person_id_active',
150                                 'type': 'int'
151                             },
152                             {
153                                 'name': 'person_id_remarks',
154                                 'type': 'string'
155                             },
156                             {
157                                 'name': 'person_id_passwd',
158                                 'type': 'string'
159                             },
160                             {
161                                 'name': 'person_id_owner_id',
162                                 'type': 'int'
163                             },
164                             {
165                                 'name': 'person_id_lang',
166                                 'type': 'string'
167                             },
168                             {
169                                 'name': 'person_id_no_reset_sent',
170                                 'type': 'int'
171                             },
172                             {
173                                 'name': 'person_id_action_type',
174                                 'type': 'string'
175                             },
176                             {
177                                 'name': 'person_id_project_id',
178                                 'type': 'int'
179                             },
180                             {
181                                 'name': 'person_id_deleted_by',
182                                 'type': 'int'
183                             },
184                             {
185                                 'name': 'person_id_deleted_dt',
186                                 'type': 'date'
187                             }
188                         ]
189                     }
190                 },
191                 footer : {
192                     xtype: 'PagingToolbar',
193                     xns: Roo,
194                     pageSize : 25,
195                     displayInfo : true,
196                     displayMsg : "Displaying core_watch{0} - {1} of {2}",
197                     emptyMsg : "No core_watch found"
198                 },
199                 toolbar : {
200                     xtype: 'Toolbar',
201                     xns: Roo,
202                     items : [
203                         {
204                             xtype: 'TextItem',
205                             xns: Roo.Toolbar,
206                             text : "Show"
207                         },
208                         {
209                             xtype: 'ComboBox',
210                             xns: Roo.form,
211                             listeners : {
212                                 select : function (combo, record, index)
213                                 {
214                                   _this.grid.footer.onClick('first');
215                                 },
216                                 render : function (_self)
217                                 {
218                                   _this.affectSel = _self;
219                                 }
220                             },
221                             allowBlank : true,
222                             displayField : 'on_table',
223                             editable : false,
224                             emptyText : "Select Table",
225                             forceSelection : true,
226                             listWidth : 300,
227                             loadingText : "Searching...",
228                             minChars : 2,
229                             name : 'ontable',
230                             pageSize : 20,
231                             qtip : "Select Action",
232                             queryParam : 'query[ontable]',
233                             selectOnFocus : true,
234                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{on_table}</b> </div>',
235                             triggerAction : 'all',
236                             typeAhead : true,
237                             valueField : 'on_table',
238                             width : 150,
239                             store : {
240                                 xtype: 'Store',
241                                 xns: Roo.data,
242                                 listeners : {
243                                     beforeload : function (_self, o)
244                                     {
245                                         o.params = o.params || {};
246                                         // staff can see all logs, other companies can only see their own.
247                                         if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
248                                             o.params.company_id = Pman.Login.authUser.company_id;
249                                         }
250                                         o.params._distinct = 'on_table';
251                                         o.params._columns ='on_table';
252                                     }
253                                 },
254                                 remoteSort : true,
255                                 sortInfo : { field : 'on_table' , direction : 'ASC' },
256                                 proxy : {
257                                     xtype: 'HttpProxy',
258                                     xns: Roo.data,
259                                     method : 'GET',
260                                     url : baseURL + '/Roo/Events.php'
261                                 },
262                                 reader : {
263                                     xtype: 'JsonReader',
264                                     xns: Roo.data,
265                                     id : 'id',
266                                     root : 'data',
267                                     totalProperty : 'total',
268                                     fields : [
269                                         {
270                                             'name': 'id',
271                                             'type': 'int'
272                                         },
273                                         {
274                                             'name': 'on_table',
275                                             'type': 'string'
276                                         }
277                                          
278                                     ]
279                                 }
280                             }
281                         },
282                         {
283                             xtype: 'Fill',
284                             xns: Roo.Toolbar
285                         },
286                         {
287                             xtype: 'Button',
288                             xns: Roo.Toolbar,
289                             text : "Add",
290                             cls : 'x-btn-text-icon',
291                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
292                             listeners : {
293                                 click : function()
294                                 {
295                                     if (!_this.dialog) return;
296                                     _this.dialog.show( { id : 0 } , function() {
297                                         _this.grid.footer.onClick('first');
298                                    }); 
299                                 }
300                             }
301                         },
302                         {
303                             xtype: 'Button',
304                             xns: Roo.Toolbar,
305                             text : "Delete",
306                             cls : 'x-btn-text-icon',
307                             icon : rootURL + '/Pman/templates/images/trash.gif',
308                             listeners : {
309                                 click : function()
310                                 {
311                                      Pman.genericDelete(_this, 'core_watch'); 
312                                 }
313                             }
314                         }
315                     ]
316                 },
317                 colModel : [
318                     {
319                         xtype: 'ColumnModel',
320                         xns: Roo.grid,
321                         dataIndex : 'event',
322                         header : 'Watch Event',
323                         width : 150,
324                         renderer : function(v,x,r) { 
325                             if (typeof(r.data.event_right_display_name) != 'undefined') {
326                                 return String.format('{0}: {1}', r.data.event_left, r.data.event_right_display_name);     
327                             }
328                             return String.format('{0}', v); 
329                             
330                         }
331                     },
332                     {
333                         xtype: 'ColumnModel',
334                         xns: Roo.grid,
335                         dataIndex : 'ontable',
336                         header : 'Watch Table',
337                         width : 150,
338                         renderer : function(v) { return String.format('{0}', v); }
339                     },
340                     {
341                         xtype: 'ColumnModel',
342                         xns: Roo.grid,
343                         dataIndex : 'onid',
344                         header : 'Watch ID',
345                         width : 75,
346                         renderer : function(v) { return String.format('{0}', v); }
347                     },
348                     {
349                         xtype: 'ColumnModel',
350                         xns: Roo.grid,
351                         dataIndex : 'person_id_name',
352                         header : 'Who get\'s notified',
353                         width : 150,
354                         renderer : function(v) { return String.format('{0}', v); }
355                     },
356                     {
357                         xtype: 'ColumnModel',
358                         xns: Roo.grid,
359                         dataIndex : 'medium',
360                         header : 'What happens',
361                         width : 300,
362                         renderer : function(v) {
363                             var ar = v.split(':');
364                             if (ar.length > 1) {
365                                 var act = ar[1].replace(/^notify/,'');
366                         
367                                 return String.format('<span qtip="{0}">{1}<span>', v, act);
368                             }
369                         
370                             return String.format('{0}', v);
371                          }
372                     },
373                     {
374                         xtype: 'ColumnModel',
375                         xns: Roo.grid,
376                         header : 'Active',
377                         width : 75,
378                         dataIndex : 'active',
379                         renderer : function(v) { return String.format('{0}', v); }
380                     }
381                 ]
382             }
383         };
384     }
385 });