Commit 82560cb27e1bf55535f2911719509823a2ae7667
1 parent
65ac4a9d
Exists in
master
and in
109 other branches
fix folders (wip)
Showing
2 changed files
with
33 additions
and
69 deletions
Show diff stats
js/app/models/InteractiveNode.js
... | ... | @@ -696,21 +696,18 @@ Ext.define('amdaModel.InteractiveNode', { |
696 | 696 | * Create Folder |
697 | 697 | */ |
698 | 698 | createDir: function() { |
699 | - console.log('create folder') | |
700 | 699 | var me = this; |
701 | 700 | amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), |
702 | 701 | function() |
703 | 702 | { |
704 | 703 | var newNode = Ext.create(me.$className, |
705 | 704 | { |
706 | - leaf : false, | |
707 | - nodeType : me.get('nodeType'), | |
708 | - text : amdaModel.AmdaNode.NEW_DIR_NAME, | |
705 | + leaf : false, nodeType : me.get('nodeType'), | |
706 | + text : amdaModel.AmdaNode.NEW_DIR_NAME, | |
709 | 707 | children : [] |
710 | 708 | }); |
711 | 709 | |
712 | - // insert the new node as a child of node | |
713 | - // newNode = me.insertChild(0, newNode); | |
710 | + // insert the new node as a child of node | |
714 | 711 | me.insertChild(0, newNode); |
715 | 712 | // start text edition on this new directory node |
716 | 713 | me.expand(false); |
... | ... | @@ -741,7 +738,6 @@ Ext.define('amdaModel.InteractiveNode', { |
741 | 738 | |
742 | 739 | renameNode: function() |
743 | 740 | { |
744 | - console.log('renameNode'); | |
745 | 741 | if (this.myGetOwnerTree()) |
746 | 742 | { |
747 | 743 | // load the rootNode and recursively all its child nodes if not already loaded | ... | ... |
js/app/views/ExplorerUI.js
... | ... | @@ -698,7 +698,9 @@ Ext.define('amdaUI.ExplorerUI', { |
698 | 698 | field: { |
699 | 699 | validFlag: true, |
700 | 700 | validator : function(value) { |
701 | - console.log('validator'); | |
701 | + if(value === amdaModel.AmdaNode.NEW_DIR_NAME) { | |
702 | + this.validFlag = 'Field is not modified' | |
703 | + } | |
702 | 704 | return this.validFlag; |
703 | 705 | }, |
704 | 706 | listeners: { |
... | ... | @@ -706,27 +708,28 @@ Ext.define('amdaUI.ExplorerUI', { |
706 | 708 | { |
707 | 709 | console.log('changing...'); |
708 | 710 | var explModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); |
709 | - var activeTreePanel = explModule.getUiContent().getActiveTab(); | |
711 | + var explUI = explModule.getUiContent(); | |
712 | + var activeTreePanel = explUI.getActiveTab(); | |
710 | 713 | |
711 | 714 | var editedNode = activeTreePanel.getSelectionModel().selected.items[0]; |
712 | 715 | if (editedNode) { |
713 | 716 | editedNode.isValidName(newValue, function (res) { |
714 | - var validFlag = true; | |
717 | + field.validFlag = true; | |
715 | 718 | if (!res) { |
716 | - validFlag = 'Error during object validation'; | |
719 | + field.validFlag = 'Error during object validation'; | |
717 | 720 | } else if (!res.valid) { |
718 | 721 | if (res.error) { |
719 | - validFlag = res.error; | |
722 | + field.validFlag = res.error; | |
720 | 723 | } else { |
721 | - validFlag = 'Invalid object name'; | |
724 | + field.validFlag = 'Invalid object name'; | |
722 | 725 | } |
723 | 726 | } |
724 | - if (validFlag === true) { | |
725 | - // field.fireEvent('validitychange', true); | |
727 | + if (field.validFlag === true) { | |
728 | + console.log('change - valid'); | |
729 | + field.lastValid = newValue; | |
726 | 730 | } else { |
727 | - field.markInvalid(validFlag); | |
728 | - // field.setValue(oldValue); | |
729 | - // field.fireEvent('validitychange', false, validFlag); | |
731 | + console.log('change - not valid:', field.validFlag); | |
732 | + field.markInvalid(field.validFlag); | |
730 | 733 | } |
731 | 734 | }); |
732 | 735 | } |
... | ... | @@ -735,45 +738,23 @@ Ext.define('amdaUI.ExplorerUI', { |
735 | 738 | scope: this |
736 | 739 | } |
737 | 740 | }], |
738 | - // add our custom editor plugin | |
741 | + //add our custom editor plugin | |
739 | 742 | plugins: [ new MyTreeEditor({ |
740 | 743 | pluginId: 'treeEditor', |
741 | 744 | listeners: { |
742 | - 'canceledit' : function(editor, context) { | |
743 | - console.log('canceledit event'); | |
744 | - // if (editor && editor.startValue===amdaModel.AmdaNode.NEW_DIR_NAME) { | |
745 | - context.record.remove(true); | |
746 | - // } | |
747 | - }, | |
748 | - 'edit': function (editor, e) { | |
749 | - var me = this; | |
750 | - console.log('edit event'); | |
751 | - var explModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
752 | - var activeTreePanel = explModule.getUiContent().getActiveTab(); | |
753 | - | |
754 | - var editedNode = activeTreePanel.getSelectionModel().selected.items[0]; | |
755 | - if (editedNode) { | |
756 | - editedNode.isValidName(e.value, function (res) { | |
757 | - var validFlag = true; | |
758 | - if (!res) { | |
759 | - validFlag = 'Error during object validation'; | |
760 | - } else if (!res.valid) { | |
761 | - if (res.error) { | |
762 | - validFlag = res.error; | |
763 | - } else { | |
764 | - validFlag = 'Invalid object name'; | |
765 | - } | |
766 | - } | |
767 | - if (validFlag === true) { | |
768 | - console.log('valid'); | |
769 | - } else { | |
770 | - console.log('not valid'); | |
771 | - me.cancelEdit(); | |
772 | - } | |
773 | - }); | |
774 | - } | |
775 | - | |
776 | - | |
745 | + 'validateedit': function (editor, e) { | |
746 | + var field = e.column.field | |
747 | + console.log('validateedit - field=', field); | |
748 | + if(field.validFlag !== true) { | |
749 | + if(field.lastValid) { | |
750 | + e.record.data[e.field] = field.lastValid; | |
751 | + } else { | |
752 | + e.record.remove(true); | |
753 | + } | |
754 | + } | |
755 | + }, | |
756 | + 'beforeedit': function (editor, e) { | |
757 | + // e.column.field.fireEvent('change', e.value, e.value); | |
777 | 758 | } |
778 | 759 | }, |
779 | 760 | scope: this |
... | ... | @@ -1013,11 +994,10 @@ Ext.define( 'MyTreeEditor', { |
1013 | 994 | * Cancel any active editing. |
1014 | 995 | */ |
1015 | 996 | cancelEdit: function() { |
1016 | - console.log('cancelEdit'); | |
1017 | 997 | var me = this, |
1018 | 998 | activeEd = me.getActiveEditor(), |
1019 | 999 | viewEl = me.grid.getView().getEl(me.getActiveColumn()); |
1020 | - // console.log('activeEd:', activeEd); | |
1000 | + | |
1021 | 1001 | me.setActiveEditor(null); |
1022 | 1002 | me.setActiveColumn(null); |
1023 | 1003 | me.setActiveRecord(null); |
... | ... | @@ -1039,23 +1019,12 @@ Ext.define( 'MyTreeEditor', { |
1039 | 1019 | |
1040 | 1020 | me.on({ |
1041 | 1021 | edit: function(editor,event){ |
1042 | - console.log('edited'); | |
1043 | - // console.log('grid:', event.grid.validate()); | |
1044 | - // console.log('record:', event.record.validate()); | |
1045 | - // console.log('field:', event.field); | |
1046 | - // console.log('grid:', event.grid.validFlag); | |
1047 | - // console.log('record:', event.record.validFlag); | |
1048 | - // console.log('field:', event.field.validFlag); | |
1049 | - // // console.log('row:', event.row.validFlag); | |
1050 | - // console.log('column:', event.column.validFlag); | |
1051 | - // me.cancelEdit(); | |
1052 | - // if there is a modification | |
1022 | + // if there is a modification | |
1053 | 1023 | if (event.originalValue !== event.value) { |
1054 | 1024 | // delegate rename action on model |
1055 | 1025 | event.record.rename(event.value,function(result){ |
1056 | 1026 | // if a result has been returned : success |
1057 | 1027 | if(result) { |
1058 | - console.log('renaming, success'); | |
1059 | 1028 | // delegate commit action to delete modification flag |
1060 | 1029 | event.record.commit(); |
1061 | 1030 | var rec = event.record.data; |
... | ... | @@ -1065,7 +1034,6 @@ Ext.define( 'MyTreeEditor', { |
1065 | 1034 | rec.id = result.id; |
1066 | 1035 | } |
1067 | 1036 | } else { // in case of transaction error |
1068 | - console.log('renaming, oops'); | |
1069 | 1037 | // reset originalValue |
1070 | 1038 | event.record.value = event.originalValue; |
1071 | 1039 | event.record.set('text', event.originalValue); | ... | ... |