sync
[Pman.Admin] / Pman.Tab.AdminContacts.bjs
1 {
2  "items" : [
3   {
4    "$ xns" : "Roo",
5    "autoScroll" : true,
6    "bool background" : false,
7    "fitContainer" : true,
8    "fitToframe" : true,
9    "items" : [
10     {
11      "$ xns" : "Roo.grid",
12      "* prop" : "grid",
13      "autoExpandColumn" : "name",
14      "ddGroup" : "groupDD",
15      "enableDrag" : true,
16      "items" : [
17       {
18        "$ sortInfo" : "{ field : 'name', direction: 'ASC' }",
19        "$ xns" : "Roo.data",
20        "* prop" : "dataSource",
21        "items" : [
22         {
23          "$ url" : "baseURL + '/Roo/core_person'",
24          "$ xns" : "Roo.data",
25          "* prop" : "proxy",
26          "method" : "GET",
27          "xtype" : "HttpProxy"
28         },
29         {
30          "$ xns" : "Roo.data",
31          "* prop" : "reader",
32          "id" : "id",
33          "root" : "data",
34          "totalProperty" : "total",
35          "xtype" : "JsonReader"
36         }
37        ],
38        "listeners" : {
39         "beforeload" : [
40          "function (_self, o)",
41          "{",
42          "    if(!_this.active_company_button.pressed){",
43          "        o.params['!company_id_comptype'] = 'OWNER';",
44          "    }",
45          "    ",
46          "    o.params['query[search]'] = _this.searchBox.getValue();",
47          "    ",
48          "    if (!_this.activeButton) {return; false;}",
49          "    ",
50          "    if (_this.companyCombo &&   _this.companyCombo.getValue()) {",
51          "        o.params.company_id =   _this.companyCombo.getValue();",
52          "    }",
53          "    ",
54          "    ",
55          "    o.params.active = _this.activeButton.pressed ? 0 : 1;",
56          "    ",
57          "    if(_this.active_company_button.pressed){",
58          "        o.params.company_id = 0;",
59          "    }",
60          "    ",
61          "    var c = Pman.Tab.AdminContactsManager.layout.getRegion('west').getActivePanel();",
62          "    ",
63          "    if (!c) { ",
64          "        return false;",
65          "    }",
66          "    ",
67          "    var tms = c.grid.getSelectionModel().getSelected();",
68          "    ",
69          "    if (!tms) {",
70          "        return false;",
71          "    }",
72          "    ",
73          "    if(c.tableName == 'Groups'){",
74          "        o.params['query[in_group]'] = tms.data.id;",
75          "        o.params['query[type]'] = 2; // group type..",
76          "    }else{",
77          "        o.params['query[in_country]'] = (tms.data.country*1 == -1) ? '' : tms.data.country;",
78          "        o.params['query[in_group]'] = 0;",
79          "        o.params['query[type]'] = 2;",
80          "    }",
81          "    /*",
82          "    if (Pman.Tab.AdminContactsGroup && Pman.Tab.AdminContactsGroup.grid) {",
83          "        ",
84          "        ",
85          "        ",
86          "    }",
87          "    ",
88          "    if(Pman.Tab.AdminCountries && Pman.Tab.AdminCountries.grid){",
89          "        var tms = Pman.Tab.AdminCountries.grid.getSelectionModel().getSelected();",
90          "        ",
91          "        if (!tms) {",
92          "            return false;",
93          "        }",
94          "        ",
95          "    }",
96          "    */",
97          "    //o.params['query[name]'] = _this.searchBox.getValue();",
98          "  ",
99          "}"
100         ],
101         "update" : [
102          "function (_self, record, operation)",
103          "{",
104          "    if (operation != 'commit') {",
105          "        return;",
106          "    }",
107          "    // only used to change active status.",
108          "    ",
109          "    new Pman.Request({",
110          "        url : baseURL + '/Roo/Person.php',",
111          "        method :'POST',",
112          "        params : {",
113          "            id : record.data.id,",
114          "            active: record.data.active",
115          "            ",
116          "        },",
117          "        success : function() {",
118          "            // do nothing",
119          "            ",
120          "            _this.grid.ds.remove(record);",
121          "            ",
122          "        },",
123          "        failure : function() ",
124          "        {",
125          "            Roo.MessageBox.alert(\"Error\", \"saving failed\", function() {",
126          "                _this.grid.footer.onClick('first');",
127          "            });",
128          "        }",
129          "    });",
130          "}"
131         ]
132        },
133        "remoteSort" : true,
134        "xtype" : "Store"
135       },
136       {
137        "$ xns" : "Roo",
138        "* prop" : "footer",
139        "displayInfo" : true,
140        "displayMsg" : "Displaying Person{0} - {1} of {2}",
141        "emptyMsg" : "No Person found",
142        "items" : [
143         {
144          "$ xns" : "Roo.Toolbar",
145          "text" : "Drag person to add or remove from group",
146          "xtype" : "TextItem"
147         }
148        ],
149        "pageSize" : 25,
150        "xtype" : "PagingToolbar"
151       },
152       {
153        "$ xns" : "Roo",
154        "* prop" : "toolbar",
155        "items" : [
156         {
157          "$ xns" : "Roo.Toolbar",
158          "text" : "Search",
159          "xtype" : "TextItem"
160         },
161         {
162          "$ xns" : "Roo.form",
163          "listeners" : {
164           "render" : [
165            "function (_self)",
166            "{",
167            "    _this.searchBox = _self;",
168            "}"
169           ],
170           "show" : [
171            "function (_self,e)",
172            "{",
173            "    if (e.getCharCode() != 13) {",
174            "        return;",
175            "    }",
176            "    _this.grid.footer.onClick('first');",
177            "}"
178           ],
179           "specialkey" : [
180            "function (_self, e)",
181            "{",
182            "  if (e.getKey() == 13) {",
183            "    _this.grid.footer.onClick('first');",
184            "  }",
185            "}"
186           ]
187          },
188          "xtype" : "TextField"
189         },
190         {
191          "$ xns" : "Roo.form",
192          "displayField" : "name",
193          "editable" : true,
194          "emptyText" : "Select Company",
195          "forceSelection" : true,
196          "hiddenName" : "company_id",
197          "items" : [
198           {
199            "$ sortInfo" : "{ direction : 'ASC', field: 'name' }",
200            "$ xns" : "Roo.data",
201            "* prop" : "store",
202            "items" : [
203             {
204              "$ url" : "baseURL + '/Roo/core_company'",
205              "$ xns" : "Roo.data",
206              "* prop" : "proxy",
207              "method" : "GET",
208              "xtype" : "HttpProxy"
209             },
210             {
211              "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"code\",\"type\":\"string\"}]",
212              "$ xns" : "Roo.data",
213              "* prop" : "reader",
214              "id" : "id",
215              "root" : "data",
216              "totalProperty" : "total",
217              "xtype" : "JsonReader"
218             }
219            ],
220            "listeners" : {
221             "|beforeload" : [
222              "function (_self, o){",
223              "    o.params = o.params || {};",
224              "    // set more here",
225              "}",
226              ""
227             ]
228            },
229            "remoteSort" : true,
230            "xtype" : "Store"
231           }
232          ],
233          "listWidth" : 400,
234          "listeners" : {
235           "render" : [
236            "function (_self)",
237            "{",
238            "  _this.companyCombo = _self;",
239            "}"
240           ],
241           "select" : [
242            "function (combo, record, index)",
243            "{",
244            "   _this.grid.footer.onClick.defer(300,_this.grid.footer,[ 'first'] );",
245            "}"
246           ]
247          },
248          "loadingText" : "Searching...",
249          "minChars" : 2,
250          "name" : "company_name",
251          "pageSize" : 20,
252          "qtip" : "Select Companies",
253          "queryParam" : "query[name]",
254          "selectOnFocus" : true,
255          "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> </div>",
256          "triggerAction" : "all",
257          "typeAhead" : true,
258          "valueField" : "id",
259          "width" : 150,
260          "xtype" : "ComboBox"
261         },
262         {
263          "$ icon" : "rootURL + '/Pman/templates/images/search.gif'",
264          "$ xns" : "Roo.Toolbar",
265          "cls" : "x-btn-icon",
266          "listeners" : {
267           "|click" : [
268            "function (_self, e)",
269            "{",
270            "_this.grid.footer.onClick('first');",
271            "}"
272           ]
273          },
274          "xtype" : "Button"
275         },
276         {
277          "$ icon" : "rootURL + '/Pman/templates/images/edit-clear.gif'",
278          "$ xns" : "Roo.Toolbar",
279          "cls" : "x-btn-icon",
280          "listeners" : {
281           "|click" : [
282            "function (_self, e)",
283            "{",
284            "_this.searchBox.setValue('');",
285            "    _this.grid.footer.onClick('first');",
286            "}"
287           ]
288          },
289          "xtype" : "Button"
290         },
291         {
292          "$ xns" : "Roo.Toolbar",
293          "enableToggle" : true,
294          "listeners" : {
295           "render" : [
296            "function (_self)",
297            "{",
298            "  _this.activeButton = _self;",
299            "}"
300           ],
301           "toggle" : [
302            "function (_self, pressed)",
303            "{",
304            "   _this.grid.footer.onClick('first');",
305            "   this.setText(pressed ? \"Show Active\" : \"Show Removed\");",
306            "   ",
307            "   ",
308            "}"
309           ]
310          },
311          "text" : "Show Removed",
312          "xtype" : "Button"
313         },
314         {
315          "$ xns" : "Roo.Toolbar",
316          "enableToggle" : true,
317          "listeners" : {
318           "render" : [
319            "function (_self)",
320            "{",
321            "  _this.active_company_button = _self;",
322            "}"
323           ],
324           "toggle" : [
325            "function (_self, pressed)",
326            "{",
327            "   _this.grid.footer.onClick('first');",
328            "   this.setText(pressed ? \"Show Company\" : \"Show No Company\");",
329            "   ",
330            "   ",
331            "}"
332           ]
333          },
334          "text" : "Show No Company",
335          "xtype" : "Button"
336         },
337         {
338          "$ xns" : "Roo.Toolbar",
339          "listeners" : {
340           "click" : [
341            "function (_self, e)",
342            "{",
343            "    var s = _this.grid.getSelectionModel().getSelections();",
344            "    if(s.length != 1){",
345            "        Roo.MessageBox.alert(\"Error\", \"Select a Person\");",
346            "        return;",
347            "    }",
348            "    ",
349            "    new Pman.Request({",
350            "        url : baseURL + '/Login.php',",
351            "        method : 'GET',",
352            "        params : {",
353            "            'switch' : s[0].data.id",
354            "        },",
355            "        success : function (){",
356            "            document.location = baseURL + '?ts=' + Math.random();",
357            "        },",
358            "        failure : function (d){",
359            "            Roo.log(d);",
360            "            Roo.MessageBox.alert(\"Error\", d);",
361            "        }",
362            "    });",
363            "}"
364           ]
365          },
366          "text" : "Switch to Selected User",
367          "xtype" : "Button"
368         },
369         {
370          "$ xns" : "Roo.Toolbar",
371          "xtype" : "Fill"
372         },
373         {
374          "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
375          "$ xns" : "Roo.Toolbar",
376          "cls" : "x-btn-text-icon",
377          "listeners" : {
378           "|click" : [
379            "function()",
380            "{",
381            "    ",
382            "    _this.dialog.show( { id : 0 } , function() {",
383            "        _this.grid.footer.onClick('first');",
384            "   }); ",
385            "}",
386            ""
387           ]
388          },
389          "text" : "Add",
390          "xtype" : "Button"
391         },
392         {
393          "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
394          "$ xns" : "Roo.Toolbar",
395          "cls" : "x-btn-text-icon",
396          "listeners" : {
397           "|click" : [
398            "function()",
399            "{",
400            "    ",
401            "    Pman.Dialog.PersonBulkAdd.show( { id : 0 } , function() {",
402            "        _this.grid.footer.onClick('first');",
403            "   }); ",
404            "}",
405            ""
406           ]
407          },
408          "text" : "Bulk Add",
409          "xtype" : "Button"
410         },
411         {
412          "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'",
413          "$ xns" : "Roo.Toolbar",
414          "cls" : "x-btn-text-icon",
415          "listeners" : {
416           "|click" : [
417            "function()",
418            "{",
419            "    var s = _this.grid.getSelectionModel().getSelections();",
420            "    if (!s.length || (s.length > 1))  {",
421            "        Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");",
422            "        return;",
423            "    }",
424            "  ",
425            "    _this.dialog.show(s[0].data, function() {",
426            "        _this.grid.footer.onClick('first');",
427            "    }); ",
428            "    ",
429            "}",
430            ""
431           ]
432          },
433          "text" : "Edit",
434          "xtype" : "Button"
435         },
436         {
437          "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
438          "$ xns" : "Roo.Toolbar",
439          "cls" : "x-btn-text-icon",
440          "listeners" : {
441           "|click" : [
442            "function()",
443            "{",
444            "     Pman.genericDelete(_this, 'Person'); ",
445            "}",
446            "        "
447           ]
448          },
449          "text" : "Delete",
450          "xtype" : "Button"
451         }
452        ],
453        "xtype" : "Toolbar"
454       },
455       {
456        "$ renderer" : [
457         "function(v,x,r) { ",
458         "      return String.format('<span qtip=\"{0}\">{1}</span>', ",
459         "                    r.data.project_id_name,",
460         "                    v);",
461         " }"
462        ],
463        "$ xns" : "Roo.grid",
464        "* prop" : "colModel[]",
465        "dataIndex" : "project_id_code",
466        "header" : "Project",
467        "hidden" : true,
468        "sortable" : true,
469        "width" : 75,
470        "xtype" : "ColumnModel"
471       },
472       {
473        "$ renderer" : [
474         "function(v,x,r) {",
475         "    if (r.data.office_id) {",
476         "        return String.format('{0} - {1}', v, r.data.office_id_name); ",
477         "    } ",
478         "    return String.format('{0}', v); ",
479         "}"
480        ],
481        "$ xns" : "Roo.grid",
482        "* prop" : "colModel[]",
483        "dataIndex" : "company_id_comptype",
484        "header" : "Type",
485        "sortable" : true,
486        "width" : 50,
487        "xtype" : "ColumnModel"
488       },
489       {
490        "$ renderer" : [
491         "function(v,x,r) {",
492         "    if (r.data.office_id) {",
493         "        return String.format('{0} - {1}', v, r.data.office_id_name); ",
494         "    } ",
495         "    return String.format('{0}', v); ",
496         "}"
497        ],
498        "$ xns" : "Roo.grid",
499        "* prop" : "colModel[]",
500        "dataIndex" : "company_id_name",
501        "header" : "Company",
502        "sortable" : true,
503        "width" : 150,
504        "xtype" : "ColumnModel"
505       },
506       {
507        "$ renderer" : "function(v) { return String.format('{0}', v); }",
508        "$ xns" : "Roo.grid",
509        "* prop" : "colModel[]",
510        "dataIndex" : "name",
511        "header" : "Name",
512        "sortable" : true,
513        "width" : 200,
514        "xtype" : "ColumnModel"
515       },
516       {
517        "$ renderer" : "function(v) { return String.format('{0}', v); }",
518        "$ xns" : "Roo.grid",
519        "* prop" : "colModel[]",
520        "dataIndex" : "role",
521        "header" : "Role",
522        "width" : 100,
523        "xtype" : "ColumnModel"
524       },
525       {
526        "$ renderer" : "function(v) { return String.format('{0}', v); }",
527        "$ xns" : "Roo.grid",
528        "* prop" : "colModel[]",
529        "dataIndex" : "phone",
530        "header" : "Phone",
531        "width" : 100,
532        "xtype" : "ColumnModel"
533       },
534       {
535        "$ renderer" : "function(v) { return String.format('{0}', v); }",
536        "$ xns" : "Roo.grid",
537        "* prop" : "colModel[]",
538        "Boolean hidden" : true,
539        "dataIndex" : "fax",
540        "header" : "Fax",
541        "width" : 100,
542        "xtype" : "ColumnModel"
543       },
544       {
545        "$ renderer" : [
546         "function(v) {",
547         "   return (v.length && v.indexOf('@') > 0 ) ? ",
548         "                    String.format('<a href=\"mailto:{0}\">{0}</a>',v) : v;",
549         " }"
550        ],
551        "$ xns" : "Roo.grid",
552        "* prop" : "colModel[]",
553        "dataIndex" : "email",
554        "header" : "Email",
555        "sortable" : true,
556        "width" : 200,
557        "xtype" : "ColumnModel"
558       },
559       {
560        "$ renderer" : [
561         "function(v) {  ",
562         "    var state = v> 0 ?  '-checked' : '';",
563         "",
564         "    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';",
565         "                ",
566         " }"
567        ],
568        "$ xns" : "Roo.grid",
569        "* prop" : "colModel[]",
570        "dataIndex" : "active",
571        "header" : "Active",
572        "width" : 75,
573        "xtype" : "ColumnModel"
574       }
575      ],
576      "listeners" : {
577       "cellclick" : [
578        "function (_self, rowIndex, columnIndex, e)",
579        "{",
580        "",
581        "        var di = this.colModel.getDataIndex(columnIndex);",
582        "        if (di != 'active') {",
583        "            return;",
584        "        }",
585        "         ",
586        "        var rec = _this.grid.ds.getAt(rowIndex);",
587        "        ",
588        "        rec.set('active', rec.data.active ? 0 : 1);",
589        "        rec.commit();",
590        "         ",
591        "        ",
592        "}"
593       ],
594       "|render" : [
595        "function() ",
596        "{",
597        "    _this.grid = this; ",
598        "    if (!_this.dialog) {",
599        "        _this.dialog = Pman.Dialog.PersonEdit;",
600        "        ",
601        "    }",
602        "    //_this.dialog = Pman.Dialog.FILL_IN",
603        "    if (_this.panel.active) {",
604        "       this.footer.onClick('first');",
605        "    }",
606        "}"
607       ],
608       "|rowdblclick" : [
609        "function (_self, rowIndex, e)",
610        "{",
611        "    if (!_this.dialog) {",
612        "        return;",
613        "    }",
614        "    _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {",
615        "        _this.grid.footer.onClick('first');",
616        "    }); ",
617        "}",
618        ""
619       ]
620      },
621      "loadMask" : true,
622      "xtype" : "Grid"
623     }
624    ],
625    "listeners" : {
626     "|activate" : [
627      "function() {",
628      "    _this.panel = this;",
629      "    if (_this.grid) {",
630      "        _this.grid.footer.onClick('first');",
631      "    }",
632      "}"
633     ]
634    },
635    "region" : "center",
636    "tableName" : "Person",
637    "title" : "Person",
638    "xtype" : "GridPanel"
639   }
640  ],
641  "modOrder" : "001",
642  "name" : "Pman.Tab.AdminContacts",
643  "named_strings" : {
644   "company_name_emptyText" : "99b344c8ae43e3e7213862b8f35c4e51",
645   "company_name_loadingText" : "1243daf593fa297e07ab03bf06d925af",
646   "company_name_qtip" : "9675747b5ab12d05f18518761e68a533"
647  },
648  "parent" : "Pman.Tab.AdminContactsManager",
649  "path" : "/home/alan/gitlive/Pman.Admin/Pman.Tab.AdminContacts.bjs",
650  "permname" : "Core.Person",
651  "strings" : {
652   "1243daf593fa297e07ab03bf06d925af" : "Searching...",
653   "13348442cc6a27032d2b4aa28b75a5d3" : "Search",
654   "1c76cbfe21c6f44c1d1e59d54f3e4420" : "Company",
655   "40bed7cf9b3d4bb3a3d7a7e3eb18c5eb" : "Person",
656   "4110db87ce3ac86d603d03d691616b1e" : "Drag person to add or remove from group",
657   "49ee3087348e8d44e1feda1917443987" : "Name",
658   "4d3d769b812b6faa6b76e1a8abaece2d" : "Active",
659   "7dce122004969d56ae2e0245cb754d35" : "Edit",
660   "8444e81d652b084d70c71cd7d19ac0cf" : "Displaying Person{0} - {1} of {2}",
661   "9675747b5ab12d05f18518761e68a533" : "Select Companies",
662   "9810aa2b9f44401be4bf73188ef2b67d" : "Fax",
663   "99b344c8ae43e3e7213862b8f35c4e51" : "Select Company",
664   "9e727fdd3aec8274f46685441900280d" : "Project",
665   "a1fa27779242b4902f7ae3bdd5c6d508" : "Type",
666   "a93806efd0cc7a149f0f03e2b9a0f862" : "Bulk Add",
667   "b47a519aebda8fdb4b59bdae6eb2bff0" : "Show No Company",
668   "bbbabdbe1b262f75d99d62880b953be1" : "Role",
669   "bcc254b55c4a1babdf1dcb82c207506b" : "Phone",
670   "ce8ae9da5b7cd6c3df2929543a9af92d" : "Email",
671   "d4d25ad0a12e8d30e9d8d35230f6d1d3" : "Show Removed",
672   "ec211f7c20af43e742bf2570c3cb84f9" : "Add",
673   "ec3249f16ee5880d4c1acb752e5c925f" : "Switch to Selected User",
674   "f1174ecbbc232f948717979daf04cf08" : "No Person found",
675   "f2a6c498fb90ee345d997f888fce3b18" : "Delete"
676  },
677  "title" : "Pman.Tab.AdminContacts"
678 }