[BUGFIX] Change name of correct pagetree entry after renaming 77/44977/3
authorMartin Gebert <martin-mfg2@gmx.de>
Fri, 27 Nov 2015 12:51:45 +0000 (13:51 +0100)
committerAndreas Fernandez <typo3@scripting-base.de>
Fri, 4 Dec 2015 09:42:43 +0000 (10:42 +0100)
* The first parameter to TreeEditor.complete and
TreeEditor.beforecomplete is the TreeEditor, not the edited node.
Reflect this in the code.
* In TreeEditor.updateNodeText, update the node provided as parameter
instead of the current editNode.
* In saveTitle, remove the first parameter, because it's used in the
wrong way (code assumes i'ts a node, but it's actually a TreeEditor) and
is not necessary.
* In saveTitle, store the current editNode, in case treeEditor.editNode
changes before the ajax call completes.

Resolves: #56371
Releases: master
Change-Id: I9446969701f0e24bcc048305ea06819228982826
Reviewed-on: https://review.typo3.org/44977
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Tested-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/actions.js
typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/treeeditor.js

index 305385d..2f491ba 100644 (file)
@@ -744,36 +744,38 @@ TYPO3.Components.PageTree.Actions = {
        /**
         * Updates the title of a node
         *
-        * @param {Ext.tree.TreeNode} node
         * @param {String} newText
         * @param {String} oldText
         * @param {TYPO3.Components.PageTree.TreeEditor} treeEditor
         * @return {void}
         */
-       saveTitle: function(node, newText, oldText, treeEditor) {
+       saveTitle: function(newText, oldText, treeEditor) {
+               // Save current editNode in case treeEditor.editNode changes before the ajax call completes
+               var editedNode = treeEditor.editNode;
+
                if (newText === oldText || newText == '') {
                        treeEditor.updateNodeText(
-                               node,
-                               node.editNode.attributes.nodeData.editableText,
+                               editedNode,
+                               editedNode.attributes.nodeData.editableText,
                                Ext.util.Format.htmlEncode(oldText)
                        );
                        return;
                }
 
                TYPO3.Components.PageTree.Commands.updateLabel(
-                       node.editNode.attributes.nodeData,
+                       editedNode.attributes.nodeData,
                        newText,
                        function(response) {
                                if (this.evaluateResponse(response)) {
-                                       treeEditor.updateNodeText(node, response.editableText, response.updatedText);
+                                       treeEditor.updateNodeText(editedNode, response.editableText, response.updatedText);
                                } else {
                                        treeEditor.updateNodeText(
-                                               node,
-                                               node.editNode.attributes.nodeData.editableText,
+                                               editedNode,
+                                               editedNode.attributes.nodeData.editableText,
                                                Ext.util.Format.htmlEncode(oldText)
                                        );
                                }
-                               this.singleClick(node.editNode, node.editNode.ownerTree);
+                               this.singleClick(treeEditor.editNode, treeEditor.editNode.ownerTree);
                        },
                        this
                );
index 7de8b59..c0b662e 100644 (file)
@@ -49,7 +49,7 @@ TYPO3.Components.PageTree.TreeEditor = Ext.extend(Ext.tree.TreeEditor, {
         * Handles the synchronization between the edited label and the shown label.
         */
        listeners: {
-               beforecomplete: function(node) {
+               beforecomplete: function(treeEditor) {
                        this.updatedValue = this.getValue();
                        if (this.updatedValue === '') {
                                this.cancelEdit();
@@ -59,13 +59,13 @@ TYPO3.Components.PageTree.TreeEditor = Ext.extend(Ext.tree.TreeEditor, {
                },
 
                complete: {
-                       fn: function(node, newValue, oldValue) {
+                       fn: function(treeEditor, newValue, oldValue) {
                                if (newValue === oldValue) {
                                        this.fireEvent('canceledit', this);
                                        return false;
                                }
 
-                               this.editNode.getOwnerTree().commandProvider.saveTitle(node, this.updatedValue, oldValue, this);
+                               this.editNode.getOwnerTree().commandProvider.saveTitle(this.updatedValue, oldValue, this);
                        }
                },
 
@@ -92,8 +92,8 @@ TYPO3.Components.PageTree.TreeEditor = Ext.extend(Ext.tree.TreeEditor, {
         * @return {void}
         */
        updateNodeText: function(node, editableText, updatedNode) {
-               this.editNode.setText(this.editNode.attributes.prefix + updatedNode + this.editNode.attributes.suffix);
-               this.editNode.attributes.editableText = editableText;
+               node.setText(node.attributes.prefix + updatedNode + node.attributes.suffix);
+               node.attributes.editableText = editableText;
        },
 
        /**