Pman.Tab.AdminTranslations.bjs
[Pman.Admin] / Pman.Tab.AdminTranslations.bjs
1 {
2     "id": "roo-file-56",
3     "name": "Pman.Tab.AdminTranslations",
4     "parent": "Pman.Tab.Admin",
5     "title": "Admin - Translations",
6     "path": "/home/alan/gitlive/Pman.Admin/Pman.Tab.AdminTranslations.bjs",
7     "items": [
8         {
9             "region": "center",
10             "title": "Translate App",
11             "xtype": "NestedLayoutPanel",
12             "|xns": "Roo",
13             "items": [
14                 {
15                     "|xns": "Roo",
16                     "xtype": "BorderLayout",
17                     "*prop": "layout",
18                     "items": [
19                         {
20                             "*prop": "center",
21                             "alwaysShowTabs": true,
22                             "tabPosition": "top",
23                             "xtype": "LayoutRegion",
24                             "|xns": "Roo"
25                         },
26                         {
27                             "listeners": {
28                                 "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n       _this.grid.getDataSource().reload(); \n    }\n}"
29                             },
30                             "background": true,
31                             "fitContainer": true,
32                             "fitToframe": true,
33                             "region": "center",
34                             "title": "Text in interface",
35                             "xtype": "GridPanel",
36                             "|xns": "Roo",
37                             "items": [
38                                 {
39                                     "listeners": {
40                                         "|render": "function() { \n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.panel.active) {\n      _this.grid.getDataSource().reload(); \n    }\n}",
41                                         "|beforeedit": "function(e) {\n    console.log('beforeedit');\n    //if (e.record.get('origtxt').indexOf('<') > -1) {\n                       // console.log(\"HTML EDITOR!!\");\n                     \n                    //    return false;\n                    //}\n                    if (e.record.get('txt').replace(/\\s+/, '').length) {\n                        return true;\n                    }\n                    if (e.record.get('suggest').length) {\n                        e.record.set('txt', e.record.get('suggest'));\n                    //    _this.saveRec(e.record);\n                        return;\n                    }\n                    \n                    \n                    \n                   \n                    var tl = e.record.get('id').split('/')[0];\n                  \n                    tl = (tl == 'zh_HK') ? 'zh-TW' : tl; \n                    tl = tl.replace('_', '-');\n                    var rec = e.record;\n                    \n                    \n                    \n                    Pman.gtranslate(e.record.get('origtxt'), 'en', tl, function(result) { \n                        if (typeof(result) == 'object') { //error\n                            return; \n                           }\n                        \n                        if (_this.grid.activeEditor) {\n                            _this.grid.activeEditor.setValue(result);\n                        } else {\n                            rec.set('txt',result);\n                            //_this.saveRec(rec);\n                        }\n\n                        //\n                        \n                        \n                        //console.log(result.translation);\n                    });\n                    \n                   \n                    \n                    return true;\n                } ",
42                                         "|afteredit": "function (e)\n{\n    var saveRec  = function(rec)\n    {\n        var g = _this.grid;\n\n        //g.getView().el.mask('Saving');\n        Ext.Ajax.request({\n            url : baseURL + '/Admin/Translations.php',\n            method: 'POST',\n            params : {\n                id : rec.get('id'),\n                txt : rec.get('txt'),\n                lang :  _this.langCombo.getValue(),\n                module :  _this.modCombo.getValue()\n            },\n            success : function()\n            {\n                //g.getView().el.unmask();\n                //g.getDataSource().reload();\n            },\n            failure : function()\n            {\n                Ext.Msg.alert(\"Error\", \"There was a problem saving the data - try reloading\");\n               // g.getView().el.unmask();\n            }\n            \n    });\n        };\n    \n    saveRec.defer(1000, _this, [ e.record ]);\n}"
43                                     },
44                                     "*prop": "grid",
45                                     "autoExpandColumn": "txt",
46                                     "clicksToEdit": 1,
47                                     "loadMask": true,
48                                     "xtype": "EditorGrid",
49                                     "|xns": "Roo.grid",
50                                     "items": [
51                                         {
52                                             "*prop": "dataSource",
53                                             "xtype": "Store",
54                                             "|reader": "Pman.Readers.Category",
55                                             "listeners": {
56                                                 "|beforeload": "function (_self, opts)\n{\n\n                        if (!_this.langCombo || !_this.langCombo.getValue().length) {\n                            return false;\n                        }\n                        if (!_this.modCombo || !_this.modCombo.getValue().length) {\n                            return false;\n                        }\n                        opts.params = {\n                            lang :  _this.langCombo.getValue(),\n                            module :  _this.modCombo.getValue()\n                        };\n}"
57                                             },
58                                             "|xns": "Roo.data",
59                                             "items": [
60                                                 {
61                                                     "*prop": "proxy",
62                                                     "xtype": "HttpProxy",
63                                                     "method": "GET",
64                                                     "|url": "baseURL + '/Admin/Translations.php'",
65                                                     "listeners": {},
66                                                     "|xns": "Roo.data"
67                                                 },
68                                                 {
69                                                     "xtype": "JsonReader",
70                                                     "|xns": "Roo.data",
71                                                     "*prop": "reader",
72                                                     "root": "data",
73                                                     "totalProperty": "total",
74                                                     "id": "id",
75                                                     "|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'                  ]",
76                                                     "listeners": {}
77                                                 }
78                                             ]
79                                         },
80                                         {
81                                             "*prop": "toolbar",
82                                             "xtype": "Toolbar",
83                                             "listeners": {},
84                                             "|xns": "Roo",
85                                             "items": [
86                                                 {
87                                                     "xtype": "ComboBox",
88                                                     "listeners": {
89                                                         "|render": "function (_self)\n{\n  _this.modCombo = _self;\n}",
90                                                         "|select": "function (combo, record, index)\n{\n  _this.grid.getDataSource().reload(); \n}"
91                                                     },
92                                                     "valueField": "module",
93                                                     "displayField": "module",
94                                                     "width": 200,
95                                                     "typeAhead": false,
96                                                     "editable": false,
97                                                     "mode": "local",
98                                                     "triggerAction": "all",
99                                                     "emptyText": "Select Module",
100                                                     "selectOnFocus": true,
101                                                     "|xns": "Roo.form",
102                                                     "items": [
103                                                         {
104                                                             "*prop": "store",
105                                                             "xtype": "SimpleStore",
106                                                             "|data": "(function() {             \n        var modlist = [];             \n        AppModules = typeof(AppModules) == 'undefined' ? '' : AppModules;\n        Roo.each( AppModules.split(','), function(mod) {            \n                 modlist.push( [ mod ] );            \n      });             \n      return modlist;\n   })()",
107                                                             "|fields": "['module']",
108                                                             "|xns": "Roo.data"
109                                                         }
110                                                     ]
111                                                 },
112                                                 {
113                                                     "xtype": "ComboBox",
114                                                     "listeners": {
115                                                         "|select": "function (combo, record, index)\n{\n  _this.grid.getDataSource().reload(); \n}",
116                                                         "|render": "function (_self)\n{\n  _this.langCombo=_self;\n}"
117                                                     },
118                                                     "valueField": "lang",
119                                                     "displayField": "ldisp",
120                                                     "width": 200,
121                                                     "typeAhead": false,
122                                                     "editable": false,
123                                                     "mode": "local",
124                                                     "triggerAction": "all",
125                                                     "emptyText": "Select Language",
126                                                     "selectOnFocus": true,
127                                                     "|xns": "Roo.form",
128                                                     "items": [
129                                                         {
130                                                             "xtype": "SimpleStore",
131                                                             "|xns": "Roo.data",
132                                                             "*prop": "store",
133                                                             "listeners": {},
134                                                             "|fields": "['lang', 'ldisp']",
135                                                             "|data": "[                                                [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ],                         [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ]                     ]"
136                                                         }
137                                                     ]
138                                                 }
139                                             ]
140                                         },
141                                         {
142                                             "xtype": "ColumnModel",
143                                             "header": "Name",
144                                             "width": 150,
145                                             "dataIndex": "colname",
146                                             "|renderer": "function(v,x,r) {                         var c = '#666';                         if (r.get('updated') < r.get('origupdated')) {                             c = 'red';                         }                                                  return '<div style=\"color:'+c+'\";>' +r.get('tableid')+ ':' + v + '</div>';                                              }",
147                                             "listeners": {},
148                                             "|xns": "Roo.grid",
149                                             "*prop": "colModel[]"
150                                         },
151                                         {
152                                             "xtype": "ColumnModel",
153                                             "header": "Original",
154                                             "width": 300,
155                                             "dataIndex": "origtxt",
156                                             "|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>';                                              }",
157                                             "listeners": {},
158                                             "|xns": "Roo.grid",
159                                             "*prop": "colModel[]"
160                                         },
161                                         {
162                                             "*prop": "colModel[]",
163                                             "dataIndex": "txt",
164                                             "header": "Translated (Click to Edit)",
165                                             "width": 150,
166                                             "xtype": "ColumnModel",
167                                             "|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>';                     }",
168                                             "|xns": "Roo.grid",
169                                             "items": [
170                                                 {
171                                                     "xtype": "GridEditor",
172                                                     "*prop": "editor",
173                                                     "|xns": "Roo.grid",
174                                                     "listeners": {},
175                                                     "items": [
176                                                         {
177                                                             "xtype": "TextField",
178                                                             "*prop": "field",
179                                                             "|xns": "Roo.form",
180                                                             "listeners": {}
181                                                         }
182                                                     ]
183                                                 }
184                                             ]
185                                         }
186                                     ]
187                                 }
188                             ]
189                         },
190                         {
191                             "listeners": {
192                                 "|activate": "function() {\n    _this.langpanel = this;\n    if (_this.langgrid) {\n        _this.langgrid.ds.load({});\n    }\n}"
193                             },
194                             "background": true,
195                             "fitContainer": true,
196                             "fitToframe": true,
197                             "region": "center",
198                             "tableName": "i18n",
199                             "title": "i18n",
200                             "xtype": "GridPanel",
201                             "|xns": "Roo",
202                             "items": [
203                                 {
204                                     "listeners": {
205                                         "|render": "function() \n{\n    _this.langgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.langpanel.active) {\n       this.ds.load({});\n    }\n}",
206                                         "afteredit": "function (e)\n{\n    var saveRec  = function(rec)\n    {\n        var g = _this.grid;\n\n        //g.getView().el.mask('Saving');\n        Ext.Ajax.request({\n            url : baseURL + '/Roo/I18n.php',\n            method: 'POST',\n            params : {\n                id : rec.get('id'),\n                lval : rec.get('lval')\n            },\n            success : function()\n            {\n                //g.getView().el.unmask();\n                //g.getDataSource().reload();\n            },\n            failure : function()\n            {\n                Ext.Msg.alert(\"Error\", \"There was a problem saving the data - try reloading\");\n               // g.getView().el.unmask();\n            }\n            \n    });\n        };\n    \n    saveRec.defer(1000, _this, [ e.record ]);\n}",
207                                         "beforeedit": "function(e) {\n    console.log('beforeedit');\n    //if (e.record.get('origtxt').indexOf('<') > -1) {\n                       // console.log(\"HTML EDITOR!!\");\n             \n            //    return false;\n            //}\n            if (e.record.get('lval').replace(/\\s+/, '').length) {\n                return true;\n            }\n            \n             \n            \n            \n            Pman.gtranslate(e.record.get('lval_en'), 'en', tl, function(result) { \n                if (typeof(result) == 'object') { //error\n                    return; \n                   }\n                \n                if (_this.grid.activeEditor) {\n                    _this.grid.activeEditor.setValue(result);\n                } else {\n                    rec.set('lval',result);\n                    //_this.saveRec(rec);\n                }\n\n                //\n                \n                \n                //console.log(result.translation);\n            });\n            \n           \n            \n            return true;\n        } "
208                                     },
209                                     "*prop": "grid",
210                                     "autoExpandColumn": "lval",
211                                     "clicksToEdit": 1,
212                                     "loadMask": true,
213                                     "xtype": "EditorGrid",
214                                     "|xns": "Roo.grid",
215                                     "items": [
216                                         {
217                                             "listeners": {
218                                                 "beforeload": "function (_self, options)\n{\n   options  =options ||  {};\n   options.params =options.params|| {};\n   options.params.ltype = _this.langtypeCombo.getValue();\n   options.params.inlang = _this.langgridCombo.getValue();\n   options.params['query[_with_en]'] = 1;\n   if (!options.params.ltype.length || !options.params.inlang.length) {\n       return false;\n   }\n   \n   options.params.limit = 9999;\n   \n}"
219                                             },
220                                             "*prop": "dataSource",
221                                             "remoteSort": true,
222                                             "xtype": "Store",
223                                             "|sortInfo": "{ field : 'lkey', direction: 'ASC' }",
224                                             "|xns": "Roo.data",
225                                             "items": [
226                                                 {
227                                                     "*prop": "proxy",
228                                                     "xtype": "HttpProxy",
229                                                     "method": "GET",
230                                                     "|url": "baseURL + '/Roo/i18n.php'",
231                                                     "|xns": "Roo.data"
232                                                 },
233                                                 {
234                                                     "|xns": "Roo.data",
235                                                     "xtype": "JsonReader",
236                                                     "totalProperty": "total",
237                                                     "root": "data",
238                                                     "*prop": "reader",
239                                                     "id": "id",
240                                                     "|fields": "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'ltype',\n        'type': 'string'\n    },\n    {\n        'name': 'lkey',\n        'type': 'string'\n    },\n    {\n        'name': 'inlang',\n        'type': 'string'\n    },\n    {\n        'name': 'lval',\n        'type': 'string'\n    }\n]"
241                                                 }
242                                             ]
243                                         },
244                                         {
245                                             "*prop": "toolbar",
246                                             "xtype": "Toolbar",
247                                             "|xns": "Roo",
248                                             "items": [
249                                                 {
250                                                     "listeners": {
251                                                         "|render": "function (_self)\n{\n  _this.langtypeCombo = _self;\n}",
252                                                         "|select": "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}"
253                                                     },
254                                                     "displayField": "lval",
255                                                     "editable": false,
256                                                     "emptyText": "Select Translation of",
257                                                     "mode": "local",
258                                                     "selectOnFocus": true,
259                                                     "triggerAction": "all",
260                                                     "typeAhead": false,
261                                                     "valueField": "lkey",
262                                                     "width": 200,
263                                                     "xtype": "ComboBox",
264                                                     "|xns": "Roo.form",
265                                                     "items": [
266                                                         {
267                                                             "*prop": "store",
268                                                             "xtype": "SimpleStore",
269                                                             "|data": "[\n   [ 'l', 'Language Names' ],\n   [ 'c', 'Country Names' ],\n    [ 'm', 'Currency Names' ]\n]",
270                                                             "|fields": "['lkey','lval']",
271                                                             "|xns": "Roo.data"
272                                                         }
273                                                     ]
274                                                 },
275                                                 {
276                                                     "listeners": {
277                                                         "|select": "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}",
278                                                         "|render": "function (_self)\n{\n  _this.langgridCombo=_self;\n}"
279                                                     },
280                                                     "displayField": "ldisp",
281                                                     "editable": false,
282                                                     "emptyText": "Select Language",
283                                                     "mode": "local",
284                                                     "selectOnFocus": true,
285                                                     "triggerAction": "all",
286                                                     "typeAhead": false,
287                                                     "valueField": "lang",
288                                                     "width": 200,
289                                                     "xtype": "ComboBox",
290                                                     "|xns": "Roo.form",
291                                                     "items": [
292                                                         {
293                                                             "xtype": "SimpleStore",
294                                                             "|xns": "Roo.data",
295                                                             "*prop": "store",
296                                                             "listeners": {},
297                                                             "|fields": "['lang', 'ldisp']",
298                                                             "|data": "[                                                [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ],                         [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ]                     ]"
299                                                         }
300                                                     ]
301                                                 }
302                                             ]
303                                         },
304                                         {
305                                             "*prop": "colModel[]",
306                                             "dataIndex": "lkey",
307                                             "header": "Code",
308                                             "width": 50,
309                                             "xtype": "ColumnModel",
310                                             "|renderer": "function(v) { return String.format('{0}', v); }",
311                                             "|xns": "Roo.grid"
312                                         },
313                                         {
314                                             "*prop": "colModel[]",
315                                             "dataIndex": "lval_en",
316                                             "header": "English",
317                                             "width": 150,
318                                             "xtype": "ColumnModel",
319                                             "|renderer": "function(v) { return String.format('{0}', v); }",
320                                             "|xns": "Roo.grid"
321                                         },
322                                         {
323                                             "*prop": "colModel[]",
324                                             "dataIndex": "lval",
325                                             "header": "Translation",
326                                             "width": 200,
327                                             "xtype": "ColumnModel",
328                                             "|renderer": "function(v) { return String.format('{0}', v); }",
329                                             "|xns": "Roo.grid",
330                                             "items": [
331                                                 {
332                                                     "xtype": "GridEditor",
333                                                     "*prop": "editor",
334                                                     "|xns": "Roo.grid",
335                                                     "listeners": {},
336                                                     "items": [
337                                                         {
338                                                             "xtype": "TextField",
339                                                             "*prop": "field",
340                                                             "|xns": "Roo.form",
341                                                             "listeners": {}
342                                                         }
343                                                     ]
344                                                 }
345                                             ]
346                                         }
347                                     ]
348                                 }
349                             ]
350                         }
351                     ]
352                 }
353             ]
354         }
355     ],
356     "permname": "Admin.Translations",
357     "modOrder": "950"
358 }