- grid : {
- xtype : 'EditorGrid',
- autoExpandColumn : 'txt',
- clicksToEdit : 1,
- loadMask : true,
- listeners : {
- afteredit : function (e)
- {
- var saveRec = function(rec)
- {
- var g = _this.grid;
-
- //g.getView().el.mask('Saving');
- new Pman.Request({
- url : baseURL + '/Admin/Translations.php',
- method: 'POST',
- params : {
- id : rec.get('id'),
- txt : rec.get('txt'),
- lang : _this.langCombo.getValue(),
- module : _this.modCombo.getValue()
- },
- success : function()
- {
- //g.getView().el.unmask();
- //g.getDataSource().reload();
- },
- failure : function()
- {
- Roo.MessageBox.alert("Error", "There was a problem saving the data - try reloading");
- // g.getView().el.unmask();
- }
-
- });
- };
-
- saveRec.defer(1000, _this, [ e.record ]);
- },
- beforeedit : function(e) {
- console.log('beforeedit');
- //if (e.record.get('origtxt').indexOf('<') > -1) {
- // console.log("HTML EDITOR!!");
-
- // return false;
- //}
- if (e.record.get('txt').replace(/\s+/, '').length) {
- return true;
- }
- if (e.record.get('suggest').length) {
- e.record.set('txt', e.record.get('suggest'));
- // _this.saveRec(e.record);
- return;
- }
-
-
-
-
- var tl = e.record.get('id').split('/')[0];
-
- tl = (tl == 'zh_HK') ? 'zh-TW' : tl;
- tl = tl.replace('_', '-');
- var rec = e.record;
-
-
-
- Pman.gtranslate(e.record.get('origtxt'), 'en', tl, function(result) {
- if (typeof(result) == 'object') { //error
- return;
- }
-
- if (_this.grid.activeEditor) {
- _this.grid.activeEditor.setValue(result);
- } else {
- rec.set('txt',result);
- //_this.saveRec(rec);
- }
-
- //
-
-
- //console.log(result.translation);
- });
-
-
-
- return true;
- },
- celldblclick : function (_self, rowIndex, columnIndex, e)
- {
- var di = this.colModel.config[columnIndex].dataIndex;
- if (di != 'reset_tx') {
- return;
- }
- rec = this.ds.getAt(rowIndex);
-
- var g = _this.grid;
-
- new Pman.Request({
- url : baseURL + '/Admin/Translations.php',
- method: 'POST',
- params : {
- id : rec.get('id'),
- txt : '',
- lang : _this.langCombo.getValue(),
- module : _this.modCombo.getValue()
- },
- success : function()
- {
- //g.getView().el.unmask();
- //g.getDataSource().reload();
- rec.set('txt', '');
- },
- failure : function()
- {
- Roo.MessageBox.alert("Error", "There was a problem saving the data - try reloading");
- // g.getView().el.unmask();
- }
-
- });
-
-
- },
- render : function() {
- _this.grid = this;
- //_this.dialog = Pman.Dialog.FILL_IN
- if (_this.panel.active) {
- _this.grid.getDataSource().reload();
- }
- }
- },
- xns : Roo.grid,
- '|xns' : 'Roo.grid',
- toolbar : {
- xtype : 'Toolbar',
- xns : Roo,
- '|xns' : 'Roo',
- items : [
- {
- xtype : 'ComboBox',
- displayField : 'module',
- editable : false,
- emptyText : _this._strings['b51c3fa7e0ae26a1d88bf1279f265bb4'] /* Select Module */,
- mode : 'local',
- selectOnFocus : true,
- triggerAction : 'all',
- typeAhead : false,
- valueField : 'module',
- width : 200,
- listeners : {
- render : function (_self)
- {
- _this.modCombo = _self;
- },
- select : function (combo, record, index)
- {
- _this.grid.getDataSource().reload();
- }
- },
- xns : Roo.form,
- '|xns' : 'Roo.form',
- store : {
- xtype : 'SimpleStore',
- data : (function() {
- var modlist = [];
- AppModules = typeof(AppModules) == 'undefined' ? '' : AppModules;
- Roo.each( AppModules.split(','), function(mod) {
- modlist.push( [ mod ] );
- });
- return modlist;
- })(),
- fields : ['module'],
- xns : Roo.data,
- '|xns' : 'Roo.data'
- }