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        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 (self, ret, load, jsonData)\n{\n    Roo.MessageBox.alert(\"Error\", 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": "reset_tx",
165                                             "header": "Reset",
166                                             "width": 50,
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+'\";>' +r.get('tableid')+ ':' + v + '</div>';                                              }",
169                                             "|xns": "Roo.grid"
170                                         },
171                                         {
172                                             "*prop": "colModel[]",
173                                             "dataIndex": "txt",
174                                             "header": "Translated (Click to Edit)",
175                                             "width": 150,
176                                             "xtype": "ColumnModel",
177                                             "|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>';                     }",
178                                             "|xns": "Roo.grid",
179                                             "items": [
180                                                 {
181                                                     "xtype": "GridEditor",
182                                                     "*prop": "editor",
183                                                     "|xns": "Roo.grid",
184                                                     "listeners": {},
185                                                     "items": [
186                                                         {
187                                                             "xtype": "TextField",
188                                                             "*prop": "field",
189                                                             "|xns": "Roo.form",
190                                                             "listeners": {}
191                                                         }
192                                                     ]
193                                                 }
194                                             ]
195                                         }
196                                     ]
197                                 }
198                             ]
199                         },
200                         {
201                             "listeners": {
202                                 "|activate": "function() {\n    _this.langpanel = this;\n    if (_this.langgrid) {\n        _this.langgrid.ds.load({});\n    }\n}"
203                             },
204                             "background": true,
205                             "fitContainer": true,
206                             "fitToframe": true,
207                             "region": "center",
208                             "tableName": "i18n",
209                             "title": "Languages and Countries",
210                             "xtype": "GridPanel",
211                             "|xns": "Roo",
212                             "items": [
213                                 {
214                                     "listeners": {
215                                         "|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}",
216                                         "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}",
217                                         "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        } "
218                                     },
219                                     "*prop": "grid",
220                                     "autoExpandColumn": "lval",
221                                     "clicksToEdit": 1,
222                                     "loadMask": true,
223                                     "xtype": "EditorGrid",
224                                     "|xns": "Roo.grid",
225                                     "items": [
226                                         {
227                                             "listeners": {
228                                                 "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}"
229                                             },
230                                             "*prop": "dataSource",
231                                             "remoteSort": true,
232                                             "xtype": "Store",
233                                             "|sortInfo": "{ field : 'lkey', direction: 'ASC' }",
234                                             "|xns": "Roo.data",
235                                             "items": [
236                                                 {
237                                                     "*prop": "proxy",
238                                                     "xtype": "HttpProxy",
239                                                     "method": "GET",
240                                                     "|url": "baseURL + '/Roo/i18n.php'",
241                                                     "|xns": "Roo.data"
242                                                 },
243                                                 {
244                                                     "|xns": "Roo.data",
245                                                     "xtype": "JsonReader",
246                                                     "totalProperty": "total",
247                                                     "root": "data",
248                                                     "*prop": "reader",
249                                                     "id": "id",
250                                                     "|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]"
251                                                 }
252                                             ]
253                                         },
254                                         {
255                                             "*prop": "toolbar",
256                                             "xtype": "Toolbar",
257                                             "|xns": "Roo",
258                                             "items": [
259                                                 {
260                                                     "listeners": {
261                                                         "|render": "function (_self)\n{\n  _this.langtypeCombo = _self;\n}",
262                                                         "|select": "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}"
263                                                     },
264                                                     "displayField": "lval",
265                                                     "editable": false,
266                                                     "emptyText": "Select Translation of",
267                                                     "mode": "local",
268                                                     "selectOnFocus": true,
269                                                     "triggerAction": "all",
270                                                     "typeAhead": false,
271                                                     "valueField": "lkey",
272                                                     "width": 200,
273                                                     "xtype": "ComboBox",
274                                                     "|xns": "Roo.form",
275                                                     "items": [
276                                                         {
277                                                             "*prop": "store",
278                                                             "xtype": "SimpleStore",
279                                                             "|data": "[\n   [ 'l', 'Language Names' ],\n   [ 'c', 'Country Names' ],\n    [ 'm', 'Currency Names' ]\n]",
280                                                             "|fields": "['lkey','lval']",
281                                                             "|xns": "Roo.data"
282                                                         }
283                                                     ]
284                                                 },
285                                                 {
286                                                     "listeners": {
287                                                         "|select": "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}",
288                                                         "|render": "function (_self)\n{\n  _this.langgridCombo=_self;\n}"
289                                                     },
290                                                     "displayField": "ldisp",
291                                                     "editable": false,
292                                                     "emptyText": "Select Language",
293                                                     "mode": "local",
294                                                     "selectOnFocus": true,
295                                                     "triggerAction": "all",
296                                                     "typeAhead": false,
297                                                     "valueField": "lang",
298                                                     "width": 200,
299                                                     "xtype": "ComboBox",
300                                                     "|xns": "Roo.form",
301                                                     "items": [
302                                                         {
303                                                             "xtype": "SimpleStore",
304                                                             "|xns": "Roo.data",
305                                                             "*prop": "store",
306                                                             "listeners": {},
307                                                             "|fields": "['lang', 'ldisp']",
308                                                             "|data": "[                                                [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ],                         [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ]                     ]"
309                                                         }
310                                                     ]
311                                                 }
312                                             ]
313                                         },
314                                         {
315                                             "*prop": "colModel[]",
316                                             "dataIndex": "lkey",
317                                             "header": "Code",
318                                             "width": 50,
319                                             "xtype": "ColumnModel",
320                                             "|renderer": "function(v) { return String.format('{0}', v); }",
321                                             "|xns": "Roo.grid"
322                                         },
323                                         {
324                                             "*prop": "colModel[]",
325                                             "dataIndex": "lval_en",
326                                             "header": "English",
327                                             "width": 150,
328                                             "xtype": "ColumnModel",
329                                             "|renderer": "function(v) { return String.format('{0}', v); }",
330                                             "|xns": "Roo.grid"
331                                         },
332                                         {
333                                             "*prop": "colModel[]",
334                                             "dataIndex": "lval",
335                                             "header": "Translation",
336                                             "width": 200,
337                                             "xtype": "ColumnModel",
338                                             "|renderer": "function(v) { return String.format('{0}', v); }",
339                                             "|xns": "Roo.grid",
340                                             "items": [
341                                                 {
342                                                     "xtype": "GridEditor",
343                                                     "*prop": "editor",
344                                                     "|xns": "Roo.grid",
345                                                     "listeners": {},
346                                                     "items": [
347                                                         {
348                                                             "xtype": "TextField",
349                                                             "*prop": "field",
350                                                             "|xns": "Roo.form",
351                                                             "listeners": {}
352                                                         }
353                                                     ]
354                                                 }
355                                             ]
356                                         }
357                                     ]
358                                 }
359                             ]
360                         }
361                     ]
362                 }
363             ]
364         }
365     ],
366     "permname": "Admin.Translations",
367     "modOrder": "950"
368 }