From: Alan Knowles Date: Thu, 6 Jul 2017 02:35:01 +0000 (+0800) Subject: Pman.Tab.AdminTranslations.bjs X-Git-Url: http://git.roojs.org/?p=Pman.Admin;a=commitdiff_plain;h=884c35c521876ca759d5b2a191e8bac22d2204b8 Pman.Tab.AdminTranslations.bjs Pman.Tab.AdminTranslations.js --- diff --git a/Pman.Tab.AdminTranslations.bjs b/Pman.Tab.AdminTranslations.bjs index f15ee05..b7cb497 100644 --- a/Pman.Tab.AdminTranslations.bjs +++ b/Pman.Tab.AdminTranslations.bjs @@ -2,7 +2,7 @@ "name" : "Pman.Tab.AdminTranslations", "parent" : "Pman.Tab.Admin", "title" : "Admin - Translations", - "path" : "/home/edward/gitlive/Pman.Admin/Pman.Tab.AdminTranslations.bjs", + "path" : "/home/alan/gitlive/Pman.Admin/Pman.Tab.AdminTranslations.bjs", "permname" : "Admin.Translations", "modOrder" : "950", "strings" : { @@ -25,8 +25,8 @@ "items" : [ { "region" : "center", - "xtype" : "NestedLayoutPanel", "title" : "Translate App", + "xtype" : "NestedLayoutPanel", "$ xns" : "Roo", "items" : [ { @@ -45,9 +45,9 @@ "listeners" : { "|activate" : "function() {\n _this.panel = this;\n if (_this.grid) {\n _this.grid.getDataSource().reload(); \n }\n}" }, + "fitToframe" : true, "background" : true, "region" : "center", - "fitToframe" : true, "title" : "Text in interface", "xtype" : "GridPanel", "fitContainer" : true, @@ -79,8 +79,8 @@ "items" : [ { "$ url" : "baseURL + '/Admin/Translations.php'", - "method" : "GET", "xtype" : "HttpProxy", + "method" : "GET", "$ xns" : "Roo.data", "* prop" : "proxy" }, @@ -168,17 +168,17 @@ }, { "xtype" : "ColumnModel", - "width" : 150, "header" : "Name", - "$ renderer" : "function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '
' +r.get('tableid')+ ':' + v + '
'; }", + "width" : 150, + "$ renderer" : "function(v,x,r) { \n var c = '#666'; \n if (r.get('updated') < r.get('origupdated')) { \n c = 'red'; \n \n } \n return '
' +r.get('tableid')+ ':' + v + '
'; \n }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", "dataIndex" : "colname" }, { "xtype" : "ColumnModel", - "width" : 300, "header" : "Original", + "width" : 300, "$ renderer" : "function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '
' + Ext.util.Format.htmlEncode(v) + '
'; }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", @@ -186,8 +186,8 @@ }, { "xtype" : "ColumnModel", - "header" : "Reset", "width" : 50, + "header" : "Reset", "$ renderer" : "function(v,x,r) { \n return '';\n}", "$ xns" : "Roo.grid", "* prop" : "colModel[]", @@ -195,8 +195,8 @@ }, { "xtype" : "ColumnModel", - "header" : "Translated (Click to Edit)", "width" : 150, + "header" : "Translated (Click to Edit)", "$ renderer" : "function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '
' + Ext.util.Format.htmlEncode(v) + '
'; }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", @@ -224,9 +224,9 @@ "listeners" : { "|activate" : "function() {\n _this.langpanel = this;\n if (_this.langgrid) {\n _this.langgrid.ds.load({});\n }\n}" }, + "fitToframe" : true, "background" : true, "region" : "center", - "fitToframe" : true, "title" : "Languages and Countries", "xtype" : "GridPanel", "fitContainer" : true, @@ -236,8 +236,8 @@ { "listeners" : { "beforeedit" : "function(e) {\n console.log('beforeedit');\n //if (e.record.get('origtxt').indexOf('<') > -1) {\n // console.log(\"HTML EDITOR!!\");\n \n // return false;\n //}\n if (e.record.get('lval').replace(/\\s+/, '').length) {\n return true;\n }\n \n \n var tl = _this.langgridCombo.getValue();\n \n tl = (tl == 'zh_HK') ? 'zh-TW' : tl; \n tl = tl.replace('_', '-');\n var rec = e.record;\n \n \n \n Pman.gtranslate(e.record.get('lval_en'), 'en', tl, function(result) { \n if (typeof(result) == 'object') { //error\n return; \n }\n \n if (_this.grid.activeEditor) {\n _this.grid.activeEditor.setValue(result);\n } else {\n rec.set('lval',result);\n //_this.saveRec(rec);\n }\n\n //\n \n \n //console.log(result.translation);\n });\n \n \n \n return true;\n } ", - "|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}", "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n if(_this.langgrid.colModel.getDataIndex(columnIndex) !== 'is_active'){\n return;\n }\n \n var s = _this.langgrid.ds.getAt(rowIndex);\n \n if(!s || s.data.id * 1 < 0){\n return;\n }\n \n s.set('is_active', s.data.is_active ? 0 : 1);\n \n new Pman.Request({\n url : baseURL+'/Roo/I18n',\n method : 'POST',\n params : {\n id : s.data.id,\n is_active : s.data.is_active\n }\n }); \n \n}", + "|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}", "afteredit" : "function (e)\n{\n var saveRec = function(rec)\n {\n var g = _this.grid;\n\n //g.getView().el.mask('Saving');\n Ext.Ajax.request({\n url : baseURL + '/Roo/I18n.php',\n method: 'POST',\n params : {\n id : rec.get('id'),\n lval : rec.get('lval')\n },\n success : function()\n {\n //g.getView().el.unmask();\n //g.getDataSource().reload();\n },\n failure : function()\n {\n Ext.Msg.alert(\"Error\", \"There was a problem saving the data - try reloading\");\n // g.getView().el.unmask();\n }\n \n });\n };\n \n saveRec.defer(1000, _this, [ e.record ]);\n}" }, "autoExpandColumn" : "lval", @@ -259,8 +259,8 @@ "items" : [ { "$ url" : "baseURL + '/Roo/i18n.php'", - "method" : "GET", "xtype" : "HttpProxy", + "method" : "GET", "$ xns" : "Roo.data", "* prop" : "proxy" }, @@ -336,8 +336,8 @@ }, { "xtype" : "ColumnModel", - "header" : "Code", "width" : 50, + "header" : "Code", "$ renderer" : "function(v) { return String.format('{0}', v); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", @@ -345,8 +345,8 @@ }, { "xtype" : "ColumnModel", - "header" : "English", "width" : 150, + "header" : "English", "$ renderer" : "function(v) { return String.format('{0}', v); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", @@ -354,8 +354,8 @@ }, { "xtype" : "ColumnModel", - "header" : "Translation", "width" : 200, + "header" : "Translation", "$ renderer" : "function(v) { return String.format('{0}', v); }", "$ xns" : "Roo.grid", "* prop" : "colModel[]", @@ -377,8 +377,8 @@ }, { "xtype" : "ColumnModel", - "header" : "Active?", "width" : 150, + "header" : "Active?", "$ renderer" : "function(v,x,r) { \n\n return '';\n \n \n}", "$ xns" : "Roo.grid", "* prop" : "colModel[]", diff --git a/Pman.Tab.AdminTranslations.js b/Pman.Tab.AdminTranslations.js index ae59913..7685e99 100644 --- a/Pman.Tab.AdminTranslations.js +++ b/Pman.Tab.AdminTranslations.js @@ -31,37 +31,35 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ name : "Admin - Translations", disabled : false, permname : 'Admin.Translations', - _tree : function() + _tree : function(_data) { var _this = this; var MODULE = this; return { + xtype : 'NestedLayoutPanel', region : 'center', title : _this._strings['4e7c16d320ae129cc81b296e05748b3a'] /* Translate App */, xns : Roo, '|xns' : 'Roo', - xtype : 'NestedLayoutPanel', layout : { + xtype : 'BorderLayout', xns : Roo, '|xns' : 'Roo', - xtype : 'BorderLayout', center : { + xtype : 'LayoutRegion', alwaysShowTabs : true, tabPosition : 'top', xns : Roo, - '|xns' : 'Roo', - xtype : 'LayoutRegion' + '|xns' : 'Roo' }, items : [ { + xtype : 'GridPanel', background : true, fitContainer : true, fitToframe : true, region : 'center', title : _this._strings['a1d1ae170f841c328acdc6052511ed8c'] /* Text in interface */, - xns : Roo, - '|xns' : 'Roo', - xtype : 'GridPanel', listeners : { activate : function() { _this.panel = this; @@ -70,13 +68,13 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ } } }, + xns : Roo, + '|xns' : 'Roo', grid : { + xtype : 'EditorGrid', autoExpandColumn : 'txt', clicksToEdit : 1, loadMask : true, - xns : Roo.grid, - '|xns' : 'Roo.grid', - xtype : 'EditorGrid', listeners : { afteredit : function (e) { @@ -202,12 +200,15 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ } } }, + xns : Roo.grid, + '|xns' : 'Roo.grid', toolbar : { + xtype : 'Toolbar', xns : Roo, '|xns' : 'Roo', - xtype : 'Toolbar', items : [ { + xtype : 'ComboBox', displayField : 'module', editable : false, emptyText : _this._strings['b51c3fa7e0ae26a1d88bf1279f265bb4'] /* Select Module */, @@ -217,9 +218,6 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ typeAhead : false, valueField : 'module', width : 200, - xns : Roo.form, - '|xns' : 'Roo.form', - xtype : 'ComboBox', listeners : { render : function (_self) { @@ -230,7 +228,10 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ _this.grid.getDataSource().reload(); } }, + xns : Roo.form, + '|xns' : 'Roo.form', store : { + xtype : 'SimpleStore', data : (function() { var modlist = []; AppModules = typeof(AppModules) == 'undefined' ? '' : AppModules; @@ -241,11 +242,11 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ })(), fields : ['module'], xns : Roo.data, - '|xns' : 'Roo.data', - xtype : 'SimpleStore' + '|xns' : 'Roo.data' } }, { + xtype : 'ComboBox', displayField : 'ldisp', editable : false, emptyText : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */, @@ -255,9 +256,6 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ typeAhead : false, valueField : 'lang', width : 200, - xns : Roo.form, - '|xns' : 'Roo.form', - xtype : 'ComboBox', listeners : { render : function (_self) { @@ -268,24 +266,24 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ _this.grid.getDataSource().reload(); } }, + xns : Roo.form, + '|xns' : 'Roo.form', store : { + xtype : 'SimpleStore', data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ], fields : ['lang', 'ldisp'], xns : Roo.data, - '|xns' : 'Roo.data', - xtype : 'SimpleStore' + '|xns' : 'Roo.data' } }, { + xtype : 'Fill', xns : Roo.Toolbar, - '|xns' : 'Roo.Toolbar', - xtype : 'Fill' + '|xns' : 'Roo.Toolbar' }, { - text : _this._strings['801ab24683a4a8c433c6eb40c48bcd9d'] /* Download */, - xns : Roo.Toolbar, - '|xns' : 'Roo.Toolbar', xtype : 'Button', + text : _this._strings['801ab24683a4a8c433c6eb40c48bcd9d'] /* Download */, listeners : { click : function (_self, e) { @@ -294,15 +292,15 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ }); } - } + }, + xns : Roo.Toolbar, + '|xns' : 'Roo.Toolbar' } ] }, dataSource : { - reader : Pman.Readers.Category, - xns : Roo.data, - '|xns' : 'Roo.data', xtype : 'Store', + reader : Pman.Readers.Category, listeners : { beforeload : function (_self, opts) { @@ -323,43 +321,53 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ Roo.MessageBox.alert("Error", jsonData); } }, + xns : Roo.data, + '|xns' : 'Roo.data', proxy : { + xtype : 'HttpProxy', method : 'GET', url : baseURL + '/Admin/Translations.php', xns : Roo.data, - '|xns' : 'Roo.data', - xtype : 'HttpProxy' + '|xns' : 'Roo.data' }, reader : { + xtype : 'JsonReader', 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' ], id : 'id', root : 'data', totalProperty : 'total', xns : Roo.data, - '|xns' : 'Roo.data', - xtype : 'JsonReader' + '|xns' : 'Roo.data' } }, colModel : [ { + xtype : 'ColumnModel', dataIndex : 'colname', header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */, - renderer : function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '
' +r.get('tableid')+ ':' + v + '
'; }, + renderer : function(v,x,r) { + var c = '#666'; + if (r.get('updated') < r.get('origupdated')) { + c = 'red'; + + } + return '
' +r.get('tableid')+ ':' + v + '
'; + }, width : 150, xns : Roo.grid, - '|xns' : 'Roo.grid', - xtype : 'ColumnModel' + '|xns' : 'Roo.grid' }, { + xtype : 'ColumnModel', dataIndex : 'origtxt', header : _this._strings['0a52da7a03a6de3beefe54f8c03ad80d'] /* Original */, renderer : function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '
' + Ext.util.Format.htmlEncode(v) + '
'; }, width : 300, xns : Roo.grid, - '|xns' : 'Roo.grid', - xtype : 'ColumnModel' + '|xns' : 'Roo.grid' }, { + xtype : 'ColumnModel', dataIndex : 'reset_tx', header : _this._strings['526d688f37a86d3c3f27d0c5016eb71d'] /* Reset */, renderer : function(v,x,r) { @@ -367,25 +375,24 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ }, width : 50, xns : Roo.grid, - '|xns' : 'Roo.grid', - xtype : 'ColumnModel' + '|xns' : 'Roo.grid' }, { + xtype : 'ColumnModel', dataIndex : 'txt', header : _this._strings['e2ade2e0b88406a390f59b5232abb328'] /* Translated (Click to Edit) */, renderer : function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '
' + Ext.util.Format.htmlEncode(v) + '
'; }, width : 150, xns : Roo.grid, '|xns' : 'Roo.grid', - xtype : 'ColumnModel', editor : { + xtype : 'GridEditor', xns : Roo.grid, '|xns' : 'Roo.grid', - xtype : 'GridEditor', field : { + xtype : 'TextField', xns : Roo.form, - '|xns' : 'Roo.form', - xtype : 'TextField' + '|xns' : 'Roo.form' } } } @@ -393,15 +400,13 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ } }, { + xtype : 'GridPanel', background : true, fitContainer : true, fitToframe : true, region : 'center', tableName : 'i18n', title : _this._strings['0a9e8bd9e8b301dfb2c21c355e0b377d'] /* Languages and Countries */, - xns : Roo, - '|xns' : 'Roo', - xtype : 'GridPanel', listeners : { activate : function() { _this.langpanel = this; @@ -410,13 +415,13 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ } } }, + xns : Roo, + '|xns' : 'Roo', grid : { + xtype : 'EditorGrid', autoExpandColumn : 'lval', clicksToEdit : 1, loadMask : true, - xns : Roo.grid, - '|xns' : 'Roo.grid', - xtype : 'EditorGrid', listeners : { afteredit : function (e) { @@ -523,12 +528,15 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ } } }, + xns : Roo.grid, + '|xns' : 'Roo.grid', toolbar : { + xtype : 'Toolbar', xns : Roo, '|xns' : 'Roo', - xtype : 'Toolbar', items : [ { + xtype : 'ComboBox', displayField : 'lval', editable : false, emptyText : _this._strings['552bcc4e00cd663f09cc4efbaca1cd45'] /* Select Translation of */, @@ -538,9 +546,6 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ typeAhead : false, valueField : 'lkey', width : 200, - xns : Roo.form, - '|xns' : 'Roo.form', - xtype : 'ComboBox', listeners : { render : function (_self) { @@ -551,7 +556,10 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ _this.langgrid.getDataSource().reload(); } }, + xns : Roo.form, + '|xns' : 'Roo.form', store : { + xtype : 'SimpleStore', data : [ [ 'l', 'Language Names' ], [ 'c', 'Country Names' ], @@ -559,11 +567,11 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ ], fields : ['lkey','lval'], xns : Roo.data, - '|xns' : 'Roo.data', - xtype : 'SimpleStore' + '|xns' : 'Roo.data' } }, { + xtype : 'ComboBox', displayField : 'ldisp', editable : false, emptyText : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */, @@ -573,9 +581,6 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ typeAhead : false, valueField : 'lang', width : 200, - xns : Roo.form, - '|xns' : 'Roo.form', - xtype : 'ComboBox', listeners : { render : function (_self) { @@ -586,22 +591,22 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ _this.langgrid.getDataSource().reload(); } }, + xns : Roo.form, + '|xns' : 'Roo.form', store : { + xtype : 'SimpleStore', data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ], fields : ['lang', 'ldisp'], xns : Roo.data, - '|xns' : 'Roo.data', - xtype : 'SimpleStore' + '|xns' : 'Roo.data' } } ] }, dataSource : { + xtype : 'Store', remoteSort : true, sortInfo : { field : 'lkey', direction: 'ASC' }, - xns : Roo.data, - '|xns' : 'Roo.data', - xtype : 'Store', listeners : { beforeload : function (_self, options) { @@ -618,14 +623,17 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ } }, + xns : Roo.data, + '|xns' : 'Roo.data', proxy : { + xtype : 'HttpProxy', method : 'GET', url : baseURL + '/Roo/i18n.php', xns : Roo.data, - '|xns' : 'Roo.data', - xtype : 'HttpProxy' + '|xns' : 'Roo.data' }, reader : { + xtype : 'JsonReader', fields : [ { 'name': 'id', @@ -652,49 +660,49 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ root : 'data', totalProperty : 'total', xns : Roo.data, - '|xns' : 'Roo.data', - xtype : 'JsonReader' + '|xns' : 'Roo.data' } }, colModel : [ { + xtype : 'ColumnModel', dataIndex : 'lkey', header : _this._strings['ca0dbad92a874b2f69b549293387925e'] /* Code */, renderer : function(v) { return String.format('{0}', v); }, width : 50, xns : Roo.grid, - '|xns' : 'Roo.grid', - xtype : 'ColumnModel' + '|xns' : 'Roo.grid' }, { + xtype : 'ColumnModel', dataIndex : 'lval_en', header : _this._strings['78463a384a5aa4fad5fa73e2f506ecfc'] /* English */, renderer : function(v) { return String.format('{0}', v); }, width : 150, xns : Roo.grid, - '|xns' : 'Roo.grid', - xtype : 'ColumnModel' + '|xns' : 'Roo.grid' }, { + xtype : 'ColumnModel', dataIndex : 'lval', header : _this._strings['6dd08874f83507e9c7b23f1a46b7fa7c'] /* Translation */, renderer : function(v) { return String.format('{0}', v); }, width : 200, xns : Roo.grid, '|xns' : 'Roo.grid', - xtype : 'ColumnModel', editor : { + xtype : 'GridEditor', xns : Roo.grid, '|xns' : 'Roo.grid', - xtype : 'GridEditor', field : { + xtype : 'TextField', xns : Roo.form, - '|xns' : 'Roo.form', - xtype : 'TextField' + '|xns' : 'Roo.form' } } }, { + xtype : 'ColumnModel', dataIndex : 'is_active', header : _this._strings['ae739a236065a45c64ad51aacb19498c'] /* Active? */, renderer : function(v,x,r) { @@ -705,8 +713,7 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({ }, width : 150, xns : Roo.grid, - '|xns' : 'Roo.grid', - xtype : 'ColumnModel' + '|xns' : 'Roo.grid' } ] }