Pman.Dialog.AdminWatch.bjs
[Pman.Admin] / old / Pman.Tab.AdminPermMembers.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Tab');
6
7 Pman.Tab.AdminPermMembers = new Roo.XComponent({
8   part     :  ["old", "AdminPermMembers" ],
9   order    : '001-Pman.Tab.AdminPermMembers',
10   region   : 'center',
11   parent   : 'Pman.Tab.AdminPermManager',
12   name     : "Pman.Tab.AdminPermMembers",
13   disabled : false, 
14   permname : '', 
15   _tree : function()
16   {
17    var _this = this;
18    var MODULE = this;
19    return {
20    grid : {
21     dataSource : {
22      proxy : {
23       '|xns' : 'Roo.data',
24       url : baseURL + '/Roo/core_person',
25       xtype : 'HttpProxy',
26       method : 'GET',
27       xns : Roo.data
28      },
29      reader : {
30       '|xns' : 'Roo.data',
31       id : 'id',
32       root : 'data',
33       xtype : 'JsonReader',
34       xns : Roo.data,
35       fields : [
36           {
37               'name': 'id',
38               'type': 'int'
39           },
40           {
41               'name': 'office_id',
42               'type': 'int'
43           },
44           {
45               'name': 'name',
46               'type': 'string'
47           },
48           {
49               'name': 'phone',
50               'type': 'string'
51           },
52           {
53               'name': 'fax',
54               'type': 'string'
55           },
56           {
57               'name': 'email',
58               'type': 'string'
59           },
60           {
61               'name': 'company_id',
62               'type': 'int'
63           },
64           {
65               'name': 'role',
66               'type': 'string'
67           },
68           {
69               'name': 'active',
70               'type': 'int'
71           },
72           {
73               'name': 'remarks',
74               'type': 'string'
75           },
76           {
77               'name': 'passwd',
78               'type': 'string'
79           },
80           {
81               'name': 'owner_id',
82               'type': 'int'
83           },
84           {
85               'name': 'lang',
86               'type': 'string'
87           },
88           {
89               'name': 'no_reset_sent',
90               'type': 'int'
91           },
92           {
93               'name': 'action_type',
94               'type': 'string'
95           },
96           {
97               'name': 'project_id',
98               'type': 'int'
99           },
100           {
101               'name': 'office_id_id',
102               'type': 'int'
103           },
104           {
105               'name': 'office_id_company_id',
106               'type': 'int'
107           },
108           {
109               'name': 'office_id_name',
110               'type': 'string'
111           },
112           {
113               'name': 'office_id_address',
114               'type': 'string'
115           },
116           {
117               'name': 'office_id_phone',
118               'type': 'string'
119           },
120           {
121               'name': 'office_id_fax',
122               'type': 'string'
123           },
124           {
125               'name': 'office_id_email',
126               'type': 'string'
127           },
128           {
129               'name': 'office_id_role',
130               'type': 'string'
131           },
132           {
133               'name': 'company_id_code',
134               'type': 'string'
135           },
136           {
137               'name': 'company_id_name',
138               'type': 'string'
139           },
140           {
141               'name': 'company_id_remarks',
142               'type': 'string'
143           },
144           {
145               'name': 'company_id_owner_id',
146               'type': 'int'
147           },
148           {
149               'name': 'company_id_address',
150               'type': 'string'
151           },
152           {
153               'name': 'company_id_tel',
154               'type': 'string'
155           },
156           {
157               'name': 'company_id_fax',
158               'type': 'string'
159           },
160           {
161               'name': 'company_id_email',
162               'type': 'string'
163           },
164           {
165               'name': 'company_id_id',
166               'type': 'int'
167           },
168           {
169               'name': 'company_id_isOwner',
170               'type': 'int'
171           },
172           {
173               'name': 'company_id_logo_id',
174               'type': 'int'
175           },
176           {
177               'name': 'company_id_background_color',
178               'type': 'string'
179           },
180           {
181               'name': 'company_id_comptype',
182               'type': 'string'
183           },
184           {
185               'name': 'company_id_url',
186               'type': 'string'
187           },
188           {
189               'name': 'company_id_main_office_id',
190               'type': 'int'
191           },
192           {
193               'name': 'company_id_created_by',
194               'type': 'int'
195           },
196           {
197               'name': 'company_id_created_dt',
198               'type': 'date'
199           },
200           {
201               'name': 'company_id_updated_by',
202               'type': 'int'
203           },
204           {
205               'name': 'company_id_updated_dt',
206               'type': 'date'
207           },
208           {
209               'name': 'company_id_passwd',
210               'type': 'string'
211           },
212           {
213               'name': 'project_id_id',
214               'type': 'int'
215           },
216           {
217               'name': 'project_id_name',
218               'type': 'string'
219           },
220           {
221               'name': 'project_id_remarks',
222               'type': 'string'
223           },
224           {
225               'name': 'project_id_owner_id',
226               'type': 'int'
227           },
228           {
229               'name': 'project_id_code',
230               'type': 'string'
231           },
232           {
233               'name': 'project_id_active',
234               'type': 'int'
235           },
236           {
237               'name': 'project_id_type',
238               'type': 'string'
239           },
240           {
241               'name': 'project_id_client_id',
242               'type': 'int'
243           },
244           {
245               'name': 'project_id_team_id',
246               'type': 'int'
247           },
248           {
249               'name': 'project_id_file_location',
250               'type': 'string'
251           },
252           {
253               'name': 'project_id_open_date',
254               'type': 'date'
255           },
256           {
257               'name': 'project_id_open_by',
258               'type': 'int'
259           },
260           {
261               'name': 'project_id_close_date',
262               'type': 'date'
263           },
264           {
265               'name': 'project_id_countries',
266               'type': 'string'
267           },
268           {
269               'name': 'project_id_languages',
270               'type': 'string'
271           },
272           {
273               'name': 'project_id_agency_id',
274               'type': 'int'
275           },
276           {
277               'name': 'owner_id_id',
278               'type': 'int'
279           },
280           {
281               'name': 'owner_id_office_id',
282               'type': 'int'
283           },
284           {
285               'name': 'owner_id_name',
286               'type': 'string'
287           },
288           {
289               'name': 'owner_id_phone',
290               'type': 'string'
291           },
292           {
293               'name': 'owner_id_fax',
294               'type': 'string'
295           },
296           {
297               'name': 'owner_id_email',
298               'type': 'string'
299           },
300           {
301               'name': 'owner_id_company_id',
302               'type': 'int'
303           },
304           {
305               'name': 'owner_id_role',
306               'type': 'string'
307           },
308           {
309               'name': 'owner_id_active',
310               'type': 'int'
311           },
312           {
313               'name': 'owner_id_remarks',
314               'type': 'string'
315           },
316           {
317               'name': 'owner_id_passwd',
318               'type': 'string'
319           },
320           {
321               'name': 'owner_id_owner_id',
322               'type': 'int'
323           },
324           {
325               'name': 'owner_id_lang',
326               'type': 'string'
327           },
328           {
329               'name': 'owner_id_no_reset_sent',
330               'type': 'int'
331           },
332           {
333               'name': 'owner_id_action_type',
334               'type': 'string'
335           },
336           {
337               'name': 'owner_id_project_id',
338               'type': 'int'
339           }
340       ],
341       totalProperty : 'total'
342      },
343      '|xns' : 'Roo.data',
344      xtype : 'Store',
345      remoteSort : true,
346      sortInfo : { field : 'name', direction: 'ASC' },
347      xns : Roo.data,
348      listeners : {
349       update : function (_self, record, operation)
350        {
351            if (operation != 'commit') {
352                return;
353            }
354            // only used to change active status.
355            
356            new Pman.Request({
357                url : baseURL + '/Roo/core_person',
358                method :'POST',
359                params : {
360                    id : record.data.id,
361                    active: record.data.active
362                    
363                },
364                success : function() {
365                    // do nothing
366                    
367                    _this.grid.ds.remove(record);
368                    
369                },
370                failure : function() 
371                {
372                    Roo.MessageBox.alert("Error", "saving failed", function() {
373                        _this.grid.footer.onClick('first');
374                    });
375                }
376            });
377        },
378       beforeload : function (_self, o)
379        {
380          
381           // technically we may allow non-owner's to be in the group..
382           // need to work out how that will work...
383           // 
384           
385            //o.params['company_id_comptype'] = 'OWNER';
386            o.params['query[search]'] = _this.searchBox.getValue();
387            
388            if (!_this.activeButton) {return; false;}
389            
390            
391            o.params.active = _this.activeButton.pressed ? 0 : 1;
392            if (!Pman.Tab.AdminPermManager) { 
393                return false;
394            }
395            
396            
397            if (Pman.Tab.AdminPermManager && Pman.Tab.AdminPermManager.grid) {
398                var tms = Pman.Tab.AdminPermManager.grid.getSelectionModel().getSelected();
399                
400                if (!tms) {
401                    return false;
402                }
403                o.params['query[in_group]'] = tms.data.id;
404                o.params['query[type]'] = 0; // group type..
405                
406            }
407            //o.params['query[name]'] = _this.searchBox.getValue();
408          
409            
410        }
411      },
412      items : [
413
414      ]
415
416     },
417     footer : {
418      '|xns' : 'Roo',
419      pageSize : 25,
420      xtype : 'PagingToolbar',
421      emptyMsg : "No Person found",
422      xns : Roo,
423      displayInfo : true,
424      displayMsg : "Displaying Person{0} - {1} of {2}",
425      items : [
426       {
427        '|xns' : 'Roo.Toolbar',
428        text : "Drag person to add or remove from group",
429        xtype : 'TextItem',
430        xns : Roo.Toolbar
431       }
432      ]
433
434     },
435     toolbar : {
436      '|xns' : 'Roo',
437      xtype : 'Toolbar',
438      xns : Roo,
439      items : [
440       {
441        '|xns' : 'Roo.Toolbar',
442        text : "Add",
443        xtype : 'Button',
444        cls : 'x-btn-text-icon',
445        icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
446        xns : Roo.Toolbar,
447        listeners : {
448         click : function()
449          {
450              
451              _this.dialog.show( { id : 0 } , function() {
452                  _this.grid.footer.onClick('first');
453             }); 
454          }
455        }
456       },
457       {
458        '|xns' : 'Roo.Toolbar',
459        text : "Bulk Add",
460        xtype : 'Button',
461        cls : 'x-btn-text-icon',
462        icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
463        xns : Roo.Toolbar,
464        listeners : {
465         click : function()
466          {
467              
468              Pman.Dialog.PersonBulkAdd.show( { id : 0 } , function() {
469                  _this.grid.footer.onClick('first');
470             }); 
471          }
472        }
473       },
474       {
475        '|xns' : 'Roo.Toolbar',
476        text : "Edit",
477        xtype : 'Button',
478        cls : 'x-btn-text-icon',
479        icon : Roo.rootURL + 'images/default/tree/leaf.gif',
480        xns : Roo.Toolbar,
481        listeners : {
482         click : function()
483          {
484              var s = _this.grid.getSelectionModel().getSelections();
485              if (!s.length || (s.length > 1))  {
486                  Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
487                  return;
488              }
489            
490              _this.dialog.show(s[0].data, function() {
491                  _this.grid.footer.onClick('first');
492              }); 
493              
494          }
495        }
496       },
497       {
498        '|xns' : 'Roo.Toolbar',
499        xtype : 'Separator',
500        xns : Roo.Toolbar
501       },
502       {
503        '|xns' : 'Roo.Toolbar',
504        text : "Search",
505        xtype : 'TextItem',
506        xns : Roo.Toolbar
507       },
508       {
509        '|xns' : 'Roo.form',
510        xtype : 'TextField',
511        xns : Roo.form,
512        listeners : {
513         specialkey : function (_self, e)
514          {
515            if (e.getKey() == 13) {
516              _this.grid.footer.onClick('first');
517            }
518          },
519         show : function (_self,e)
520          {
521              if (e.getCharCode() != 13) {
522                  return;
523              }
524              _this.grid.footer.onClick('first');
525          },
526         render : function (_self)
527          {
528              _this.searchBox = _self;
529          }
530        }
531       },
532       {
533        '|xns' : 'Roo.Toolbar',
534        xtype : 'Button',
535        cls : 'x-btn-icon',
536        icon : rootURL + '/Pman/templates/images/search.gif',
537        xns : Roo.Toolbar,
538        listeners : {
539         click : function (_self, e)
540          {
541          _this.grid.footer.onClick('first');
542          }
543        }
544       },
545       {
546        '|xns' : 'Roo.Toolbar',
547        xtype : 'Button',
548        cls : 'x-btn-icon',
549        icon : rootURL + '/Pman/templates/images/edit-clear.gif',
550        xns : Roo.Toolbar,
551        listeners : {
552         click : function (_self, e)
553          {
554          _this.searchBox.setValue('');
555              _this.grid.footer.onClick('first');
556          }
557        }
558       },
559       {
560        '|xns' : 'Roo.Toolbar',
561        xtype : 'Fill',
562        xns : Roo.Toolbar
563       },
564       {
565        '|xns' : 'Roo.Toolbar',
566        text : "Show Removed",
567        enableToggle : true,
568        xtype : 'Button',
569        xns : Roo.Toolbar,
570        listeners : {
571         toggle : function (_self, pressed)
572          {
573             _this.grid.footer.onClick('first');
574             this.setText(pressed ? "Show Active" : "Show Removed");
575             
576             
577          },
578         render : function (_self)
579          {
580            _this.activeButton = _self;
581          }
582        }
583       }
584      ]
585
586     },
587     '|xns' : 'Roo.grid',
588     autoExpandColumn : 'name',
589     xtype : 'Grid',
590     ddGroup : 'groupDD',
591     enableDrag : true,
592     loadMask : true,
593     xns : Roo.grid,
594     colModel : [
595       {
596        '|xns' : 'Roo.grid',
597        hidden : true,
598        xtype : 'ColumnModel',
599        sortable : true,
600        header : 'Project',
601        width : 75,
602        renderer : function(v,x,r) { 
603              return String.format('<span qtip="{0}">{1}</span>', 
604                            r.data.project_id_name,
605                            v);
606         },
607        xns : Roo.grid,
608        dataIndex : 'project_id_code'
609       },
610 {
611        '|xns' : 'Roo.grid',
612        xtype : 'ColumnModel',
613        sortable : true,
614        header : 'Type',
615        width : 50,
616        renderer : function(v,x,r) {
617            if (r.data.office_id) {
618                return String.format('{0} - {1}', v, r.data.office_id_name); 
619            } 
620            return String.format('{0}', v); 
621        },
622        xns : Roo.grid,
623        dataIndex : 'company_id_comptype'
624       },
625 {
626        '|xns' : 'Roo.grid',
627        xtype : 'ColumnModel',
628        sortable : true,
629        header : 'Company',
630        width : 150,
631        renderer : function(v,x,r) {
632            if (r.data.office_id) {
633                return String.format('{0} - {1}', v, r.data.office_id_name); 
634            } 
635            return String.format('{0}', v); 
636        },
637        xns : Roo.grid,
638        dataIndex : 'company_id_name'
639       },
640 {
641        '|xns' : 'Roo.grid',
642        xtype : 'ColumnModel',
643        sortable : true,
644        header : 'Name',
645        width : 200,
646        renderer : function(v,p,r) { 
647            if(r.data.active != 1){
648                return String.format('<div style="text-decoration:line-through">{0}</div>', v); 
649            }
650            return String.format('{0}', v); 
651        },
652        xns : Roo.grid,
653        dataIndex : 'name'
654       },
655 {
656        '|xns' : 'Roo.grid',
657        xtype : 'ColumnModel',
658        width : 100,
659        header : 'Role',
660        renderer : function(v) { return String.format('{0}', v); },
661        xns : Roo.grid,
662        dataIndex : 'role'
663       },
664 {
665        '|xns' : 'Roo.grid',
666        xtype : 'ColumnModel',
667        width : 100,
668        header : 'Phone',
669        renderer : function(v) { return String.format('{0}', v); },
670        xns : Roo.grid,
671        dataIndex : 'phone'
672       },
673 {
674        '|xns' : 'Roo.grid',
675        xtype : 'ColumnModel',
676        width : 100,
677        header : 'Fax',
678        renderer : function(v) { return String.format('{0}', v); },
679        xns : Roo.grid,
680        dataIndex : 'fax'
681       },
682 {
683        '|xns' : 'Roo.grid',
684        xtype : 'ColumnModel',
685        sortable : true,
686        header : 'Email',
687        width : 200,
688        renderer : function(v) {
689           return (v.length && v.indexOf('@') > 0 ) ? 
690                            String.format('<a href="mailto:{0}">{0}</a>',v) : v;
691         },
692        xns : Roo.grid,
693        dataIndex : 'email'
694       },
695 {
696        '|xns' : 'Roo.grid',
697        xtype : 'ColumnModel',
698        width : 75,
699        header : 'Active',
700        renderer : function(v) {  
701            var state = v> 0 ?  '-checked' : '';
702        
703            return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
704                        
705         },
706        xns : Roo.grid,
707        dataIndex : 'active'
708       }
709     ],
710     listeners : {
711      rowdblclick : function (_self, rowIndex, e)
712       {
713           if (!_this.dialog) return;
714           _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
715               _this.grid.footer.onClick('first');
716           }); 
717       },
718      render : function() 
719       {
720           _this.grid = this; 
721           if (!_this.dialog) {
722               _this.dialog = Pman.Dialog.PersonEdit;
723               
724           }
725           //_this.dialog = Pman.Dialog.FILL_IN
726           if (_this.panel.active) {
727              this.footer.onClick('first');
728           }
729       },
730      cellclick : function (_self, rowIndex, columnIndex, e)
731       {
732       
733               var di = this.colModel.getDataIndex(columnIndex);
734               if (di != 'active') {
735                   return;
736               }
737                
738               var rec = _this.grid.ds.getAt(rowIndex);
739               
740               rec.set('active', rec.data.active ? 0 : 1);
741               rec.commit();
742               Roo.select('.x-grid-row-selected').item(1).addClass('fadeout');
743               (function(){
744                   _this.grid.footer.onClick('first');
745               }).defer(5000)();
746               
747       }
748     },
749     items : [
750
751     ]
752
753    },
754    '|xns' : 'Roo',
755    autoScroll : true,
756    fitToframe : true,
757    background : true,
758    region : 'center',
759    title : "Person",
760    xtype : 'GridPanel',
761    fitContainer : true,
762    xns : Roo,
763    tableName : 'Person',
764    listeners : {
765     activate : function() {
766          _this.panel = this;
767          if (_this.grid) {
768              _this.grid.footer.onClick('first');
769          }
770      }
771    },
772    items : [
773
774    ]
775
776   };  }
777 });