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