Pman.Tab.CmsTranslateTemplates.bjs
[Pman.Cms] / Pman.Tab.CmsTranslateTemplates.bjs
1 {
2     "id": "roo-file-243",
3     "name": "Pman.Tab.CmsTranslateTemplates",
4     "parent": "Pman.Tab.Cms",
5     "title": "Pman.Tab.CmsTranslateTemplates",
6     "path": "/home/chris/gitlive/Pman.Cms/Pman.Tab.CmsTranslateTemplates.bjs",
7     "items": [
8         {
9             "region": "center",
10             "title": "Translate Templates",
11             "xtype": "NestedLayoutPanel",
12             "|xns": "Roo",
13             "items": [
14                 {
15                     "|xns": "Roo",
16                     "xtype": "BorderLayout",
17                     "*prop": "layout",
18                     "items": [
19                         {
20                             "*prop": "west",
21                             "split": true,
22                             "width": 200,
23                             "xtype": "LayoutRegion",
24                             "|xns": "Roo"
25                         },
26                         {
27                             "*prop": "center",
28                             "xtype": "LayoutRegion",
29                             "|xns": "Roo"
30                         },
31                         {
32                             "listeners": {
33                                 "render": "function (_self)\n{\n    _this.treepanel = _self;\n}"
34                             },
35                             "region": "west",
36                             "xtype": "TreePanel",
37                             "|xns": "Roo",
38                             "items": [
39                                 {
40                                     "|xns": "Roo",
41                                     "xtype": "Toolbar",
42                                     "*prop": "toolbar",
43                                     "items": [
44                                         {
45                                             "listeners": {
46                                                 "click": "function (_self, e)\n{\n    Pman.Dialog.CmsLanguagePick.show( {  }, function(lang) {\n        \n        new Pman.Request({\n            url : baseURL + '/Roo/cms_templatestr',\n            method : 'GET',\n            params : {\n               \n                lang : lang\n            }, \n            success : function()\n            {\n\n                _this.treepanel.tree.getRootNode().reload();\n            \n            }\n        });\n    \n    });\n    \n}"
47                                             },
48                                             "text": "New",
49                                             "xtype": "Button",
50                                             "|xns": "Roo.Toolbar"
51                                         },
52                                         {
53                                             "listeners": {
54                                                 "click": "function (_self, e)\n{\n    var tree = _this.treepanel.tree;\n    var sn  = tree.getSelectionModel().getSelectedNode();\n    if (!sn || sn.id.split('/').length > 1) {\n        Roo.MessageBox.alert(\"Error\", \"Select a language\");\n        return;\n    }\n    \n     Roo.MessageBox.confirm(\"Confirm\", \"Are sure you want to delete the language\", function (v){\n            if (v != 'yes') {\n                return;\n            }\n            Roo.MessageBox.alert(\"Not yet\", \"not done yet\");\n            return;\n            Roo.Ajax.request({\n                url : baseURL + '/Roo/cms_language.php',\n                method: 'POST',\n                params : {\n                    _delete : _t.selectedNode.id \n                },\n                success : function()\n                {\n                   _this.treepanel.tree.getRootNode().reload();\n                    //g.getDataSource().reload();\n                },\n                failure : function()\n                {\n                    Roo.MessageBox.alert(\"Error\", \n                        \"There was a problem saving the data - try reloading\");\n                    \n                }\n                \n            });\n            \n            \n            \n            \n        });\n}"
55                                             },
56                                             "text": "Delete",
57                                             "xtype": "Button",
58                                             "|xns": "Roo.Toolbar"
59                                         },
60                                         {
61                                             "listeners": {
62                                                 "click": "function (_self, e)\n{\n    _this.treepanel.tree.getRootNode().reload();\n    \n}"
63                                             },
64                                             "text": "Reload",
65                                             "xtype": "Button",
66                                             "|xns": "Roo.Toolbar"
67                                         }
68                                     ]
69                                 },
70                                 {
71                                     "*prop": "tree",
72                                     "containerScroll": false,
73                                     "rootVisible": true,
74                                     "xtype": "TreePanel",
75                                     "|xns": "Roo.tree",
76                                     "items": [
77                                         {
78                                             "listeners": {
79                                                 "beforeload": "function (This, node, callback)\n{\n    // set some params.\n    Roo.log(node);\n    this.baseParams._tree = 1;\n    \n    //this.baseParams.category = node.attributes.category;\n}",
80                                                 "loadexception": "function (This, node, response)\n{\n    Roo.MessageBox.alert(\"Error\", \"Problem loading tree\");\n}"
81                                             },
82                                             "*prop": "loader",
83                                             "requestMethod": "GET",
84                                             "xtype": "TreeLoader",
85                                             "|baseParams": "{ _tree : 1 }",
86                                             "|dataUrl": "baseURL + '/Roo/cms_templatestr'",
87                                             "|xns": "Roo.tree"
88                                         },
89                                         {
90                                             "*prop": "root",
91                                             "id": "transtree",
92                                             "text": "Translations",
93                                             "xtype": "AsyncTreeNode",
94                                             "|xns": "Roo.tree"
95                                         },
96                                         {
97                                             "listeners": {
98                                                 "selectionchange": "function (_self, node)\n{\n    Roo.log(node);\n    \n    //if (node.id.split('/').length < 2) {\n    //    return;\n   // }\n    (function() {\n        _this.grid.footer.onClick('first');\n    }).defer(100);\n    \n}"
99                                             },
100                                             "*prop": "selModel",
101                                             "xtype": "DefaultSelectionModel",
102                                             "|xns": "Roo.tree"
103                                         }
104                                     ]
105                                 }
106                             ]
107                         },
108                         {
109                             "listeners": {
110                                 "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
111                             },
112                             "background": false,
113                             "fitContainer": true,
114                             "fitToframe": true,
115                             "region": "center",
116                             "tableName": "Page",
117                             "title": "Page",
118                             "xtype": "GridPanel",
119                             "|xns": "Roo",
120                             "items": [
121                                 {
122                                     "listeners": {
123                                         "|render": "function() \n{\n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.panel.active) {\n        this.footer.onClick('first');\n      // this.ds.onc.onClick('first');\n    }\n}",
124                                         "|rowdblclick": "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\n        _this.grid.footer.onClick('first');\n    }); \n}\n",
125                                         "beforeedit": "function (e)\n{   \n    if (e.record.data.src_id_txt.indexOf('<') > -1) {\n       // console.log(\"HTML EDITOR!!\");\n        Pman.Dialog.CmsTranslateEditor.show(e.record);\n        return false;\n    }\n    \n    var str=e.record.data.src_id_txt;\n    var patt=/{(.*?)}/g;\n    \n    if(patt.test(str)){\n        e.cancel = true;\n        Roo.MessageBox.prompt('WARNING', 'This text is with {TEMPLATE VARIABLE}, PLEASE BE CAREFUL EDITING. What\\'s change? '+str, function(btn, text){\n            if (btn == 'ok'){\n                e.value = text;\n                e.record.set('txt', text);\n                e.record.commit();\n            }\n        });\n        return;\n    }\n\n    if (e.record.data.txt.replace(/\\s+/, '').length) {\n        return true;\n    }\n    \n    var tl = _this.treepanel.tree.getSelectionModel().getSelectedNode().parentNode.attributes.id;\n    // mapping?\n    \n    tl = (tl == 'zh_HK') ? 'zh-TW' : tl;\n    \n    if (tl == 'en' && !e.value.length) {\n\n        e.value = e.record.data.src_id_txt;\n        e.record.set('txt', e.record.data.src_id_txt);\n        return true;\n    }\n    \n    Pman.GoogleTranslate(e.record.data.src_id_txt, \"en\", tl, function(result) {\n       // Roo.log(result);\n        _this.grid.activeEditor.setValue(result);\n        //console.log(result.translation);\n    });\n    \n\n    \n    return true;\n}",
126                                         "afteredit": "function (e)\n{\n    e.record.commit();\n}"
127                                     },
128                                     "*prop": "grid",
129                                     "autoExpandColumn": "txt",
130                                     "clicksToEdit": 1,
131                                     "loadMask": true,
132                                     "xtype": "EditorGrid",
133                                     "|xns": "Roo.grid",
134                                     "items": [
135                                         {
136                                             "*prop": "footer",
137                                             "displayInfo": true,
138                                             "displayMsg": "Displaying petition_entry{0} - {1} of {2}",
139                                             "emptyMsg": "Not Found",
140                                             "pageSize": 25,
141                                             "xtype": "PagingToolbar",
142                                             "|xns": "Roo"
143                                         },
144                                         {
145                                             "listeners": {
146                                                 "update": "function (_self, rec, operation)\n{\n    Roo.log(operation);\n    \n    if (operation != 'commit') {\n        return;\n    }\n    \n\n    _this.grid.getView().el.mask(\"Saving\");\n    new Pman.Request({\n        url : baseURL + '/Roo/cms_templatestr',\n        method: 'POST',\n        params : {\n            id : rec.get('id'),\n            txt : rec.get('txt')\n        },\n        success : function()\n        {\n            _this.grid.getView().el.unmask();\n                //g.getDataSource().reload();\n        },\n        failure : function()\n        {\n            _this.grid.getView().el.unmask();\n            Roo.MessageBox.alert(\"Error\", \"There was a problem saving the data - try reloading\");\n         }\n            \n    });\n    \n}",
147                                                 "beforeload": "function (_self, o)\n{\n   \n    var sn = _this.treepanel.tree.getSelectionModel().getSelectedNode();\n\n    if (!sn) { // || (sn.id.split('/').length < 2)) {\n       \n        _this.grid.ds.removeAll();\n        return false;\n    }\n    Roo.log(\"load?\");\n    var ar = sn.attributes.id * 1;//.split('/');\n    \n    o.params = o.params || {};\n    o.params.lang = sn.parentNode.attributes.id;\n    o.params.template_id = sn.attributes.id;\n    o.params.sort= 'src_id_txt';\n    o.params.dir = 'ASC';\n}"
148                                             },
149                                             "*prop": "dataSource",
150                                             "remoteSort": true,
151                                             "xtype": "Store",
152                                             "|sortInfo": "{ field : 'shortname', direction: 'ASC' }",
153                                             "|xns": "Roo.data",
154                                             "items": [
155                                                 {
156                                                     "*prop": "proxy",
157                                                     "method": "GET",
158                                                     "xtype": "HttpProxy",
159                                                     "|url": "baseURL + '/Roo/cms_templatestr.php'",
160                                                     "|xns": "Roo.data"
161                                                 },
162                                                 {
163                                                     "*prop": "reader",
164                                                     "id": "id",
165                                                     "root": "data",
166                                                     "totalProperty": "total",
167                                                     "xtype": "JsonReader",
168                                                     "|fields": "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'shortname',\n        'type': 'string'\n    },\n   \n]",
169                                                     "|xns": "Roo.data"
170                                                 }
171                                             ]
172                                         },
173                                         {
174                                             "*prop": "colModel[]",
175                                             "dataIndex": "src_id_txt",
176                                             "header": "Original",
177                                             "width": 200,
178                                             "xtype": "ColumnModel",
179                                             "|renderer": "function(v,x,r) { \n\n var c = '#666';\n        if (r.data.updated  < r.data.src_id_origupdated) {\n            c = 'red';\n        }\n        \n//        return '<div style=\"color:'+c+'\";>' +r.data.tableid + ':' + v + '</div>';\n        return String.format('<div style=\"color:'+c+'\";>{0}</div>', v)\n\n}",
180                                             "|xns": "Roo.grid"
181                                         },
182                                         {
183                                             "*prop": "colModel[]",
184                                             "dataIndex": "txt",
185                                             "header": "Translation",
186                                             "width": 200,
187                                             "xtype": "ColumnModel",
188                                             "|renderer": "function(v,x,r) { \n\n var c = '#666';\n        if (r.data.updated  < r.data.src_id_updated) {\n            c = 'red';\n        }\n        \n//        return '<div style=\"color:'+c+'\";>' +r.data.tableid + ':' + v + '</div>';\n        return String.format('<div style=\"color:'+c+'\";>{0}</div>', v)\n\n}",
189                                             "|xns": "Roo.grid",
190                                             "items": [
191                                                 {
192                                                     "|xns": "Roo.grid",
193                                                     "xtype": "GridEditor",
194                                                     "*prop": "editor",
195                                                     "items": [
196                                                         {
197                                                             "*prop": "field",
198                                                             "allowBlank": false,
199                                                             "xtype": "TextField",
200                                                             "|xns": "Roo.form"
201                                                         }
202                                                     ]
203                                                 }
204                                             ]
205                                         }
206                                     ]
207                                 }
208                             ]
209                         }
210                     ]
211                 }
212             ]
213         }
214     ],
215     "permname": "",
216     "modOrder": "800"
217 }