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                                             "*prop": "dataSource",
217                                             "xtype": "Store",
218                                             "remoteSort": true,
219                                             "|sortInfo": "{ field : 'ltype', direction: 'ASC' }",
220                                             "|xns": "Roo.data",
221                                             "items": [
222                                                 {
223                                                     "*prop": "proxy",
224                                                     "xtype": "HttpProxy",
225                                                     "method": "GET",
226                                                     "|url": "baseURL + '/Roo/i18n.php'",
227                                                     "|xns": "Roo.data"
228                                                 },
229                                                 {
230                                                     "|xns": "Roo.data",
231                                                     "xtype": "JsonReader",
232                                                     "totalProperty": "total",
233                                                     "root": "data",
234                                                     "*prop": "reader",
235                                                     "id": "id",
236                                                     "|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]"
237                                                 }
238                                             ]
239                                         },
240                                         {
241                                             "*prop": "footer",
242                                             "xtype": "PagingToolbar",
243                                             "pageSize": 25,
244                                             "displayInfo": true,
245                                             "displayMsg": "Displaying i18n{0} - {1} of {2}",
246                                             "emptyMsg": "No i18n found",
247                                             "|xns": "Roo"
248                                         },
249                                         {
250                                             "*prop": "toolbar",
251                                             "xtype": "Toolbar",
252                                             "|xns": "Roo",
253                                             "items": [
254                                                 {
255                                                     "listeners": {
256                                                         "|render": "function (_self)\n{\n  _this.modCombo = _self;\n}",
257                                                         "|select": "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}"
258                                                     },
259                                                     "displayField": "module",
260                                                     "editable": false,
261                                                     "emptyText": "Select Module",
262                                                     "mode": "local",
263                                                     "selectOnFocus": true,
264                                                     "triggerAction": "all",
265                                                     "typeAhead": false,
266                                                     "valueField": "module",
267                                                     "width": 200,
268                                                     "xtype": "ComboBox",
269                                                     "|xns": "Roo.form",
270                                                     "items": [
271                                                         {
272                                                             "*prop": "store",
273                                                             "xtype": "SimpleStore",
274                                                             "|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   })()",
275                                                             "|fields": "['module']",
276                                                             "|xns": "Roo.data"
277                                                         }
278                                                     ]
279                                                 },
280                                                 {
281                                                     "listeners": {
282                                                         "|select": "function (combo, record, index)\n{\n  _this.langgrid.getDataSource().reload(); \n}",
283                                                         "|render": "function (_self)\n{\n  _this.langgridCombo=_self;\n}"
284                                                     },
285                                                     "displayField": "ldisp",
286                                                     "editable": false,
287                                                     "emptyText": "Select Language",
288                                                     "mode": "local",
289                                                     "selectOnFocus": true,
290                                                     "triggerAction": "all",
291                                                     "typeAhead": false,
292                                                     "valueField": "lang",
293                                                     "width": 200,
294                                                     "xtype": "ComboBox",
295                                                     "|xns": "Roo.form",
296                                                     "items": [
297                                                         {
298                                                             "xtype": "SimpleStore",
299                                                             "|xns": "Roo.data",
300                                                             "*prop": "store",
301                                                             "listeners": {},
302                                                             "|fields": "['lang', 'ldisp']",
303                                                             "|data": "[                                                [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ],                         [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ]                     ]"
304                                                         }
305                                                     ]
306                                                 }
307                                             ]
308                                         },
309                                         {
310                                             "xtype": "ColumnModel",
311                                             "header": "Id",
312                                             "width": 75,
313                                             "dataIndex": "id",
314                                             "|renderer": "function(v) { return String.format('{0}', v); }",
315                                             "|xns": "Roo.grid",
316                                             "*prop": "colModel[]"
317                                         },
318                                         {
319                                             "xtype": "ColumnModel",
320                                             "header": "Ltype",
321                                             "width": 200,
322                                             "dataIndex": "ltype",
323                                             "|renderer": "function(v) { return String.format('{0}', v); }",
324                                             "|xns": "Roo.grid",
325                                             "*prop": "colModel[]"
326                                         },
327                                         {
328                                             "xtype": "ColumnModel",
329                                             "header": "Lkey",
330                                             "width": 200,
331                                             "dataIndex": "lkey",
332                                             "|renderer": "function(v) { return String.format('{0}', v); }",
333                                             "|xns": "Roo.grid",
334                                             "*prop": "colModel[]"
335                                         },
336                                         {
337                                             "xtype": "ColumnModel",
338                                             "header": "Inlang",
339                                             "width": 200,
340                                             "dataIndex": "inlang",
341                                             "|renderer": "function(v) { return String.format('{0}', v); }",
342                                             "|xns": "Roo.grid",
343                                             "*prop": "colModel[]"
344                                         },
345                                         {
346                                             "xtype": "ColumnModel",
347                                             "header": "Lval",
348                                             "width": 200,
349                                             "dataIndex": "lval",
350                                             "|renderer": "function(v) { return String.format('{0}', v); }",
351                                             "|xns": "Roo.grid",
352                                             "*prop": "colModel[]"
353                                         }
354                                     ]
355                                 }
356                             ]
357                         }
358                     ]
359                 }
360             ]
361         }
362     ],
363     "permname": "Admin.Translations",
364     "modOrder": "950"
365 }