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                                                             "xtype": "SimpleStore",
105                                                             "|xns": "Roo.data",
106                                                             "*prop": "store",
107                                                             "listeners": {},
108                                                             "|fields": "['module']",
109                                                             "|data": "(function() {             var modlist = [];             Roo.each( AppModules.split(','), function(mod) {            \n         modlist.push( [ mod ] );             });             return modlist;         })()"
110                                                         }
111                                                     ]
112                                                 },
113                                                 {
114                                                     "xtype": "ComboBox",
115                                                     "listeners": {
116                                                         "|select": "function (combo, record, index)\n{\n  _this.grid.getDataSource().reload(); \n}",
117                                                         "|render": "function (_self)\n{\n  _this.langCombo=_self;\n}"
118                                                     },
119                                                     "valueField": "lang",
120                                                     "displayField": "ldisp",
121                                                     "width": 200,
122                                                     "typeAhead": false,
123                                                     "editable": false,
124                                                     "mode": "local",
125                                                     "triggerAction": "all",
126                                                     "emptyText": "Select Language",
127                                                     "selectOnFocus": true,
128                                                     "|xns": "Roo.form",
129                                                     "items": [
130                                                         {
131                                                             "xtype": "SimpleStore",
132                                                             "|xns": "Roo.data",
133                                                             "*prop": "store",
134                                                             "listeners": {},
135                                                             "|fields": "['lang', 'ldisp']",
136                                                             "|data": "[                                                [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ],                         [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ]                     ]"
137                                                         }
138                                                     ]
139                                                 }
140                                             ]
141                                         },
142                                         {
143                                             "xtype": "ColumnModel",
144                                             "header": "Name",
145                                             "width": 150,
146                                             "dataIndex": "colname",
147                                             "|renderer": "function(v,x,r) {                         var c = '#666';                         if (r.get('updated') < r.get('origupdated')) {                             c = 'red';                         }                                                  return '<div style=\"color:'+c+'\";>' +r.get('tableid')+ ':' + v + '</div>';                                              }",
148                                             "listeners": {},
149                                             "|xns": "Roo.grid",
150                                             "*prop": "colModel[]"
151                                         },
152                                         {
153                                             "xtype": "ColumnModel",
154                                             "header": "Original",
155                                             "width": 300,
156                                             "dataIndex": "origtxt",
157                                             "|renderer": "function(v,x,r) {                         var c = '#666';                         if (r.get('updated') < r.get('origupdated')) {                             c = 'red';                         }                         return '<div style=\"color:' + c+ '\">' +                                  Ext.util.Format.htmlEncode(v) + '</div>';                                              }",
158                                             "listeners": {},
159                                             "|xns": "Roo.grid",
160                                             "*prop": "colModel[]"
161                                         },
162                                         {
163                                             "xtype": "ColumnModel",
164                                             "header": "Translated (Click to Edit)",
165                                             "width": 150,
166                                             "dataIndex": "txt",
167                                             "|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>';                     }",
168                                             "listeners": {},
169                                             "|xns": "Roo.grid",
170                                             "*prop": "colModel[]",
171                                             "items": [
172                                                 {
173                                                     "xtype": "GridEditor",
174                                                     "*prop": "editor",
175                                                     "|xns": "Roo.grid",
176                                                     "listeners": {},
177                                                     "items": [
178                                                         {
179                                                             "xtype": "TextField",
180                                                             "*prop": "field",
181                                                             "|xns": "Roo.form",
182                                                             "listeners": {}
183                                                         }
184                                                     ]
185                                                 }
186                                             ]
187                                         }
188                                     ]
189                                 }
190                             ]
191                         }
192                     ]
193                 }
194             ]
195         }
196     ],
197     "permname": "Admin.Translations",
198     "modOrder": "950"
199 }