sync
[Pman.Admin] / Pman.Tab.AdminTranslationInt.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.AdminTranslationsInt = new Roo.XComponent({
8
9  _strings : {
10   'deccbe4e9083c3b5f7cd2632722765bb' :"Translate",
11   '4994a8ffeba4ac3140beb89e8d41f174' :"Language",
12   'ae739a236065a45c64ad51aacb19498c' :"Active?",
13   'd41d8cd98f00b204e9800998ecf8427e' :"",
14   '6dd08874f83507e9c7b23f1a46b7fa7c' :"Translation",
15   '83dad8107f9459efe2b4fabcf5b63108' :"Select Language",
16   '78463a384a5aa4fad5fa73e2f506ecfc' :"English",
17   '552bcc4e00cd663f09cc4efbaca1cd45' :"Select Translation of",
18   'ca0dbad92a874b2f69b549293387925e' :"Code",
19   '0a9e8bd9e8b301dfb2c21c355e0b377d' :"Languages and Countries"
20  },
21  _named_strings : {
22   'language_title_value' : 'd41d8cd98f00b204e9800998ecf8427e' /*  */ ,
23   'language_title_qtip' : '83dad8107f9459efe2b4fabcf5b63108' /* Select Language */ ,
24   'language_title_fieldLabel' : '4994a8ffeba4ac3140beb89e8d41f174' /* Language */ 
25  },
26
27   part     :  ["Admin", "TranslationInt" ],
28   order    : '950-Pman.Tab.AdminTranslationsInt',
29   region   : 'center',
30   parent   : 'Pman.Tab.Admin',
31   name     : "Admin - AdminTranslationsInt",
32   disabled : false, 
33   permname : 'Admin.TranslationsInt', 
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['deccbe4e9083c3b5f7cd2632722765bb'] /* Translate */,
42    xns : Roo,
43    '|xns' : 'Roo',
44    layout : {
45     xtype : 'BorderLayout',
46     xns : Roo,
47     '|xns' : 'Roo',
48     center : {
49      xtype : 'LayoutRegion',
50      alwaysShowTabs : true,
51      tabPosition : 'top',
52      xns : Roo,
53      '|xns' : 'Roo'
54     },
55     items  : [
56      {
57       xtype : 'GridPanel',
58       background : true,
59       fitContainer : true,
60       fitToframe : true,
61       region : 'center',
62       tableName : 'i18n',
63       title : _this._strings['0a9e8bd9e8b301dfb2c21c355e0b377d'] /* Languages and Countries */,
64       listeners : {
65        activate : function() {
66             _this.langpanel = this;
67             if (_this.langgrid) {
68                 _this.langgrid.ds.load({});
69             }
70         }
71       },
72       xns : Roo,
73       '|xns' : 'Roo',
74       grid : {
75        xtype : 'EditorGrid',
76        autoExpandColumn : 'lval',
77        clicksToEdit : 1,
78        loadMask : true,
79        listeners : {
80         afteredit : function (e)
81          {
82              var saveRec  = function(rec)
83              {
84                  var g = _this.grid;
85          
86                  //g.getView().el.mask('Saving');
87                  Ext.Ajax.request({
88                      url : baseURL + '/Roo/I18n.php',
89                      method: 'POST',
90                      params : {
91                          id : rec.get('id'),
92                          lval : rec.get('lval'),
93                          ltype : rec.get('ltype')
94                      },
95                      success : function()
96                      {
97                          //g.getView().el.unmask();
98                          //g.getDataSource().reload();
99                      },
100                      failure : function()
101                      {
102                          Ext.Msg.alert("Error", "There was a problem saving the data - try reloading");
103                         // g.getView().el.unmask();
104                      }
105                      
106              });
107                  };
108              
109              saveRec.defer(1000, _this, [ e.record ]);
110          },
111         beforeedit : function(e) {
112              console.log('beforeedit');
113              //if (e.record.get('origtxt').indexOf('<') > -1) {
114                                 // console.log("HTML EDITOR!!");
115                       
116                      //    return false;
117                      //}
118                      if (e.record.get('lval').replace(/\s+/, '').length) {
119                          return true;
120                      }
121                      
122                      
123                      var tl = _this.langgridCombo.getValue();
124                    
125                      tl = (tl == 'zh_HK') ? 'zh-TW' : tl; 
126                      tl = tl.replace('_', '-');
127                      var rec = e.record;
128                      
129                      
130                      
131                      Pman.gtranslate(e.record.get('lval_en'), 'en', tl, function(result) { 
132                          if (typeof(result) == 'object') { //error
133                              return; 
134                             }
135                          
136                          if (_this.grid.activeEditor) {
137                              _this.grid.activeEditor.setValue(result);
138                          } else {
139                              rec.set('lval',result);
140                              //_this.saveRec(rec);
141                          }
142          
143                          //
144                          
145                          
146                          //console.log(result.translation);
147                      });
148                      
149                     
150                      
151                      return true;
152                  },
153         cellclick : function (_self, rowIndex, columnIndex, e)
154          {
155              if(_this.langgrid.colModel.getDataIndex(columnIndex) !== 'is_active'){
156                  return;
157              }
158              
159              var s = _this.langgrid.ds.getAt(rowIndex);
160              
161              if(!s || s.data.id * 1 < 0){
162                  return;
163              }
164              
165              s.set('is_active', s.data.is_active ? 0 : 1);
166              
167              new Pman.Request({
168                  url : baseURL+'/Roo/I18n',
169                  method : 'POST',
170                  params : {
171                      id : s.data.id,
172                      is_active : s.data.is_active
173                  }
174              }); 
175              
176          },
177         render : function() 
178          {
179              _this.langgrid = this; 
180              //_this.dialog = Pman.Dialog.FILL_IN
181              if (_this.langpanel.active) {
182                 this.ds.load({});
183              }
184          }
185        },
186        xns : Roo.grid,
187        '|xns' : 'Roo.grid',
188        toolbar : {
189         xtype : 'Toolbar',
190         xns : Roo,
191         '|xns' : 'Roo',
192         items  : [
193          {
194           xtype : 'ComboBox',
195           displayField : 'lval',
196           editable : false,
197           emptyText : _this._strings['552bcc4e00cd663f09cc4efbaca1cd45'] /* Select Translation of */,
198           mode : 'local',
199           selectOnFocus : true,
200           triggerAction : 'all',
201           typeAhead : false,
202           valueField : 'lkey',
203           width : 200,
204           listeners : {
205            render : function (_self)
206             {
207               _this.langtypeCombo = _self;
208             },
209            select : function (combo, record, index)
210             {
211               _this.langgrid.getDataSource().reload(); 
212             }
213           },
214           xns : Roo.form,
215           '|xns' : 'Roo.form',
216           store : {
217            xtype : 'SimpleStore',
218            data : [
219               [ 'l', 'Language Names' ],
220               [ 'c', 'Country Names' ],
221                [ 'm', 'Currency Names' ]
222            ],
223            fields : ['lkey','lval'],
224            xns : Roo.data,
225            '|xns' : 'Roo.data'
226           }
227          },
228          {
229           xtype : 'ComboBox',
230           allowBlank : false,
231           displayField : 'title',
232           editable : true,
233           fieldLabel : _this._strings['4994a8ffeba4ac3140beb89e8d41f174'] /* Language */,
234           hiddenName : 'language',
235           listWidth : 300,
236           minChars : 2,
237           name : 'language_title',
238           pageSize : 400,
239           qtip : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */,
240           queryParam : 'query[name_starts]',
241           selectOnFocus : true,
242           triggerAction : 'all',
243           typeAhead : true,
244           value : _this._strings['d41d8cd98f00b204e9800998ecf8427e'] /*  */,
245           valueField : 'code',
246           width : 200,
247           listeners : {
248            render : function (_self)
249             {
250               _this.langgridCombo=_self;
251             },
252            select : function (combo, record, index)
253             {
254               _this.langgrid.getDataSource().reload(); 
255             }
256           },
257           xns : Roo.form,
258           '|xns' : 'Roo.form',
259           store : {
260            xtype : 'Store',
261            sortInfo : { field : 'title', direction: 'ASC' },
262            listeners : {
263             beforeload : function (_self, options)
264              {
265                 options  =options ||  {};
266                 options.params =options.params|| {};
267                 options.params.ltype = 'l';
268                 options.params.inlang = 'en';
269                 
270                  options.params._as_code_and_title = 1;
271                 
272              }
273            },
274            xns : Roo.data,
275            '|xns' : 'Roo.data',
276            proxy : {
277             xtype : 'HttpProxy',
278             method : 'GET',
279             url : baseURL + '/Roo/i18n.php',
280             xns : Roo.data,
281             '|xns' : 'Roo.data'
282            },
283            reader : {
284             xtype : 'JsonReader',
285             fields : [
286                 {
287                     'name': 'id',
288                     'type': 'int'
289                 },
290                 {
291                     'name': 'ltype',
292                     'type': 'string'
293                 },
294                 {
295                     'name': 'lkey',
296                     'type': 'string'
297                 },
298                 {
299                     'name': 'inlang',
300                     'type': 'string'
301                 },
302                 {
303                     'name': 'lval',
304                     'type': 'string'
305                 } 
306             ],
307             id : 'id',
308             root : 'data',
309             totalProperty : 'total',
310             xns : Roo.data,
311             '|xns' : 'Roo.data'
312            }
313           }
314          }
315         ]
316        },
317        dataSource : {
318         xtype : 'Store',
319         remoteSort : true,
320         sortInfo : { field : 'lkey', direction: 'ASC' },
321         listeners : {
322          beforeload : function (_self, options)
323           {
324              options  =options ||  {};
325              options.params =options.params|| {};
326              options.params.ltype = _this.langtypeCombo.getValue();
327              options.params.inlang = _this.langgridCombo.getValue();
328              options.params['query[_with_en]'] = 1;
329              if (!options.params.ltype.length || !options.params.inlang.length) {
330                  return false;
331              }
332              
333              options.params.limit = 9999;
334              
335           }
336         },
337         xns : Roo.data,
338         '|xns' : 'Roo.data',
339         proxy : {
340          xtype : 'HttpProxy',
341          method : 'GET',
342          url : baseURL + '/Roo/i18n.php',
343          xns : Roo.data,
344          '|xns' : 'Roo.data'
345         },
346         reader : {
347          xtype : 'JsonReader',
348          fields : [
349              {
350                  'name': 'id',
351                  'type': 'int'
352              },
353              {
354                  'name': 'ltype',
355                  'type': 'string'
356              },
357              {
358                  'name': 'lkey',
359                  'type': 'string'
360              },
361              {
362                  'name': 'inlang',
363                  'type': 'string'
364              },
365              {
366                  'name': 'lval',
367                  'type': 'string'
368              }
369          ],
370          id : 'id',
371          root : 'data',
372          totalProperty : 'total',
373          xns : Roo.data,
374          '|xns' : 'Roo.data'
375         }
376        },
377        colModel : [
378         {
379          xtype : 'ColumnModel',
380          dataIndex : 'lkey',
381          header : _this._strings['ca0dbad92a874b2f69b549293387925e'] /* Code */,
382          renderer : function(v) { return String.format('{0}', v); },
383          sortable : true,
384          width : 50,
385          xns : Roo.grid,
386          '|xns' : 'Roo.grid'
387         },
388         {
389          xtype : 'ColumnModel',
390          dataIndex : 'lval_en',
391          header : _this._strings['78463a384a5aa4fad5fa73e2f506ecfc'] /* English */,
392          renderer : function(v) { return String.format('{0}', v); },
393          sortable : true,
394          width : 150,
395          xns : Roo.grid,
396          '|xns' : 'Roo.grid'
397         },
398         {
399          xtype : 'ColumnModel',
400          dataIndex : 'lval',
401          header : _this._strings['6dd08874f83507e9c7b23f1a46b7fa7c'] /* Translation */,
402          renderer : function(v) { return String.format('{0}', v); },
403          sortable : true,
404          width : 200,
405          xns : Roo.grid,
406          '|xns' : 'Roo.grid',
407          editor : {
408           xtype : 'GridEditor',
409           xns : Roo.grid,
410           '|xns' : 'Roo.grid',
411           field : {
412            xtype : 'TextField',
413            xns : Roo.form,
414            '|xns' : 'Roo.form'
415           }
416          }
417         },
418         {
419          xtype : 'ColumnModel',
420          dataIndex : 'is_active',
421          header : _this._strings['ae739a236065a45c64ad51aacb19498c'] /* Active? */,
422          renderer : function(v,x,r) { 
423          
424              return '<img class="x-grid-check-icon' + (v*1 ? '-checked' : '')  + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
425                                                  
426              
427          },
428          width : 150,
429          xns : Roo.grid,
430          '|xns' : 'Roo.grid'
431         }
432        ]
433       }
434      }
435     ]
436    }
437   };  }
438 });