Commit 11d21073c77e3d050a6d0f47c10353805df4df9f
1 parent
36904910
Exists in
master
and in
109 other branches
Fix bugs when creating and renaming folders
Showing
2 changed files
with
32 additions
and
28 deletions
Show diff stats
js/app/models/InteractiveNode.js
... | ... | @@ -146,7 +146,7 @@ Ext.define('amdaModel.InteractiveNode', { |
146 | 146 | */ |
147 | 147 | rename: function(value,callBackFn) |
148 | 148 | { |
149 | - var dataToSend = {id : this.get('id'), old_name: this.modified.text, name: value, parent : this.parentNode.get('id'), leaf: this.isLeaf(), nodeType: this.get('nodeType')}; | |
149 | + var dataToSend = {id : this.get('id'), old_name: this.modified.text, name: value, parent : this.data.parentId, leaf: this.isLeaf(), nodeType: this.get('nodeType')}; | |
150 | 150 | AmdaAction.renameObject(dataToSend, callBackFn); |
151 | 151 | }, |
152 | 152 | |
... | ... | @@ -442,7 +442,7 @@ Ext.define('amdaModel.InteractiveNode', { |
442 | 442 | this.createLeaf(this); |
443 | 443 | break; |
444 | 444 | case 'renameNode': |
445 | - this.renameNode(); | |
445 | + this.renameNode(false); | |
446 | 446 | break; |
447 | 447 | case 'editLeaf': |
448 | 448 | this.editLeaf(); |
... | ... | @@ -704,7 +704,8 @@ Ext.define('amdaModel.InteractiveNode', { |
704 | 704 | { |
705 | 705 | leaf : false, nodeType : me.get('nodeType'), |
706 | 706 | text : amdaModel.AmdaNode.NEW_DIR_NAME, |
707 | - children : [] | |
707 | + children : [], | |
708 | + parentId: me.get('id') | |
708 | 709 | }); |
709 | 710 | |
710 | 711 | // insert the new node as a child of node |
... | ... | @@ -716,7 +717,7 @@ Ext.define('amdaModel.InteractiveNode', { |
716 | 717 | // select the new node |
717 | 718 | me.myGetOwnerTree().getSelectionModel().select(newNode); |
718 | 719 | // call the renameNode method for this new node |
719 | - newNode.renameNode(); | |
720 | + newNode.renameNode(true); | |
720 | 721 | }); |
721 | 722 | }, |
722 | 723 | |
... | ... | @@ -736,7 +737,7 @@ Ext.define('amdaModel.InteractiveNode', { |
736 | 737 | }); |
737 | 738 | }, |
738 | 739 | |
739 | - renameNode: function() | |
740 | + renameNode: function(deleteOnFailure) | |
740 | 741 | { |
741 | 742 | if (this.myGetOwnerTree()) |
742 | 743 | { |
... | ... | @@ -746,8 +747,10 @@ Ext.define('amdaModel.InteractiveNode', { |
746 | 747 | function() |
747 | 748 | { |
748 | 749 | // fire the edition event on tree |
749 | - me.myGetOwnerTree().fireEvent('edition',me.myGetOwnerTree().view, me.myGetOwnerTree().getSelectionModel().selected.items[0]); | |
750 | - }); | |
750 | + var item = me.myGetOwnerTree().getSelectionModel().selected.items[0]; | |
751 | + item.deleteOnFailure = deleteOnFailure; | |
752 | + me.myGetOwnerTree().fireEvent('edition', me.myGetOwnerTree().view, item); | |
753 | + }); | |
751 | 754 | } |
752 | 755 | else |
753 | 756 | { | ... | ... |
js/app/views/ExplorerUI.js
... | ... | @@ -719,9 +719,7 @@ Ext.define('amdaUI.ExplorerUI', { |
719 | 719 | validFlag = 'Invalid object name'; |
720 | 720 | } |
721 | 721 | } |
722 | - if (validFlag === true) { | |
723 | - field.lastValid = newValue; | |
724 | - } else { | |
722 | + if (validFlag !== true) { | |
725 | 723 | field.markInvalid(validFlag); |
726 | 724 | } |
727 | 725 | field.validFlag = validFlag; |
... | ... | @@ -732,25 +730,28 @@ Ext.define('amdaUI.ExplorerUI', { |
732 | 730 | scope: this |
733 | 731 | } |
734 | 732 | }], |
735 | - //add our custom editor plugin | |
736 | - plugins: [ new MyTreeEditor({ | |
737 | - pluginId: 'treeEditor', | |
738 | - listeners: { | |
739 | - 'edit': function (editor, e) { | |
740 | - if(e.column.field.validFlag !== true) { | |
741 | - if(e.column.field.lastValid) { | |
742 | - e.record.data[e.field] = e.column.field.lastValid; | |
743 | - } else { | |
744 | - e.record.remove(true); | |
745 | - } | |
733 | + // Add our custom editor plugin | |
734 | + plugins: [ | |
735 | + new MyTreeEditor({ | |
736 | + pluginId: 'treeEditor', | |
737 | + listeners: { | |
738 | + beforeedit: function (editor, e) { | |
739 | + e.column.field.fireEvent('change', e.column.field, e.value, ''); | |
740 | + }, | |
741 | + validateedit: function (editor, e) { | |
742 | + if (e.column.field.validFlag !== true) { | |
743 | + if (e.record.deleteOnFailure) { | |
744 | + e.record.remove(true); | |
745 | + } else { | |
746 | + return false; | |
747 | + } | |
748 | + } | |
749 | + return true; | |
746 | 750 | } |
747 | - }, | |
748 | - 'beforeedit': function (editor, e) { | |
749 | - e.column.field.fireEvent('change', e.column.field, e.value, ''); | |
750 | - } | |
751 | - }, | |
752 | - scope: this | |
753 | - })], | |
751 | + }, | |
752 | + scope: this | |
753 | + }) | |
754 | + ], | |
754 | 755 | |
755 | 756 | setNodesVisibility : function(node,forceHide) |
756 | 757 | { | ... | ... |
-
mentioned in commit 3720136bb28f798a3488ea9dbef1688e8c96ffdb