Pman.Tab.AdminTranslations.bjs
[Pman.Admin] / Pman.Tab.AdminTranslations.bjs
1 {
2     "id": "roo-file-275",
3     "name": "Pman.Tab.AdminTranslations",
4     "parent": "Pman.Tab.Admin",
5     "title": "Admin - Translations",
6     "path": "/home/edward/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 Pman.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                Roo.MessageBox.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    rec = this.ds.getAt(rowIndex);\n    \n      var g = _this.grid;\n \n    new Pman.Request({\n        url : baseURL + '/Admin/Translations.php',\n        method: 'POST',\n        params : {\n            id : rec.get('id'),\n            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            rec.set('txt', '');\n        },\n        failure : function()\n        {\n            Roo.MessageBox.alert(\"Error\", \"There was a problem saving the data - try reloading\");\n           // g.getView().el.unmask();\n        }\n        \n    });\n       \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                                                     "|xns": "Roo.Toolbar",
143                                                     "xtype": "Fill"
144                                                 },
145                                                 {
146                                                     "listeners": {
147                                                         "click": "function (_self, e)\n{\n    new Pman.Download({\n        grid: _this.grid\n    \n    });\n}"
148                                                     },
149                                                     "text": "Download",
150                                                     "xtype": "Button",
151                                                     "|xns": "Roo.Toolbar"
152                                                 }
153                                             ]
154                                         },
155                                         {
156                                             "xtype": "ColumnModel",
157                                             "header": "Name",
158                                             "width": 150,
159                                             "dataIndex": "colname",
160                                             "|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>';                                              }",
161                                             "listeners": {},
162                                             "|xns": "Roo.grid",
163                                             "*prop": "colModel[]"
164                                         },
165                                         {
166                                             "xtype": "ColumnModel",
167                                             "header": "Original",
168                                             "width": 300,
169                                             "dataIndex": "origtxt",
170                                             "|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>';                                              }",
171                                             "listeners": {},
172                                             "|xns": "Roo.grid",
173                                             "*prop": "colModel[]"
174                                         },
175                                         {
176                                             "*prop": "colModel[]",
177                                             "dataIndex": "reset_tx",
178                                             "header": "Reset",
179                                             "width": 50,
180                                             "xtype": "ColumnModel",
181                                             "|renderer": "function(v,x,r) {    \n    return  '<img src=\"' + rootURL + '/Pman/templates/images/edit-clear.gif' + '\" width=\"16\" height=\"16\">';\n}",
182                                             "|xns": "Roo.grid"
183                                         },
184                                         {
185                                             "*prop": "colModel[]",
186                                             "dataIndex": "txt",
187                                             "header": "Translated (Click to Edit)",
188                                             "width": 150,
189                                             "xtype": "ColumnModel",
190                                             "|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>';                     }",
191                                             "|xns": "Roo.grid",
192                                             "items": [
193                                                 {
194                                                     "xtype": "GridEditor",
195                                                     "*prop": "editor",
196                                                     "|xns": "Roo.grid",
197                                                     "listeners": {},
198                                                     "items": [
199                                                         {
200                                                             "xtype": "TextField",
201                                                             "*prop": "field",
202                                                             "|xns": "Roo.form",
203                                                             "listeners": {}
204                                                         }
205                                                     ]
206                                                 }
207                                             ]
208                                         }
209                                     ]
210                                 }
211                             ]
212                         },
213                         {
214                             "listeners": {
215                                 "|activate": "function() {\n    _this.langpanel = this;\n    if (_this.langgrid) {\n        _this.langgrid.ds.load({});\n    }\n}"
216                             },
217                             "background": true,
218                             "fitContainer": true,
219                             "fitToframe": true,
220                             "region": "center",
221                             "tableName": "i18n",
222                             "title": "Languages and Countries",
223                             "xtype": "GridPanel",
224                             "|xns": "Roo",
225                             "items": [
226                                 {
227                                     "listeners": {
228                                         "|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}",
229                                         "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}",
230                                         "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        } ",
231                                         "cellclick": "function (_self, rowIndex, columnIndex, e)\n{\n    if(_this.langgrid.colModel.getDataIndex(columnIndex) !== 'is_active'){\n        return;\n    }\n    \n    Roo.log('click');\n}"
232                                     },
233                                     "*prop": "grid",
234                                     "autoExpandColumn": "lval",
235                                     "clicksToEdit": 1,
236                                     "loadMask": true,
237                                     "xtype": "EditorGrid",
238                                     "|xns": "Roo.grid",
239                                     "items": [
240                                         {
241                                             "listeners": {
242                                                 "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}"
243                                             },
244                                             "*prop": "dataSource",
245                                             "remoteSort": true,
246                                             "xtype": "Store",
247                                             "|sortInfo": "{ field : 'lkey', direction: 'ASC' }",
248                                             "|xns": "Roo.data",
249                                             "items": [
250                                                 {
251                                                     "*prop": "proxy",
252                                                     "xtype": "HttpProxy",
253                                                     "method": "GET",
254                                                     "|url": "baseURL + '/Roo/i18n.php'",
255                                                     "|xns": "Roo.data"
256                                                 },
257                                                 {
258                                                     "|xns": "Roo.data",
259                                                     "xtype": "JsonReader",
260                                                     "totalProperty": "total",
261                                                     "root": "data",
262                                                     "*prop": "reader",
263                                                     "id": "id",
264                                                     "|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]"
265                                                 }
266                                             ]
267                                         },
268                                         {
269                                             "*prop": "toolbar",
270                                             "xtype": "Toolbar",
271                                             "|xns": "Roo",
272                                             "items": [
273                                                 {
274                                                     "listeners": {
275                                                         "|render": "function (_self)\n{\n  _this.langtypeCombo = _self;\n}",
276                                                         "|select": "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}"
277                                                     },
278                                                     "displayField": "lval",
279                                                     "editable": false,
280                                                     "emptyText": "Select Translation of",
281                                                     "mode": "local",
282                                                     "selectOnFocus": true,
283                                                     "triggerAction": "all",
284                                                     "typeAhead": false,
285                                                     "valueField": "lkey",
286                                                     "width": 200,
287                                                     "xtype": "ComboBox",
288                                                     "|xns": "Roo.form",
289                                                     "items": [
290                                                         {
291                                                             "*prop": "store",
292                                                             "xtype": "SimpleStore",
293                                                             "|data": "[\n   [ 'l', 'Language Names' ],\n   [ 'c', 'Country Names' ],\n    [ 'm', 'Currency Names' ]\n]",
294                                                             "|fields": "['lkey','lval']",
295                                                             "|xns": "Roo.data"
296                                                         }
297                                                     ]
298                                                 },
299                                                 {
300                                                     "listeners": {
301                                                         "|select": "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}",
302                                                         "|render": "function (_self)\n{\n  _this.langgridCombo=_self;\n}"
303                                                     },
304                                                     "displayField": "ldisp",
305                                                     "editable": false,
306                                                     "emptyText": "Select Language",
307                                                     "mode": "local",
308                                                     "selectOnFocus": true,
309                                                     "triggerAction": "all",
310                                                     "typeAhead": false,
311                                                     "valueField": "lang",
312                                                     "width": 200,
313                                                     "xtype": "ComboBox",
314                                                     "|xns": "Roo.form",
315                                                     "items": [
316                                                         {
317                                                             "xtype": "SimpleStore",
318                                                             "|xns": "Roo.data",
319                                                             "*prop": "store",
320                                                             "listeners": {},
321                                                             "|fields": "['lang', 'ldisp']",
322                                                             "|data": "[                                                [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ],                         [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ]                     ]"
323                                                         }
324                                                     ]
325                                                 }
326                                             ]
327                                         },
328                                         {
329                                             "*prop": "colModel[]",
330                                             "dataIndex": "lkey",
331                                             "header": "Code",
332                                             "width": 50,
333                                             "xtype": "ColumnModel",
334                                             "|renderer": "function(v) { return String.format('{0}', v); }",
335                                             "|xns": "Roo.grid"
336                                         },
337                                         {
338                                             "*prop": "colModel[]",
339                                             "dataIndex": "lval_en",
340                                             "header": "English",
341                                             "width": 150,
342                                             "xtype": "ColumnModel",
343                                             "|renderer": "function(v) { return String.format('{0}', v); }",
344                                             "|xns": "Roo.grid"
345                                         },
346                                         {
347                                             "*prop": "colModel[]",
348                                             "dataIndex": "lval",
349                                             "header": "Translation",
350                                             "width": 200,
351                                             "xtype": "ColumnModel",
352                                             "|renderer": "function(v) { return String.format('{0}', v); }",
353                                             "|xns": "Roo.grid",
354                                             "items": [
355                                                 {
356                                                     "xtype": "GridEditor",
357                                                     "*prop": "editor",
358                                                     "|xns": "Roo.grid",
359                                                     "listeners": {},
360                                                     "items": [
361                                                         {
362                                                             "xtype": "TextField",
363                                                             "*prop": "field",
364                                                             "|xns": "Roo.form",
365                                                             "listeners": {}
366                                                         }
367                                                     ]
368                                                 }
369                                             ]
370                                         },
371                                         {
372                                             "*prop": "colModel[]",
373                                             "dataIndex": "is_active",
374                                             "header": "Active?",
375                                             "width": 150,
376                                             "xtype": "ColumnModel",
377                                             "|renderer": "function(v,x,r) { \n\n    return '<img class=\"x-grid-check-icon' + (v*1 ? '-checked' : '')  + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n                                        \n    \n}",
378                                             "|xns": "Roo.grid"
379                                         }
380                                     ]
381                                 }
382                             ]
383                         }
384                     ]
385                 }
386             ]
387         }
388     ],
389     "permname": "Admin.Translations",
390     "modOrder": "950"
391 }