Pman.Tab.AdminTranslations.bjs
[Pman.Admin] / Pman.Tab.AdminTranslations.bjs
1 {
2     "id": "roo-file-168",
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        new Roo.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                                         "celldblclick": "function (_self, rowIndex, columnIndex, e)\n{\n    var di  = this.colModel.config[columnIndex].dataIndex;\n    if (di != 'reset_tx') {\n        return;\n    }\n}"
44                                     },
45                                     "*prop": "grid",
46                                     "autoExpandColumn": "txt",
47                                     "clicksToEdit": 1,
48                                     "loadMask": true,
49                                     "xtype": "EditorGrid",
50                                     "|xns": "Roo.grid",
51                                     "items": [
52                                         {
53                                             "listeners": {
54                                                 "|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}",
55                                                 "loadexception": "function (self, ret, load, jsonData)\n{\n    Roo.MessageBox.alert(\"Error\", jsonData);\n}"
56                                             },
57                                             "*prop": "dataSource",
58                                             "xtype": "Store",
59                                             "|reader": "Pman.Readers.Category",
60                                             "|xns": "Roo.data",
61                                             "items": [
62                                                 {
63                                                     "*prop": "proxy",
64                                                     "xtype": "HttpProxy",
65                                                     "method": "GET",
66                                                     "|url": "baseURL + '/Admin/Translations.php'",
67                                                     "listeners": {},
68                                                     "|xns": "Roo.data"
69                                                 },
70                                                 {
71                                                     "xtype": "JsonReader",
72                                                     "|xns": "Roo.data",
73                                                     "*prop": "reader",
74                                                     "root": "data",
75                                                     "totalProperty": "total",
76                                                     "id": "id",
77                                                     "|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'                  ]",
78                                                     "listeners": {}
79                                                 }
80                                             ]
81                                         },
82                                         {
83                                             "*prop": "toolbar",
84                                             "xtype": "Toolbar",
85                                             "listeners": {},
86                                             "|xns": "Roo",
87                                             "items": [
88                                                 {
89                                                     "xtype": "ComboBox",
90                                                     "listeners": {
91                                                         "|render": "function (_self)\n{\n  _this.modCombo = _self;\n}",
92                                                         "|select": "function (combo, record, index)\n{\n  _this.grid.getDataSource().reload(); \n}"
93                                                     },
94                                                     "valueField": "module",
95                                                     "displayField": "module",
96                                                     "width": 200,
97                                                     "typeAhead": false,
98                                                     "editable": false,
99                                                     "mode": "local",
100                                                     "triggerAction": "all",
101                                                     "emptyText": "Select Module",
102                                                     "selectOnFocus": true,
103                                                     "|xns": "Roo.form",
104                                                     "items": [
105                                                         {
106                                                             "*prop": "store",
107                                                             "xtype": "SimpleStore",
108                                                             "|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   })()",
109                                                             "|fields": "['module']",
110                                                             "|xns": "Roo.data"
111                                                         }
112                                                     ]
113                                                 },
114                                                 {
115                                                     "xtype": "ComboBox",
116                                                     "listeners": {
117                                                         "|select": "function (combo, record, index)\n{\n  _this.grid.getDataSource().reload(); \n}",
118                                                         "|render": "function (_self)\n{\n  _this.langCombo=_self;\n}"
119                                                     },
120                                                     "valueField": "lang",
121                                                     "displayField": "ldisp",
122                                                     "width": 200,
123                                                     "typeAhead": false,
124                                                     "editable": false,
125                                                     "mode": "local",
126                                                     "triggerAction": "all",
127                                                     "emptyText": "Select Language",
128                                                     "selectOnFocus": true,
129                                                     "|xns": "Roo.form",
130                                                     "items": [
131                                                         {
132                                                             "xtype": "SimpleStore",
133                                                             "|xns": "Roo.data",
134                                                             "*prop": "store",
135                                                             "listeners": {},
136                                                             "|fields": "['lang', 'ldisp']",
137                                                             "|data": "[                                                [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ],                         [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ]                     ]"
138                                                         }
139                                                     ]
140                                                 }
141                                             ]
142                                         },
143                                         {
144                                             "xtype": "ColumnModel",
145                                             "header": "Name",
146                                             "width": 150,
147                                             "dataIndex": "colname",
148                                             "|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>';                                              }",
149                                             "listeners": {},
150                                             "|xns": "Roo.grid",
151                                             "*prop": "colModel[]"
152                                         },
153                                         {
154                                             "xtype": "ColumnModel",
155                                             "header": "Original",
156                                             "width": 300,
157                                             "dataIndex": "origtxt",
158                                             "|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>';                                              }",
159                                             "listeners": {},
160                                             "|xns": "Roo.grid",
161                                             "*prop": "colModel[]"
162                                         },
163                                         {
164                                             "*prop": "colModel[]",
165                                             "dataIndex": "reset_tx",
166                                             "header": "Reset",
167                                             "width": 50,
168                                             "xtype": "ColumnModel",
169                                             "|renderer": "function(v,x,r) {    \n    return '[x]';\n}",
170                                             "|xns": "Roo.grid"
171                                         },
172                                         {
173                                             "*prop": "colModel[]",
174                                             "dataIndex": "txt",
175                                             "header": "Translated (Click to Edit)",
176                                             "width": 150,
177                                             "xtype": "ColumnModel",
178                                             "|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>';                     }",
179                                             "|xns": "Roo.grid",
180                                             "items": [
181                                                 {
182                                                     "xtype": "GridEditor",
183                                                     "*prop": "editor",
184                                                     "|xns": "Roo.grid",
185                                                     "listeners": {},
186                                                     "items": [
187                                                         {
188                                                             "xtype": "TextField",
189                                                             "*prop": "field",
190                                                             "|xns": "Roo.form",
191                                                             "listeners": {}
192                                                         }
193                                                     ]
194                                                 }
195                                             ]
196                                         }
197                                     ]
198                                 }
199                             ]
200                         },
201                         {
202                             "listeners": {
203                                 "|activate": "function() {\n    _this.langpanel = this;\n    if (_this.langgrid) {\n        _this.langgrid.ds.load({});\n    }\n}"
204                             },
205                             "background": true,
206                             "fitContainer": true,
207                             "fitToframe": true,
208                             "region": "center",
209                             "tableName": "i18n",
210                             "title": "Languages and Countries",
211                             "xtype": "GridPanel",
212                             "|xns": "Roo",
213                             "items": [
214                                 {
215                                     "listeners": {
216                                         "|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}",
217                                         "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}",
218                                         "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            var tl = _this.langgridCombo.getValue();\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('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        } "
219                                     },
220                                     "*prop": "grid",
221                                     "autoExpandColumn": "lval",
222                                     "clicksToEdit": 1,
223                                     "loadMask": true,
224                                     "xtype": "EditorGrid",
225                                     "|xns": "Roo.grid",
226                                     "items": [
227                                         {
228                                             "listeners": {
229                                                 "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}"
230                                             },
231                                             "*prop": "dataSource",
232                                             "remoteSort": true,
233                                             "xtype": "Store",
234                                             "|sortInfo": "{ field : 'lkey', direction: 'ASC' }",
235                                             "|xns": "Roo.data",
236                                             "items": [
237                                                 {
238                                                     "*prop": "proxy",
239                                                     "xtype": "HttpProxy",
240                                                     "method": "GET",
241                                                     "|url": "baseURL + '/Roo/i18n.php'",
242                                                     "|xns": "Roo.data"
243                                                 },
244                                                 {
245                                                     "|xns": "Roo.data",
246                                                     "xtype": "JsonReader",
247                                                     "totalProperty": "total",
248                                                     "root": "data",
249                                                     "*prop": "reader",
250                                                     "id": "id",
251                                                     "|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]"
252                                                 }
253                                             ]
254                                         },
255                                         {
256                                             "*prop": "toolbar",
257                                             "xtype": "Toolbar",
258                                             "|xns": "Roo",
259                                             "items": [
260                                                 {
261                                                     "listeners": {
262                                                         "|render": "function (_self)\n{\n  _this.langtypeCombo = _self;\n}",
263                                                         "|select": "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}"
264                                                     },
265                                                     "displayField": "lval",
266                                                     "editable": false,
267                                                     "emptyText": "Select Translation of",
268                                                     "mode": "local",
269                                                     "selectOnFocus": true,
270                                                     "triggerAction": "all",
271                                                     "typeAhead": false,
272                                                     "valueField": "lkey",
273                                                     "width": 200,
274                                                     "xtype": "ComboBox",
275                                                     "|xns": "Roo.form",
276                                                     "items": [
277                                                         {
278                                                             "*prop": "store",
279                                                             "xtype": "SimpleStore",
280                                                             "|data": "[\n   [ 'l', 'Language Names' ],\n   [ 'c', 'Country Names' ],\n    [ 'm', 'Currency Names' ]\n]",
281                                                             "|fields": "['lkey','lval']",
282                                                             "|xns": "Roo.data"
283                                                         }
284                                                     ]
285                                                 },
286                                                 {
287                                                     "listeners": {
288                                                         "|select": "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}",
289                                                         "|render": "function (_self)\n{\n  _this.langgridCombo=_self;\n}"
290                                                     },
291                                                     "displayField": "ldisp",
292                                                     "editable": false,
293                                                     "emptyText": "Select Language",
294                                                     "mode": "local",
295                                                     "selectOnFocus": true,
296                                                     "triggerAction": "all",
297                                                     "typeAhead": false,
298                                                     "valueField": "lang",
299                                                     "width": 200,
300                                                     "xtype": "ComboBox",
301                                                     "|xns": "Roo.form",
302                                                     "items": [
303                                                         {
304                                                             "xtype": "SimpleStore",
305                                                             "|xns": "Roo.data",
306                                                             "*prop": "store",
307                                                             "listeners": {},
308                                                             "|fields": "['lang', 'ldisp']",
309                                                             "|data": "[                                                [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ],                         [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ]                     ]"
310                                                         }
311                                                     ]
312                                                 }
313                                             ]
314                                         },
315                                         {
316                                             "*prop": "colModel[]",
317                                             "dataIndex": "lkey",
318                                             "header": "Code",
319                                             "width": 50,
320                                             "xtype": "ColumnModel",
321                                             "|renderer": "function(v) { return String.format('{0}', v); }",
322                                             "|xns": "Roo.grid"
323                                         },
324                                         {
325                                             "*prop": "colModel[]",
326                                             "dataIndex": "lval_en",
327                                             "header": "English",
328                                             "width": 150,
329                                             "xtype": "ColumnModel",
330                                             "|renderer": "function(v) { return String.format('{0}', v); }",
331                                             "|xns": "Roo.grid"
332                                         },
333                                         {
334                                             "*prop": "colModel[]",
335                                             "dataIndex": "lval",
336                                             "header": "Translation",
337                                             "width": 200,
338                                             "xtype": "ColumnModel",
339                                             "|renderer": "function(v) { return String.format('{0}', v); }",
340                                             "|xns": "Roo.grid",
341                                             "items": [
342                                                 {
343                                                     "xtype": "GridEditor",
344                                                     "*prop": "editor",
345                                                     "|xns": "Roo.grid",
346                                                     "listeners": {},
347                                                     "items": [
348                                                         {
349                                                             "xtype": "TextField",
350                                                             "*prop": "field",
351                                                             "|xns": "Roo.form",
352                                                             "listeners": {}
353                                                         }
354                                                     ]
355                                                 }
356                                             ]
357                                         }
358                                     ]
359                                 }
360                             ]
361                         }
362                     ]
363                 }
364             ]
365         }
366     ],
367     "permname": "Admin.Translations",
368     "modOrder": "950"
369 }