Pman.Tab.AdminTranslations.bjs
[Pman.Admin] / Pman.Tab.AdminTranslations.bjs
1 {
2     "id": "roo-file-56",
3     "name": "Pman.Tab.AdminTranslations",
4     "parent": "Pman.Tab.Admin",
5     "title": "Admin - Translations",
6     "path": "/home/alan/gitlive/Pman.Admin/Pman.Tab.AdminTranslations.bjs",
7     "items": [
8         {
9             "region": "center",
10             "title": "Translate App",
11             "xtype": "NestedLayoutPanel",
12             "|xns": "Roo",
13             "items": [
14                 {
15                     "|xns": "Roo",
16                     "xtype": "BorderLayout",
17                     "*prop": "layout",
18                     "items": [
19                         {
20                             "*prop": "center",
21                             "alwaysShowTabs": true,
22                             "tabPosition": "top",
23                             "xtype": "LayoutRegion",
24                             "|xns": "Roo"
25                         },
26                         {
27                             "listeners": {
28                                 "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n       _this.grid.getDataSource().reload(); \n    }\n}"
29                             },
30                             "background": true,
31                             "fitContainer": true,
32                             "fitToframe": true,
33                             "region": "center",
34                             "title": "Text in interface",
35                             "xtype": "GridPanel",
36                             "|xns": "Roo",
37                             "items": [
38                                 {
39                                     "*prop": "grid",
40                                     "xtype": "EditorGrid",
41                                     "autoExpandColumn": "txt",
42                                     "loadMask": true,
43                                     "listeners": {
44                                         "|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}",
45                                         "|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                } ",
46                                         "|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}"
47                                     },
48                                     "clicksToEdit": 1,
49                                     "|xns": "Roo.grid",
50                                     "items": [
51                                         {
52                                             "*prop": "dataSource",
53                                             "xtype": "Store",
54                                             "|reader": "Pman.Readers.Category",
55                                             "listeners": {
56                                                 "|beforeload": "function (_self, opts)\n{\n\n                        if (!_this.langCombo || !_this.langCombo.getValue().length) {\n                            return false;\n                        }\n                        if (!_this.modCombo || !_this.modCombo.getValue().length) {\n                            return false;\n                        }\n                        opts.params = {\n                            lang :  _this.langCombo.getValue(),\n                            module :  _this.modCombo.getValue()\n                        };\n}"
57                                             },
58                                             "|xns": "Roo.data",
59                                             "items": [
60                                                 {
61                                                     "*prop": "proxy",
62                                                     "xtype": "HttpProxy",
63                                                     "method": "GET",
64                                                     "|url": "baseURL + '/Admin/Translations.php'",
65                                                     "listeners": {},
66                                                     "|xns": "Roo.data"
67                                                 },
68                                                 {
69                                                     "xtype": "JsonReader",
70                                                     "|xns": "Roo.data",
71                                                     "*prop": "reader",
72                                                     "root": "data",
73                                                     "totalProperty": "total",
74                                                     "id": "id",
75                                                     "|fields": "[                    'id',             'tablename',             'tableid',             'colname',             'txt',             'lang',             { name:'updated', type:'date', dateFormat: 'Y-m-d H:i:s' },             { name:'origupdated', type:'date', dateFormat: 'Y-m-d H:i:s' },             'origtxt',             'msum',             'suggest'                  ]",
76                                                     "listeners": {}
77                                                 }
78                                             ]
79                                         },
80                                         {
81                                             "*prop": "toolbar",
82                                             "xtype": "Toolbar",
83                                             "listeners": {},
84                                             "|xns": "Roo",
85                                             "items": [
86                                                 {
87                                                     "xtype": "ComboBox",
88                                                     "listeners": {
89                                                         "|render": "function (_self)\n{\n  _this.modCombo = _self;\n}",
90                                                         "|select": "function (combo, record, index)\n{\n  _this.grid.getDataSource().reload(); \n}"
91                                                     },
92                                                     "valueField": "module",
93                                                     "displayField": "module",
94                                                     "width": 200,
95                                                     "typeAhead": false,
96                                                     "editable": false,
97                                                     "mode": "local",
98                                                     "triggerAction": "all",
99                                                     "emptyText": "Select Module",
100                                                     "selectOnFocus": true,
101                                                     "|xns": "Roo.form",
102                                                     "items": [
103                                                         {
104                                                             "*prop": "store",
105                                                             "xtype": "SimpleStore",
106                                                             "|data": "(function() {             \n        var modlist = [];             \n        AppModules = typeof(AppModules) == 'undefined' ? '' : AppModules;\n        Roo.each( AppModules.split(','), function(mod) {            \n                 modlist.push( [ mod ] );            \n      });             \n      return modlist;\n   })()",
107                                                             "|fields": "['module']",
108                                                             "|xns": "Roo.data"
109                                                         }
110                                                     ]
111                                                 },
112                                                 {
113                                                     "xtype": "ComboBox",
114                                                     "listeners": {
115                                                         "|select": "function (combo, record, index)\n{\n  _this.grid.getDataSource().reload(); \n}",
116                                                         "|render": "function (_self)\n{\n  _this.langCombo=_self;\n}"
117                                                     },
118                                                     "valueField": "lang",
119                                                     "displayField": "ldisp",
120                                                     "width": 200,
121                                                     "typeAhead": false,
122                                                     "editable": false,
123                                                     "mode": "local",
124                                                     "triggerAction": "all",
125                                                     "emptyText": "Select Language",
126                                                     "selectOnFocus": true,
127                                                     "|xns": "Roo.form",
128                                                     "items": [
129                                                         {
130                                                             "xtype": "SimpleStore",
131                                                             "|xns": "Roo.data",
132                                                             "*prop": "store",
133                                                             "listeners": {},
134                                                             "|fields": "['lang', 'ldisp']",
135                                                             "|data": "[                                                [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ],                         [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ]                     ]"
136                                                         }
137                                                     ]
138                                                 }
139                                             ]
140                                         },
141                                         {
142                                             "xtype": "ColumnModel",
143                                             "header": "Name",
144                                             "width": 150,
145                                             "dataIndex": "colname",
146                                             "|renderer": "function(v,x,r) {                         var c = '#666';                         if (r.get('updated') < r.get('origupdated')) {                             c = 'red';                         }                                                  return '<div style=\"color:'+c+'\";>' +r.get('tableid')+ ':' + v + '</div>';                                              }",
147                                             "listeners": {},
148                                             "|xns": "Roo.grid",
149                                             "*prop": "colModel[]"
150                                         },
151                                         {
152                                             "xtype": "ColumnModel",
153                                             "header": "Original",
154                                             "width": 300,
155                                             "dataIndex": "origtxt",
156                                             "|renderer": "function(v,x,r) {                         var c = '#666';                         if (r.get('updated') < r.get('origupdated')) {                             c = 'red';                         }                         return '<div style=\"color:' + c+ '\">' +                                  Ext.util.Format.htmlEncode(v) + '</div>';                                              }",
157                                             "listeners": {},
158                                             "|xns": "Roo.grid",
159                                             "*prop": "colModel[]"
160                                         },
161                                         {
162                                             "xtype": "ColumnModel",
163                                             "header": "Translated (Click to Edit)",
164                                             "width": 150,
165                                             "dataIndex": "txt",
166                                             "|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>';                     }",
167                                             "listeners": {},
168                                             "|xns": "Roo.grid",
169                                             "*prop": "colModel[]",
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": "i18n",
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                                         "|rowdblclick": "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {\n        _this.grid.footer.onClick('first');\n    }); \n}\n"
208                                     },
209                                     "*prop": "grid",
210                                     "autoExpandColumn": "ltype",
211                                     "loadMask": true,
212                                     "xtype": "Grid",
213                                     "|xns": "Roo.grid",
214                                     "items": [
215                                         {
216                                             "listeners": {
217                                                 "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.langCombo.getValue();\n   \n}"
218                                             },
219                                             "*prop": "dataSource",
220                                             "remoteSort": true,
221                                             "xtype": "Store",
222                                             "|sortInfo": "{ field : 'ltype', direction: 'ASC' }",
223                                             "|xns": "Roo.data",
224                                             "items": [
225                                                 {
226                                                     "*prop": "proxy",
227                                                     "xtype": "HttpProxy",
228                                                     "method": "GET",
229                                                     "|url": "baseURL + '/Roo/i18n.php'",
230                                                     "|xns": "Roo.data"
231                                                 },
232                                                 {
233                                                     "|xns": "Roo.data",
234                                                     "xtype": "JsonReader",
235                                                     "totalProperty": "total",
236                                                     "root": "data",
237                                                     "*prop": "reader",
238                                                     "id": "id",
239                                                     "|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]"
240                                                 }
241                                             ]
242                                         },
243                                         {
244                                             "*prop": "footer",
245                                             "xtype": "PagingToolbar",
246                                             "pageSize": 25,
247                                             "displayInfo": true,
248                                             "displayMsg": "Displaying i18n{0} - {1} of {2}",
249                                             "emptyMsg": "No i18n found",
250                                             "|xns": "Roo"
251                                         },
252                                         {
253                                             "*prop": "toolbar",
254                                             "xtype": "Toolbar",
255                                             "|xns": "Roo",
256                                             "items": [
257                                                 {
258                                                     "listeners": {
259                                                         "|render": "function (_self)\n{\n  _this.langtypeCombo = _self;\n}",
260                                                         "|select": "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}"
261                                                     },
262                                                     "displayField": "module",
263                                                     "editable": false,
264                                                     "emptyText": "Select Module",
265                                                     "mode": "local",
266                                                     "selectOnFocus": true,
267                                                     "triggerAction": "all",
268                                                     "typeAhead": false,
269                                                     "valueField": "module",
270                                                     "width": 200,
271                                                     "xtype": "ComboBox",
272                                                     "|xns": "Roo.form",
273                                                     "items": [
274                                                         {
275                                                             "*prop": "store",
276                                                             "xtype": "SimpleStore",
277                                                             "|data": "[\n   [ 'l', 'Language Names' ]\n   [ 'c', 'Country Names' ]\n]",
278                                                             "|fields": "['module']",
279                                                             "|xns": "Roo.data"
280                                                         }
281                                                     ]
282                                                 },
283                                                 {
284                                                     "listeners": {
285                                                         "|select": "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}",
286                                                         "|render": "function (_self)\n{\n  _this.langgridCombo=_self;\n}"
287                                                     },
288                                                     "displayField": "ldisp",
289                                                     "editable": false,
290                                                     "emptyText": "Select Language",
291                                                     "mode": "local",
292                                                     "selectOnFocus": true,
293                                                     "triggerAction": "all",
294                                                     "typeAhead": false,
295                                                     "valueField": "lang",
296                                                     "width": 200,
297                                                     "xtype": "ComboBox",
298                                                     "|xns": "Roo.form",
299                                                     "items": [
300                                                         {
301                                                             "xtype": "SimpleStore",
302                                                             "|xns": "Roo.data",
303                                                             "*prop": "store",
304                                                             "listeners": {},
305                                                             "|fields": "['lang', 'ldisp']",
306                                                             "|data": "[                                                [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ],                         [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ]                     ]"
307                                                         }
308                                                     ]
309                                                 }
310                                             ]
311                                         },
312                                         {
313                                             "xtype": "ColumnModel",
314                                             "header": "Id",
315                                             "width": 75,
316                                             "dataIndex": "id",
317                                             "|renderer": "function(v) { return String.format('{0}', v); }",
318                                             "|xns": "Roo.grid",
319                                             "*prop": "colModel[]"
320                                         },
321                                         {
322                                             "xtype": "ColumnModel",
323                                             "header": "Ltype",
324                                             "width": 200,
325                                             "dataIndex": "ltype",
326                                             "|renderer": "function(v) { return String.format('{0}', v); }",
327                                             "|xns": "Roo.grid",
328                                             "*prop": "colModel[]"
329                                         },
330                                         {
331                                             "xtype": "ColumnModel",
332                                             "header": "Lkey",
333                                             "width": 200,
334                                             "dataIndex": "lkey",
335                                             "|renderer": "function(v) { return String.format('{0}', v); }",
336                                             "|xns": "Roo.grid",
337                                             "*prop": "colModel[]"
338                                         },
339                                         {
340                                             "xtype": "ColumnModel",
341                                             "header": "Inlang",
342                                             "width": 200,
343                                             "dataIndex": "inlang",
344                                             "|renderer": "function(v) { return String.format('{0}', v); }",
345                                             "|xns": "Roo.grid",
346                                             "*prop": "colModel[]"
347                                         },
348                                         {
349                                             "xtype": "ColumnModel",
350                                             "header": "Lval",
351                                             "width": 200,
352                                             "dataIndex": "lval",
353                                             "|renderer": "function(v) { return String.format('{0}', v); }",
354                                             "|xns": "Roo.grid",
355                                             "*prop": "colModel[]"
356                                         }
357                                     ]
358                                 }
359                             ]
360                         }
361                     ]
362                 }
363             ]
364         }
365     ],
366     "permname": "Admin.Translations",
367     "modOrder": "950"
368 }