add title to pulldown
[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   '4994a8ffeba4ac3140beb89e8d41f174' :"Language",
12   'ae739a236065a45c64ad51aacb19498c' :"Active?",
13   'd41d8cd98f00b204e9800998ecf8427e' :"",
14   '801ab24683a4a8c433c6eb40c48bcd9d' :"Download",
15   'e2ade2e0b88406a390f59b5232abb328' :"Translated (Click to Edit)",
16   '6dd08874f83507e9c7b23f1a46b7fa7c' :"Translation",
17   '83dad8107f9459efe2b4fabcf5b63108' :"Select Language",
18   'a1d1ae170f841c328acdc6052511ed8c' :"Text in interface",
19   '78463a384a5aa4fad5fa73e2f506ecfc' :"English",
20   '4e7c16d320ae129cc81b296e05748b3a' :"Translate App",
21   '526d688f37a86d3c3f27d0c5016eb71d' :"Reset",
22   'b51c3fa7e0ae26a1d88bf1279f265bb4' :"Select Module",
23   '49ee3087348e8d44e1feda1917443987' :"Name",
24   '552bcc4e00cd663f09cc4efbaca1cd45' :"Select Translation of",
25   'ca0dbad92a874b2f69b549293387925e' :"Code",
26   '0a9e8bd9e8b301dfb2c21c355e0b377d' :"Languages and Countries"
27  },
28  _named_strings : {
29   'language_title_value' : 'd41d8cd98f00b204e9800998ecf8427e' /*  */ ,
30   'language_title_qtip' : '83dad8107f9459efe2b4fabcf5b63108' /* Select Language */ ,
31   'language_title_fieldLabel' : '4994a8ffeba4ac3140beb89e8d41f174' /* Language */ 
32  },
33
34   part     :  ["Admin", "Translations" ],
35   order    : '950-Pman.Tab.AdminTranslations',
36   region   : 'center',
37   parent   : 'Pman.Tab.Admin',
38   name     : "Admin - Translations",
39   disabled : false, 
40   permname : 'Admin.Translations', 
41   _tree : function(_data)
42   {
43    var _this = this;
44    var MODULE = this;
45    return {
46    xtype : 'NestedLayoutPanel',
47    region : 'center',
48    title : _this._strings['4e7c16d320ae129cc81b296e05748b3a'] /* Translate App */,
49    xns : Roo,
50    '|xns' : 'Roo',
51    layout : {
52     xtype : 'BorderLayout',
53     xns : Roo,
54     '|xns' : 'Roo',
55     center : {
56      xtype : 'LayoutRegion',
57      alwaysShowTabs : true,
58      tabPosition : 'top',
59      xns : Roo,
60      '|xns' : 'Roo'
61     },
62     items  : [
63      {
64       xtype : 'GridPanel',
65       background : true,
66       fitContainer : true,
67       fitToframe : true,
68       region : 'center',
69       title : _this._strings['a1d1ae170f841c328acdc6052511ed8c'] /* Text in interface */,
70       listeners : {
71        activate : function() {
72             _this.panel = this;
73             if (_this.grid) {
74                _this.grid.getDataSource().reload(); 
75             }
76         }
77       },
78       xns : Roo,
79       '|xns' : 'Roo',
80       grid : {
81        xtype : 'EditorGrid',
82        autoExpandColumn : 'txt',
83        clicksToEdit : 1,
84        loadMask : true,
85        listeners : {
86         afteredit : function (e)
87          {
88              var saveRec  = function(rec)
89              {
90                  var g = _this.grid;
91          
92                  //g.getView().el.mask('Saving');
93                  new Pman.Request({
94                      url : baseURL + '/Admin/Translations.php',
95                      method: 'POST',
96                      params : {
97                          id : rec.get('id'),
98                          txt : rec.get('txt'),
99                          lang :  _this.langCombo.getValue(),
100                          module :  _this.modCombo.getValue()
101                      },
102                      success : function()
103                      {
104                          //g.getView().el.unmask();
105                          //g.getDataSource().reload();
106                      },
107                      failure : function()
108                      {
109                          Roo.MessageBox.alert("Error", "There was a problem saving the data - try reloading");
110                         // g.getView().el.unmask();
111                      }
112                      
113              });
114                  };
115              
116              saveRec.defer(1000, _this, [ e.record ]);
117          },
118         beforeedit : function(e) {
119              console.log('beforeedit');
120              //if (e.record.get('origtxt').indexOf('<') > -1) {
121                                 // console.log("HTML EDITOR!!");
122                               
123                              //    return false;
124                              //}
125                              if (e.record.get('txt').replace(/\s+/, '').length) {
126                                  return true;
127                              }
128                              if (e.record.get('suggest').length) {
129                                  e.record.set('txt', e.record.get('suggest'));
130                              //    _this.saveRec(e.record);
131                                  return;
132                              }
133                              
134                              
135                              
136                             
137                              var tl = e.record.get('id').split('/')[0];
138                            
139                              tl = (tl == 'zh_HK') ? 'zh-TW' : tl; 
140                              tl = tl.replace('_', '-');
141                              var rec = e.record;
142                              
143                              
144                              
145                              Pman.gtranslate(e.record.get('origtxt'), 'en', tl, function(result) { 
146                                  if (typeof(result) == 'object') { //error
147                                      return; 
148                                     }
149                                  
150                                  if (_this.grid.activeEditor) {
151                                      _this.grid.activeEditor.setValue(result);
152                                  } else {
153                                      rec.set('txt',result);
154                                      //_this.saveRec(rec);
155                                  }
156          
157                                  //
158                                  
159                                  
160                                  //console.log(result.translation);
161                              });
162                              
163                             
164                              
165                              return true;
166                          },
167         celldblclick : function (_self, rowIndex, columnIndex, e)
168          {
169              var di  = this.colModel.config[columnIndex].dataIndex;
170              if (di != 'reset_tx') {
171                  return;
172              }
173              rec = this.ds.getAt(rowIndex);
174              
175                var g = _this.grid;
176           
177              new Pman.Request({
178                  url : baseURL + '/Admin/Translations.php',
179                  method: 'POST',
180                  params : {
181                      id : rec.get('id'),
182                      txt : '',
183                      lang :  _this.langCombo.getValue(),
184                      module :  _this.modCombo.getValue()
185                  },
186                  success : function()
187                  {
188                      //g.getView().el.unmask();
189                      //g.getDataSource().reload();
190                      rec.set('txt', '');
191                  },
192                  failure : function()
193                  {
194                      Roo.MessageBox.alert("Error", "There was a problem saving the data - try reloading");
195                     // g.getView().el.unmask();
196                  }
197                  
198              });
199                 
200              
201          },
202         render : function() { 
203              _this.grid = this; 
204              //_this.dialog = Pman.Dialog.FILL_IN
205              if (_this.panel.active) {
206                _this.grid.getDataSource().reload(); 
207              }
208          }
209        },
210        xns : Roo.grid,
211        '|xns' : 'Roo.grid',
212        toolbar : {
213         xtype : 'Toolbar',
214         xns : Roo,
215         '|xns' : 'Roo',
216         items  : [
217          {
218           xtype : 'ComboBox',
219           displayField : 'module',
220           editable : false,
221           emptyText : _this._strings['b51c3fa7e0ae26a1d88bf1279f265bb4'] /* Select Module */,
222           mode : 'local',
223           selectOnFocus : true,
224           triggerAction : 'all',
225           typeAhead : false,
226           valueField : 'module',
227           width : 200,
228           listeners : {
229            render : function (_self)
230             {
231               _this.modCombo = _self;
232             },
233            select : function (combo, record, index)
234             {
235               _this.grid.getDataSource().reload(); 
236             }
237           },
238           xns : Roo.form,
239           '|xns' : 'Roo.form',
240           store : {
241            xtype : 'SimpleStore',
242            data : (function() {             
243                    var modlist = [];             
244                    AppModules = typeof(AppModules) == 'undefined' ? '' : AppModules;
245                    Roo.each( AppModules.split(','), function(mod) {            
246                             modlist.push( [ mod ] );            
247                  });             
248                  return modlist;
249               })(),
250            fields : ['module'],
251            xns : Roo.data,
252            '|xns' : 'Roo.data'
253           }
254          },
255          {
256           xtype : 'ComboBox',
257           displayField : 'ldisp',
258           editable : false,
259           emptyText : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */,
260           mode : 'local',
261           selectOnFocus : true,
262           triggerAction : 'all',
263           typeAhead : false,
264           valueField : 'lang',
265           width : 200,
266           listeners : {
267            render : function (_self)
268             {
269               _this.langCombo=_self;
270             },
271            select : function (combo, record, index)
272             {
273               _this.grid.getDataSource().reload(); 
274             }
275           },
276           xns : Roo.form,
277           '|xns' : 'Roo.form',
278           store : {
279            xtype : 'SimpleStore',
280            data : [                                                [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ],                         [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ]                     ],
281            fields : ['lang', 'ldisp'],
282            xns : Roo.data,
283            '|xns' : 'Roo.data'
284           }
285          },
286          {
287           xtype : 'Fill',
288           xns : Roo.Toolbar,
289           '|xns' : 'Roo.Toolbar'
290          },
291          {
292           xtype : 'Button',
293           text : _this._strings['801ab24683a4a8c433c6eb40c48bcd9d'] /* Download */,
294           listeners : {
295            click : function (_self, e)
296             {
297                 new Pman.Download({
298                     grid: _this.grid
299                 
300                 });
301             }
302           },
303           xns : Roo.Toolbar,
304           '|xns' : 'Roo.Toolbar'
305          }
306         ]
307        },
308        dataSource : {
309         xtype : 'Store',
310         reader : Pman.Readers.Category,
311         listeners : {
312          beforeload : function (_self, opts)
313           {
314           
315                                   if (!_this.langCombo || !_this.langCombo.getValue().length) {
316                                       return false;
317                                   }
318                                   if (!_this.modCombo || !_this.modCombo.getValue().length) {
319                                       return false;
320                                   }
321                                   opts.params = {
322                                       lang :  _this.langCombo.getValue(),
323                                       module :  _this.modCombo.getValue()
324                                   };
325           },
326          loadexception : function (self, ret, load, jsonData)
327           {
328               Roo.MessageBox.alert("Error", jsonData);
329           }
330         },
331         xns : Roo.data,
332         '|xns' : 'Roo.data',
333         proxy : {
334          xtype : 'HttpProxy',
335          method : 'GET',
336          url : baseURL + '/Admin/Translations.php',
337          xns : Roo.data,
338          '|xns' : 'Roo.data'
339         },
340         reader : {
341          xtype : 'JsonReader',
342          fields : [                    'id',             'tablename',             'tableid',             'colname',             'txt',             'lang',             { name:'updated', type:'date', dateFormat: 'Y-m-d H:i:s' },             { name:'origupdated', type:'date', dateFormat: 'Y-m-d H:i:s' },             'origtxt',             'msum',             'suggest'                  ],
343          id : 'id',
344          root : 'data',
345          totalProperty : 'total',
346          xns : Roo.data,
347          '|xns' : 'Roo.data'
348         }
349        },
350        colModel : [
351         {
352          xtype : 'ColumnModel',
353          dataIndex : 'colname',
354          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
355          renderer : function(v,x,r) {                       
356            var c = '#666';                       
357              if (r.get('updated') < r.get('origupdated')) {         
358                                  c = 'red';                       
359                                  
360                                    }                                 
361                                                     return '<div style="color:'+c+'";>' +r.get('tableid')+ ':' + v + '</div>';          
362                                                                                         },
363          width : 150,
364          xns : Roo.grid,
365          '|xns' : 'Roo.grid'
366         },
367         {
368          xtype : 'ColumnModel',
369          dataIndex : 'origtxt',
370          header : _this._strings['0a52da7a03a6de3beefe54f8c03ad80d'] /* Original */,
371          renderer : function(v,x,r) {                         var c = '#666';                         if (r.get('updated') < r.get('origupdated')) {                             c = 'red';                         }                         return '<div style="color:' + c+ '">' +                                  Ext.util.Format.htmlEncode(v) + '</div>';                                              },
372          width : 300,
373          xns : Roo.grid,
374          '|xns' : 'Roo.grid'
375         },
376         {
377          xtype : 'ColumnModel',
378          dataIndex : 'reset_tx',
379          header : _this._strings['526d688f37a86d3c3f27d0c5016eb71d'] /* Reset */,
380          renderer : function(v,x,r) {    
381              return  '<img src="' + rootURL + '/Pman/templates/images/edit-clear.gif' + '" width="16" height="16">';
382          },
383          width : 50,
384          xns : Roo.grid,
385          '|xns' : 'Roo.grid'
386         },
387         {
388          xtype : 'ColumnModel',
389          dataIndex : 'txt',
390          header : _this._strings['e2ade2e0b88406a390f59b5232abb328'] /* Translated (Click to Edit) */,
391          renderer : function(v,x,r) {                                                   var c = '#666';                         if (r.get('updated') < r.get('origupdated')) {                             c = 'red';                         }                                                  return '<div style="color:' + c+ '">' + Ext.util.Format.htmlEncode(v) + '</div>';                     },
392          width : 150,
393          xns : Roo.grid,
394          '|xns' : 'Roo.grid',
395          editor : {
396           xtype : 'GridEditor',
397           xns : Roo.grid,
398           '|xns' : 'Roo.grid',
399           field : {
400            xtype : 'TextField',
401            xns : Roo.form,
402            '|xns' : 'Roo.form'
403           }
404          }
405         }
406        ]
407       }
408      },
409      {
410       xtype : 'GridPanel',
411       background : true,
412       fitContainer : true,
413       fitToframe : true,
414       region : 'center',
415       tableName : 'i18n',
416       title : _this._strings['0a9e8bd9e8b301dfb2c21c355e0b377d'] /* Languages and Countries */,
417       listeners : {
418        activate : function() {
419             _this.langpanel = this;
420             if (_this.langgrid) {
421                 _this.langgrid.ds.load({});
422             }
423         }
424       },
425       xns : Roo,
426       '|xns' : 'Roo',
427       grid : {
428        xtype : 'EditorGrid',
429        autoExpandColumn : 'lval',
430        clicksToEdit : 1,
431        loadMask : true,
432        listeners : {
433         afteredit : function (e)
434          {
435              var saveRec  = function(rec)
436              {
437                  var g = _this.grid;
438          
439                  //g.getView().el.mask('Saving');
440                  Ext.Ajax.request({
441                      url : baseURL + '/Roo/I18n.php',
442                      method: 'POST',
443                      params : {
444                          id : rec.get('id'),
445                          lval : rec.get('lval'),
446                          ltype : rec.get('ltype')
447                      },
448                      success : function()
449                      {
450                          //g.getView().el.unmask();
451                          //g.getDataSource().reload();
452                      },
453                      failure : function()
454                      {
455                          Ext.Msg.alert("Error", "There was a problem saving the data - try reloading");
456                         // g.getView().el.unmask();
457                      }
458                      
459              });
460                  };
461              
462              saveRec.defer(1000, _this, [ e.record ]);
463          },
464         beforeedit : function(e) {
465              console.log('beforeedit');
466              //if (e.record.get('origtxt').indexOf('<') > -1) {
467                                 // console.log("HTML EDITOR!!");
468                       
469                      //    return false;
470                      //}
471                      if (e.record.get('lval').replace(/\s+/, '').length) {
472                          return true;
473                      }
474                      
475                      
476                      var tl = _this.langgridCombo.getValue();
477                    
478                      tl = (tl == 'zh_HK') ? 'zh-TW' : tl; 
479                      tl = tl.replace('_', '-');
480                      var rec = e.record;
481                      
482                      
483                      
484                      Pman.gtranslate(e.record.get('lval_en'), 'en', tl, function(result) { 
485                          if (typeof(result) == 'object') { //error
486                              return; 
487                             }
488                          
489                          if (_this.grid.activeEditor) {
490                              _this.grid.activeEditor.setValue(result);
491                          } else {
492                              rec.set('lval',result);
493                              //_this.saveRec(rec);
494                          }
495          
496                          //
497                          
498                          
499                          //console.log(result.translation);
500                      });
501                      
502                     
503                      
504                      return true;
505                  },
506         cellclick : function (_self, rowIndex, columnIndex, e)
507          {
508              if(_this.langgrid.colModel.getDataIndex(columnIndex) !== 'is_active'){
509                  return;
510              }
511              
512              var s = _this.langgrid.ds.getAt(rowIndex);
513              
514              if(!s || s.data.id * 1 < 0){
515                  return;
516              }
517              
518              s.set('is_active', s.data.is_active ? 0 : 1);
519              
520              new Pman.Request({
521                  url : baseURL+'/Roo/I18n',
522                  method : 'POST',
523                  params : {
524                      id : s.data.id,
525                      is_active : s.data.is_active
526                  }
527              }); 
528              
529          },
530         render : function() 
531          {
532              _this.langgrid = this; 
533              //_this.dialog = Pman.Dialog.FILL_IN
534              if (_this.langpanel.active) {
535                 this.ds.load({});
536              }
537          }
538        },
539        xns : Roo.grid,
540        '|xns' : 'Roo.grid',
541        toolbar : {
542         xtype : 'Toolbar',
543         xns : Roo,
544         '|xns' : 'Roo',
545         items  : [
546          {
547           xtype : 'ComboBox',
548           displayField : 'lval',
549           editable : false,
550           emptyText : _this._strings['552bcc4e00cd663f09cc4efbaca1cd45'] /* Select Translation of */,
551           mode : 'local',
552           selectOnFocus : true,
553           triggerAction : 'all',
554           typeAhead : false,
555           valueField : 'lkey',
556           width : 200,
557           listeners : {
558            render : function (_self)
559             {
560               _this.langtypeCombo = _self;
561             },
562            select : function (combo, record, index)
563             {
564               _this.langgrid.getDataSource().reload(); 
565             }
566           },
567           xns : Roo.form,
568           '|xns' : 'Roo.form',
569           store : {
570            xtype : 'SimpleStore',
571            data : [
572               [ 'l', 'Language Names' ],
573               [ 'c', 'Country Names' ],
574                [ 'm', 'Currency Names' ]
575            ],
576            fields : ['lkey','lval'],
577            xns : Roo.data,
578            '|xns' : 'Roo.data'
579           }
580          },
581          {
582           xtype : 'ComboBox',
583           allowBlank : false,
584           displayField : 'title',
585           editable : true,
586           fieldLabel : _this._strings['4994a8ffeba4ac3140beb89e8d41f174'] /* Language */,
587           hiddenName : 'language',
588           listWidth : 300,
589           minChars : 2,
590           name : 'language_title',
591           pageSize : 400,
592           qtip : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */,
593           queryParam : 'query[name_starts]',
594           selectOnFocus : true,
595           triggerAction : 'all',
596           typeAhead : true,
597           value : _this._strings['d41d8cd98f00b204e9800998ecf8427e'] /*  */,
598           valueField : 'code',
599           width : 200,
600           listeners : {
601            render : function (_self)
602             {
603               _this.langgridCombo=_self;
604             },
605            select : function (combo, record, index)
606             {
607               _this.langgrid.getDataSource().reload(); 
608             }
609           },
610           xns : Roo.form,
611           '|xns' : 'Roo.form',
612           store : {
613            xtype : 'Store',
614            sortInfo : { field : 'title', direction: 'ASC' },
615            listeners : {
616             beforeload : function (_self, options)
617              {
618                 options  =options ||  {};
619                 options.params =options.params|| {};
620                 options.params.ltype = 'l';
621                 options.params.inlang = 'en';
622                 
623                  options.params._as_code_and_title = 1;
624                 
625              }
626            },
627            xns : Roo.data,
628            '|xns' : 'Roo.data',
629            proxy : {
630             xtype : 'HttpProxy',
631             method : 'GET',
632             url : baseURL + '/Roo/i18n.php',
633             xns : Roo.data,
634             '|xns' : 'Roo.data'
635            },
636            reader : {
637             xtype : 'JsonReader',
638             fields : [
639                 {
640                     'name': 'id',
641                     'type': 'int'
642                 },
643                 {
644                     'name': 'ltype',
645                     'type': 'string'
646                 },
647                 {
648                     'name': 'lkey',
649                     'type': 'string'
650                 },
651                 {
652                     'name': 'inlang',
653                     'type': 'string'
654                 },
655                 {
656                     'name': 'lval',
657                     'type': 'string'
658                 },
659                 'title'
660             ],
661             id : 'id',
662             root : 'data',
663             totalProperty : 'total',
664             xns : Roo.data,
665             '|xns' : 'Roo.data'
666            }
667           }
668          }
669         ]
670        },
671        dataSource : {
672         xtype : 'Store',
673         remoteSort : true,
674         sortInfo : { field : 'lkey', direction: 'ASC' },
675         listeners : {
676          beforeload : function (_self, options)
677           {
678              options  =options ||  {};
679              options.params =options.params|| {};
680              options.params.ltype = _this.langtypeCombo.getValue();
681              options.params.inlang = _this.langgridCombo.getValue();
682              options.params['query[_with_en]'] = 1;
683              if (!options.params.ltype.length || !options.params.inlang.length) {
684                  return false;
685              }
686              
687              options.params.limit = 9999;
688              
689           }
690         },
691         xns : Roo.data,
692         '|xns' : 'Roo.data',
693         proxy : {
694          xtype : 'HttpProxy',
695          method : 'GET',
696          url : baseURL + '/Roo/i18n.php',
697          xns : Roo.data,
698          '|xns' : 'Roo.data'
699         },
700         reader : {
701          xtype : 'JsonReader',
702          fields : [
703              {
704                  'name': 'id',
705                  'type': 'int'
706              },
707              {
708                  'name': 'ltype',
709                  'type': 'string'
710              },
711              {
712                  'name': 'lkey',
713                  'type': 'string'
714              },
715              {
716                  'name': 'inlang',
717                  'type': 'string'
718              },
719              {
720                  'name': 'lval',
721                  'type': 'string'
722              }
723          ],
724          id : 'id',
725          root : 'data',
726          totalProperty : 'total',
727          xns : Roo.data,
728          '|xns' : 'Roo.data'
729         }
730        },
731        colModel : [
732         {
733          xtype : 'ColumnModel',
734          dataIndex : 'lkey',
735          header : _this._strings['ca0dbad92a874b2f69b549293387925e'] /* Code */,
736          renderer : function(v) { return String.format('{0}', v); },
737          width : 50,
738          xns : Roo.grid,
739          '|xns' : 'Roo.grid'
740         },
741         {
742          xtype : 'ColumnModel',
743          dataIndex : 'lval_en',
744          header : _this._strings['78463a384a5aa4fad5fa73e2f506ecfc'] /* English */,
745          renderer : function(v) { return String.format('{0}', v); },
746          width : 150,
747          xns : Roo.grid,
748          '|xns' : 'Roo.grid'
749         },
750         {
751          xtype : 'ColumnModel',
752          dataIndex : 'lval',
753          header : _this._strings['6dd08874f83507e9c7b23f1a46b7fa7c'] /* Translation */,
754          renderer : function(v) { return String.format('{0}', v); },
755          width : 200,
756          xns : Roo.grid,
757          '|xns' : 'Roo.grid',
758          editor : {
759           xtype : 'GridEditor',
760           xns : Roo.grid,
761           '|xns' : 'Roo.grid',
762           field : {
763            xtype : 'TextField',
764            xns : Roo.form,
765            '|xns' : 'Roo.form'
766           }
767          }
768         },
769         {
770          xtype : 'ColumnModel',
771          dataIndex : 'is_active',
772          header : _this._strings['ae739a236065a45c64ad51aacb19498c'] /* Active? */,
773          renderer : function(v,x,r) { 
774          
775              return '<img class="x-grid-check-icon' + (v*1 ? '-checked' : '')  + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
776                                                  
777              
778          },
779          width : 150,
780          xns : Roo.grid,
781          '|xns' : 'Roo.grid'
782         }
783        ]
784       }
785      }
786     ]
787    }
788   };  }
789 });