diff --git a/js/app/models/InteractiveNode.js b/js/app/models/InteractiveNode.js index 8c52229..07849a3 100644 --- a/js/app/models/InteractiveNode.js +++ b/js/app/models/InteractiveNode.js @@ -696,21 +696,18 @@ Ext.define('amdaModel.InteractiveNode', { * Create Folder */ createDir: function() { - console.log('create folder') var me = this; amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), function() { var newNode = Ext.create(me.$className, { - leaf : false, - nodeType : me.get('nodeType'), - text : amdaModel.AmdaNode.NEW_DIR_NAME, + leaf : false, nodeType : me.get('nodeType'), + text : amdaModel.AmdaNode.NEW_DIR_NAME, children : [] }); - // insert the new node as a child of node - // newNode = me.insertChild(0, newNode); + // insert the new node as a child of node me.insertChild(0, newNode); // start text edition on this new directory node me.expand(false); @@ -741,7 +738,6 @@ Ext.define('amdaModel.InteractiveNode', { renameNode: function() { - console.log('renameNode'); if (this.myGetOwnerTree()) { // load the rootNode and recursively all its child nodes if not already loaded diff --git a/js/app/views/ExplorerUI.js b/js/app/views/ExplorerUI.js index 5935827..04184f0 100644 --- a/js/app/views/ExplorerUI.js +++ b/js/app/views/ExplorerUI.js @@ -698,7 +698,9 @@ Ext.define('amdaUI.ExplorerUI', { field: { validFlag: true, validator : function(value) { - console.log('validator'); + if(value === amdaModel.AmdaNode.NEW_DIR_NAME) { + this.validFlag = 'Field is not modified' + } return this.validFlag; }, listeners: { @@ -706,27 +708,28 @@ Ext.define('amdaUI.ExplorerUI', { { console.log('changing...'); var explModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); - var activeTreePanel = explModule.getUiContent().getActiveTab(); + var explUI = explModule.getUiContent(); + var activeTreePanel = explUI.getActiveTab(); var editedNode = activeTreePanel.getSelectionModel().selected.items[0]; if (editedNode) { editedNode.isValidName(newValue, function (res) { - var validFlag = true; + field.validFlag = true; if (!res) { - validFlag = 'Error during object validation'; + field.validFlag = 'Error during object validation'; } else if (!res.valid) { if (res.error) { - validFlag = res.error; + field.validFlag = res.error; } else { - validFlag = 'Invalid object name'; + field.validFlag = 'Invalid object name'; } } - if (validFlag === true) { - // field.fireEvent('validitychange', true); + if (field.validFlag === true) { + console.log('change - valid'); + field.lastValid = newValue; } else { - field.markInvalid(validFlag); - // field.setValue(oldValue); - // field.fireEvent('validitychange', false, validFlag); + console.log('change - not valid:', field.validFlag); + field.markInvalid(field.validFlag); } }); } @@ -735,45 +738,23 @@ Ext.define('amdaUI.ExplorerUI', { scope: this } }], - // add our custom editor plugin + //add our custom editor plugin plugins: [ new MyTreeEditor({ pluginId: 'treeEditor', listeners: { - 'canceledit' : function(editor, context) { - console.log('canceledit event'); - // if (editor && editor.startValue===amdaModel.AmdaNode.NEW_DIR_NAME) { - context.record.remove(true); - // } - }, - 'edit': function (editor, e) { - var me = this; - console.log('edit event'); - var explModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); - var activeTreePanel = explModule.getUiContent().getActiveTab(); - - var editedNode = activeTreePanel.getSelectionModel().selected.items[0]; - if (editedNode) { - editedNode.isValidName(e.value, function (res) { - var validFlag = true; - if (!res) { - validFlag = 'Error during object validation'; - } else if (!res.valid) { - if (res.error) { - validFlag = res.error; - } else { - validFlag = 'Invalid object name'; - } - } - if (validFlag === true) { - console.log('valid'); - } else { - console.log('not valid'); - me.cancelEdit(); - } - }); - } - - + 'validateedit': function (editor, e) { + var field = e.column.field + console.log('validateedit - field=', field); + if(field.validFlag !== true) { + if(field.lastValid) { + e.record.data[e.field] = field.lastValid; + } else { + e.record.remove(true); + } + } + }, + 'beforeedit': function (editor, e) { + // e.column.field.fireEvent('change', e.value, e.value); } }, scope: this @@ -1013,11 +994,10 @@ Ext.define( 'MyTreeEditor', { * Cancel any active editing. */ cancelEdit: function() { - console.log('cancelEdit'); var me = this, activeEd = me.getActiveEditor(), viewEl = me.grid.getView().getEl(me.getActiveColumn()); - // console.log('activeEd:', activeEd); + me.setActiveEditor(null); me.setActiveColumn(null); me.setActiveRecord(null); @@ -1039,23 +1019,12 @@ Ext.define( 'MyTreeEditor', { me.on({ edit: function(editor,event){ - console.log('edited'); - // console.log('grid:', event.grid.validate()); - // console.log('record:', event.record.validate()); - // console.log('field:', event.field); - // console.log('grid:', event.grid.validFlag); - // console.log('record:', event.record.validFlag); - // console.log('field:', event.field.validFlag); - // // console.log('row:', event.row.validFlag); - // console.log('column:', event.column.validFlag); - // me.cancelEdit(); - // if there is a modification + // if there is a modification if (event.originalValue !== event.value) { // delegate rename action on model event.record.rename(event.value,function(result){ // if a result has been returned : success if(result) { - console.log('renaming, success'); // delegate commit action to delete modification flag event.record.commit(); var rec = event.record.data; @@ -1065,7 +1034,6 @@ Ext.define( 'MyTreeEditor', { rec.id = result.id; } } else { // in case of transaction error - console.log('renaming, oops'); // reset originalValue event.record.value = event.originalValue; event.record.set('text', event.originalValue); -- libgit2 0.21.2