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