remove trailing comma
[Pman.Admin] / Pman.Tab.AdminTranslations.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.AdminTranslations = new Roo.XComponent({
8
9  _strings : {
10   '0a52da7a03a6de3beefe54f8c03ad80d' :"Original",
11   '69fd71b6f79260924a32a45850a13ab7' :"Translations (rescan this to update strings)",
12   '9d1ead73e678fa2f51a70a933b0bf017' :"Not Found",
13   '801ab24683a4a8c433c6eb40c48bcd9d' :"Download",
14   '6dd08874f83507e9c7b23f1a46b7fa7c' :"Translation",
15   '07a1d316d1065473f290c3c2b72a80f3' :"Application Words",
16   'e3d388b2c43e5ba0905702620ae2abc1' :"Search for",
17   'e2f9d206562d8f5ea421ad51100f7151' :"Displaying petition_entry{0} - {1} of {2}",
18   'cd6ae20e52d83f601c5fa12b66f0f6d0' :"Rescan",
19   '91412465ea9169dfd901dd5e7c96dd99' :"Upload",
20   '4d1c8263ba1036754f8db14a98f9f006' :"Reload",
21   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
22   '03c2e7e41ffc181a4e84080b4710e81e' :"New",
23   '193cfc9be3b995831c6af2fea6650e60' :"Page",
24   '1bc29b36f623ba82aaf6724fd3b16718' :"md5"
25  },
26
27   part     :  ["Admin", "Translations" ],
28   order    : '950-Pman.Tab.AdminTranslations',
29   region   : 'center',
30   parent   : 'Pman.Tab.AdminTranslationsInt',
31   name     : "Admin - Translations",
32   disabled : false, 
33   permname : 'Admin.Translations', 
34   _tree : function(_data)
35   {
36    var _this = this;
37    var MODULE = this;
38    return {
39    xtype : 'NestedLayoutPanel',
40    region : 'center',
41    title : _this._strings['07a1d316d1065473f290c3c2b72a80f3'] /* Application Words */,
42    xns : Roo,
43    '|xns' : 'Roo',
44    layout : {
45     xtype : 'BorderLayout',
46     xns : Roo,
47     '|xns' : 'Roo',
48     center : {
49      xtype : 'LayoutRegion',
50      xns : Roo,
51      '|xns' : 'Roo'
52     },
53     west : {
54      xtype : 'LayoutRegion',
55      split : true,
56      width : 450,
57      xns : Roo,
58      '|xns' : 'Roo'
59     },
60     items  : [
61      {
62       xtype : 'TreePanel',
63       region : 'west',
64       listeners : {
65        render : function (_self)
66         {
67             _this.treepanel = _self;
68         }
69       },
70       xns : Roo,
71       '|xns' : 'Roo',
72       toolbar : {
73        xtype : 'Toolbar',
74        xns : Roo,
75        '|xns' : 'Roo',
76        items  : [
77         {
78          xtype : 'Button',
79          text : _this._strings['03c2e7e41ffc181a4e84080b4710e81e'] /* New */,
80          listeners : {
81           click : function (_self, e)
82            {
83                Pman.Dialog.AdminLanguagePick.show( {  }, function(lang) {
84                    
85                    new Pman.Request({
86                        url : baseURL + '/Roo/core_templatestr',
87                        method : 'POST',
88                        params : {
89                            _rescan : lang
90                        }, 
91                        success : function()
92                        {
93                            _this.treepanel.tree.getRootNode().reload();
94                        }
95                    });
96                
97                });
98                
99            }
100          },
101          xns : Roo.Toolbar,
102          '|xns' : 'Roo.Toolbar'
103         },
104         {
105          xtype : 'Separator',
106          xns : Roo.Toolbar,
107          '|xns' : 'Roo.Toolbar'
108         },
109         {
110          xtype : 'Button',
111          text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
112          listeners : {
113           click : function (_self, e)
114            {
115                var tree = _this.treepanel.tree;
116                var sn  = tree.getSelectionModel().getSelectedNode();
117            
118                if (!sn || typeof(sn.attributes.language) == 'undefined' || !sn.attributes.language) {
119                    Roo.MessageBox.alert("Error", "Select a language");
120                    return;
121                }
122            
123                 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete the language", function (v){
124                        if (v != 'yes') {
125                            return;
126                        }
127                        Roo.MessageBox.alert("Not yet", "not done yet");
128                        return;
129                        
130                        
131                        
132                        
133                    });
134            }
135          },
136          xns : Roo.Toolbar,
137          '|xns' : 'Roo.Toolbar'
138         },
139         {
140          xtype : 'Separator',
141          xns : Roo.Toolbar,
142          '|xns' : 'Roo.Toolbar'
143         },
144         {
145          xtype : 'Button',
146          text : _this._strings['cd6ae20e52d83f601c5fa12b66f0f6d0'] /* Rescan */,
147          listeners : {
148           click : function (_self, e)
149            {
150                var tree = _this.treepanel.tree;
151                Roo.log(tree);
152                var sn  = tree.getSelectionModel().getSelectedNode();
153            
154                if (!sn) {
155                    Roo.MessageBox.alert("Error", "Select a node");
156                    return;
157                }
158                
159                var syncTemplate = function(){
160                    new Pman.Request({
161                        url : baseURL + '/Admin/UpdateBjsTemplates',
162                        method : 'GET',
163                        mask : 'Processing...',
164                        timeout : 9000000,
165                        success : function()
166                        {
167                            _this.treepanel.tree.getRootNode().reload();
168                        }
169                    });
170                
171                };
172                
173                
174                var syncLanguage = function(){
175                    new Pman.Request({
176                        url : baseURL + '/Roo/Core_templatestr',
177                        method : 'POST',
178                        mask : 'Processing...',
179                        params : {
180                            _rescan : sn.attributes.id.split(':')[1]
181                        }, 
182                        success : function()
183                        {
184                            _this.treepanel.tree.getRootNode().reload();
185                        }
186                    });
187                };
188                
189                if(typeof(sn.isRoot) != 'undefined' && sn.isRoot){
190                    syncTemplate();
191                    return;
192                }
193                
194                if(typeof(sn.attributes.language) != 'undefined' && sn.attributes.language){
195                    syncLanguage();
196                    return;
197                }
198                
199                
200                
201                
202                
203            }
204          },
205          xns : Roo.Toolbar,
206          '|xns' : 'Roo.Toolbar'
207         },
208         {
209          xtype : 'Fill',
210          xns : Roo.Toolbar,
211          '|xns' : 'Roo.Toolbar'
212         },
213         {
214          xtype : 'Button',
215          text : _this._strings['91412465ea9169dfd901dd5e7c96dd99'] /* Upload */,
216          listeners : {
217           click : function (_self, e)
218            {
219                
220                
221                Pman.Dialog.Image.show({
222                   _url : baseURL + '/Admin/Import/Core_templatestr' 
223                   
224                
225                }, function() {
226                     _this.treepanel.tree.getRootNode().reload();
227                });
228                
229                
230                
231            }
232          },
233          xns : Roo.Toolbar,
234          '|xns' : 'Roo.Toolbar'
235         },
236         {
237          xtype : 'Fill',
238          xns : Roo.Toolbar,
239          '|xns' : 'Roo.Toolbar'
240         },
241         {
242          xtype : 'Button',
243          text : _this._strings['801ab24683a4a8c433c6eb40c48bcd9d'] /* Download */,
244          listeners : {
245           click : function (_self, e)
246            {
247                var tree = _this.treepanel.tree;
248            
249                var sn  = tree.getSelectionModel().getSelectedNode();
250                
251                p = {
252                    csvCols : 'src_id_mdsum,template_id_view_name,template_id_template,src_id_txt,lang,txt',
253                    csvTitles : 'Code,Module,Template,Original,Language,Translation',
254                    limit : 9999,
255                    sort: 'template_id_view_name,template_id_template,src_id_txt',
256                    dir: 'ASC'
257                };
258                if (!sn ||  sn.id == 'transtree') {
259                    Roo.MessageBox.alert("Error", "Select language, module or page");
260                    return;
261                }
262                if (typeof(sn.id) == 'number') {
263                    p.template_id = sn.id;
264            
265                }
266                
267                
268                if (sn.id.match(/^table:/)) {
269                    var sns = sn.id.split(':');
270                    p.lang = sns[1];
271                    p.on_table = sns[2];
272                    p.csvCols = 'src_id_mdsum,on_table,on_id,on_col,src_id_txt,lang,txt';
273                    p.csvTitles = 'Code,Table,Table id,Column,Language,Translation';
274                }
275                
276                if (sn.id.match(/^view:/)) {
277                    var sns = sn.id.split(':');
278                    p.lang = sns[1];
279                    p.template_id_view_name = sns[2];
280                    
281                }
282                if (sn.id.match(/^lang:/)) {
283                    var sns = sn.id.split(':');
284                    p.lang = sns[1];
285            
286               }
287                // transtree
288                // view: {lang} : {view_name}
289                // lang:
290                 
291                new Pman.Download({
292                    url : baseURL + '/Roo/Core_templatestr',
293                    params : p,
294                    method : 'GET' 
295                });
296                
297                
298                
299                
300                
301            }
302          },
303          xns : Roo.Toolbar,
304          '|xns' : 'Roo.Toolbar'
305         },
306         {
307          xtype : 'Separator',
308          xns : Roo.Toolbar,
309          '|xns' : 'Roo.Toolbar'
310         },
311         {
312          xtype : 'Button',
313          text : _this._strings['4d1c8263ba1036754f8db14a98f9f006'] /* Reload */,
314          listeners : {
315           click : function (_self, e)
316            {
317                _this.treepanel.tree.getRootNode().reload();
318                
319            }
320          },
321          xns : Roo.Toolbar,
322          '|xns' : 'Roo.Toolbar'
323         }
324        ]
325       },
326       tree : {
327        xtype : 'TreePanel',
328        containerScroll : false,
329        rootVisible : true,
330        xns : Roo.tree,
331        '|xns' : 'Roo.tree',
332        root : {
333         xtype : 'AsyncTreeNode',
334         id : 'transtree',
335         text : _this._strings['69fd71b6f79260924a32a45850a13ab7'] /* Translations (rescan this to update strings) */,
336         xns : Roo.tree,
337         '|xns' : 'Roo.tree'
338        },
339        selModel : {
340         xtype : 'DefaultSelectionModel',
341         listeners : {
342          selectionchange : function (_self, node)
343           {
344               Roo.log(node);
345               
346               //if (node.id.split('/').length < 2) {
347               //    return;
348              // }
349               (function() {
350                   _this.grid.footer.onClick('first');
351               }).defer(100);
352               
353           }
354         },
355         xns : Roo.tree,
356         '|xns' : 'Roo.tree'
357        },
358        loader : {
359         xtype : 'TreeLoader',
360         baseParams : { _tree : 1 },
361         dataUrl : baseURL + '/Roo/Core_templatestr',
362         requestMethod : 'GET',
363         listeners : {
364          beforeload : function (This, node, callback)
365           {
366               // set some params.
367               Roo.log(node);
368               this.baseParams._tree = 1;
369               
370               //this.baseParams.category = node.attributes.category;
371           },
372          loadexception : function (This, node, response)
373           {
374               Roo.MessageBox.alert("Error", "Problem loading tree");
375           }
376         },
377         xns : Roo.tree,
378         '|xns' : 'Roo.tree'
379        }
380       }
381      },
382      {
383       xtype : 'GridPanel',
384       background : false,
385       fitContainer : true,
386       fitToframe : true,
387       region : 'center',
388       tableName : 'Page',
389       title : _this._strings['193cfc9be3b995831c6af2fea6650e60'] /* Page */,
390       listeners : {
391        activate : function() {
392             _this.panel = this;
393             if (_this.grid) {
394                 _this.grid.footer.onClick('first');
395             }
396         }
397       },
398       xns : Roo,
399       '|xns' : 'Roo',
400       grid : {
401        xtype : 'EditorGrid',
402        autoExpandColumn : 'txt',
403        clicksToEdit : 1,
404        loadMask : true,
405        listeners : {
406         afteredit : function (e)
407          {
408              e.record.commit();
409          },
410         beforeedit : function (e)
411          {   
412              /*if (e.record.data.src_id_txt.indexOf('<') > -1) {
413                 // console.log("HTML EDITOR!!");
414                  Pman.Dialog.CmsTranslateEditor.show(e.record);
415                  return false;
416              }*/
417              
418              var str=e.record.data.src_id_txt;
419              var patt=/{(.*?)}/g;
420              
421              Roo.log(str.length);
422              
423              
424              if(patt.test(str)){
425                  e.cancel = true;
426                  Pman.Dialog.AdminTranslateTemplates.show(e.record.data, function(v){
427                      Roo.log(v);
428                      e.value = v.txt;
429                      e.record.set('txt', v.txt);
430                      e.record.commit();
431                  });
432                  /*
433                  Roo.MessageBox.prompt('WARNING', 'This text is with {TEMPLATE VARIABLE}, PLEASE BE CAREFUL EDITING. What\'s change? '+str, function(btn, text){
434                      if (btn == 'ok'){
435                          e.value = text;
436                          e.record.set('txt', text);
437                          e.record.commit();
438                      }
439                  });*/
440                  return;
441              }
442              
443              if(str.length > 150){
444                  e.cancel = true;
445                  Pman.Dialog.AdminTranslateTemplates.show(e.record.data, function(v){
446                      e.value = v.txt;
447                      e.record.set('txt', v.txt);
448                      e.record.commit();
449                  });
450                  /*
451                  Roo.MessageBox.prompt('WARNING', 'This text is with {TEMPLATE VARIABLE}, PLEASE BE CAREFUL EDITING. What\'s change? '+str, function(btn, text){
452                      if (btn == 'ok'){
453                          e.value = text;
454                          e.record.set('txt', text);
455                          e.record.commit();
456                      }
457                  });*/
458                  return;
459              }
460              
461          
462              if (e.record.data.txt.replace(/\s+/, '').length) {
463                  return true;
464              }
465              
466              var tl = _this.treepanel.tree.getSelectionModel().getSelectedNode().parentNode.attributes.id;
467              // mapping?
468              
469              tl = (tl == 'zh_HK') ? 'zh-TW' : tl;
470              
471              if (tl == 'en' && !e.value.length) {
472          
473                  e.value = e.record.data.src_id_txt;
474                  e.record.set('txt', e.record.data.src_id_txt);
475                  return true;
476              }
477              
478              Pman.GoogleTranslate(e.record.data.src_id_txt, "en", tl, function(result) {
479                 // Roo.log(result);
480                  _this.grid.activeEditor.setValue(result);
481                  //console.log(result.translation);
482              });
483              
484          
485              
486              return true;
487          },
488         render : function() 
489          {
490              _this.grid = this; 
491              //_this.dialog = Pman.Dialog.FILL_IN
492              if (_this.panel.active) {
493                  this.footer.onClick('first');
494                // this.ds.onc.onClick('first');
495              }
496          },
497         rowdblclick : function (_self, rowIndex, e)
498          {
499              if (!_this.dialog) {
500                  return;
501              }
502              _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
503                  _this.grid.footer.onClick('first');
504              }); 
505          }
506        },
507        xns : Roo.grid,
508        '|xns' : 'Roo.grid',
509        footer : {
510         xtype : 'PagingToolbar',
511         displayInfo : true,
512         displayMsg : _this._strings['e2f9d206562d8f5ea421ad51100f7151'] /* Displaying petition_entry{0} - {1} of {2} */,
513         emptyMsg : _this._strings['9d1ead73e678fa2f51a70a933b0bf017'] /* Not Found */,
514         pageSize : 100,
515         xns : Roo,
516         '|xns' : 'Roo'
517        },
518        toolbar : {
519         xtype : 'Toolbar',
520         xns : Roo,
521         '|xns' : 'Roo',
522         items  : [
523          {
524           xtype : 'TextField',
525           emptyText : _this._strings['e3d388b2c43e5ba0905702620ae2abc1'] /* Search for */,
526           listeners : {
527            render : function (_self)
528             {
529                 _this.searchBox = this;
530             },
531            specialkey : function (_self, e)
532             {
533             _this.grid.footer.onClick('first');
534             }
535           },
536           xns : Roo.form,
537           '|xns' : 'Roo.form'
538          },
539          {
540           xtype : 'Button',
541           cls : 'x-btn-icon',
542           icon : rootURL + '/Pman/templates/images/search.gif',
543           listeners : {
544            click : function (_self, e)
545             {
546             _this.grid.footer.onClick('first');
547             }
548           },
549           xns : Roo.Toolbar,
550           '|xns' : 'Roo.Toolbar'
551          },
552          {
553           xtype : 'Button',
554           cls : 'x-btn-icon',
555           icon : rootURL + '/Pman/templates/images/edit-clear.gif',
556           listeners : {
557            click : function (_self, e)
558             {
559                 _this.searchBox.setValue('');
560                 
561                 _this.grid.footer.onClick('first');
562             }
563           },
564           xns : Roo.Toolbar,
565           '|xns' : 'Roo.Toolbar'
566          }
567         ]
568        },
569        dataSource : {
570         xtype : 'Store',
571         remoteSort : true,
572         sortInfo : { field : 'src_id_txt', direction: 'ASC' },
573         listeners : {
574          beforeload : function (_self, o)
575           {
576              
577               var sn = _this.treepanel.tree.getSelectionModel().getSelectedNode();
578           
579               if (!sn || typeof(sn.attributes) == 'undefined' || typeof(sn.attributes.leaf) == 'undefined' || !sn.attributes.leaf) { 
580                   _this.grid.ds.removeAll();
581                   return false;
582               }
583           
584               o.params = o.params || {};
585               o.params.lang =  sn.parentNode.attributes.id.split(':')[1];
586              
587               o.params.active = 1;
588               o.params['!src_id'] = 0;
589               
590               if (_this.searchBox && _this.searchBox.getValue().length) { 
591                   o.params['_search_txt'] = _this.searchBox.getValue();
592               }
593               
594               
595               if(sn.attributes.on_table){
596                   o.params.on_table = sn.attributes.on_table;
597               } else {
598                    o.params.template_id = sn.attributes.id * 1;
599                }
600               
601           },
602          update : function (_self, rec, operation)
603           {
604               Roo.log(operation);
605               
606               if (operation != 'commit') {
607                   return;
608               }
609               
610           
611               _this.grid.getView().el.mask("Saving");
612               new Pman.Request({
613                   url : baseURL + '/Roo/Core_templatestr',
614                   method: 'POST',
615                   params : {
616                       id : rec.get('id'),
617                       txt : rec.get('txt')
618                   },
619                   success : function()
620                   {
621                       _this.grid.getView().el.unmask();
622                           //g.getDataSource().reload();
623                   },
624                   failure : function()
625                   {
626                       _this.grid.getView().el.unmask();
627                       Roo.MessageBox.alert("Error", "There was a problem saving the data - try reloading");
628                    }
629                       
630               });
631               
632           }
633         },
634         xns : Roo.data,
635         '|xns' : 'Roo.data',
636         proxy : {
637          xtype : 'HttpProxy',
638          method : 'GET',
639          url : baseURL + '/Roo/Core_templatestr.php',
640          xns : Roo.data,
641          '|xns' : 'Roo.data'
642         },
643         reader : {
644          xtype : 'JsonReader',
645          fields : [
646              {
647                  'name': 'id',
648                  'type': 'int'
649              },
650              {
651                  'name': 'shortname',
652                  'type': 'string'
653              }
654             
655          ],
656          id : 'id',
657          root : 'data',
658          totalProperty : 'total',
659          xns : Roo.data,
660          '|xns' : 'Roo.data'
661         }
662        },
663        cm : [
664         {
665          xtype : 'ColumnModel',
666          dataIndex : 'src_id_txt',
667          header : _this._strings['0a52da7a03a6de3beefe54f8c03ad80d'] /* Original */,
668          renderer : function(v,x,r) 
669          {
670              var c = '#666';
671              if (r.data.updated  < r.data.src_id_updated) {
672                  c = 'red';
673              }
674              
675              return String.format('<div style="color:'+c+'";>{0}</div>', v)
676          
677          },
678          width : 300,
679          xns : Roo.grid,
680          '|xns' : 'Roo.grid'
681         },
682         {
683          xtype : 'ColumnModel',
684          dataIndex : 'txt',
685          header : _this._strings['6dd08874f83507e9c7b23f1a46b7fa7c'] /* Translation */,
686          renderer : function(v,x,r) 
687          { 
688          
689              var c = '#666';
690              if (r.data.updated  < r.data.src_id_updated) {
691                  c = 'red';
692              }
693              
694              return String.format('<div style="color:'+c+'";>{0}</div>', v)
695          
696          },
697          width : 200,
698          xns : Roo.grid,
699          '|xns' : 'Roo.grid',
700          editor : {
701           xtype : 'GridEditor',
702           xns : Roo.grid,
703           '|xns' : 'Roo.grid',
704           field : {
705            xtype : 'TextField',
706            allowBlank : false,
707            xns : Roo.form,
708            '|xns' : 'Roo.form'
709           }
710          }
711         },
712         {
713          xtype : 'ColumnModel',
714          dataIndex : 'src_id_mdsum',
715          header : _this._strings['1bc29b36f623ba82aaf6724fd3b16718'] /* md5 */,
716          hidden : true,
717          renderer : function(v,x,r) 
718          {
719              return v ? v : '';
720          
721          },
722          width : 250,
723          xns : Roo.grid,
724          '|xns' : 'Roo.grid'
725         }
726        ]
727       }
728      }
729     ]
730    }
731   };  }
732 });