[BUGFIX] Stay on edited page after using "Save & Close" 70/47370/4
authorMartin Vennemann <vennemann@cybay.de>
Tue, 22 Mar 2016 13:54:05 +0000 (14:54 +0100)
committerNicole Cordes <typo3@cordes.co>
Wed, 30 Mar 2016 13:18:49 +0000 (15:18 +0200)
"Save & Close" after editing a page now uses that edited
page (already highlighted in page tree) for returnUrl.

Resolves: #74180
Releases: master, 7.6
Change-Id: Icf2769263b2d428b86f339778f12b40759d94c13
Reviewed-on: https://review.typo3.org/47370
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
typo3/sysext/backend/Resources/Public/JavaScript/Utility.js
typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/actions.js

index 6df8932..9575765 100644 (file)
@@ -65,6 +65,23 @@ define(['jquery'], function($) {
                return value;
        };
 
+       /**
+        * Updates a parameter inside of given url
+        *
+        * @param {String} url
+        * @param {String} key
+        * @param {String} value
+        */
+       Utility.updateQueryStringParameter = function(url, key, value) {
+               var re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i'),
+                       separator = url.indexOf('?') !== -1 ? '&' : '?';
+
+               if (url.match(re)) {
+                       return url.replace(re, '$1' + key + '=' + value + '$2');
+               }
+               return url + separator + key + '=' + value;
+       };
+
        TYPO3.Utility = Utility;
        return Utility;
 });
index 68c7341..4d8bb05 100644 (file)
@@ -321,6 +321,12 @@ TYPO3.Components.PageTree.Actions = {
                        returnUrl = encodeURIComponent(returnUrl);
                }
 
+               var decodeReturnUrl = decodeURIComponent(returnUrl);
+               var editPageId = TYPO3.Utility.getParameterFromUrl(decodeReturnUrl, 'id');
+               if (parseInt(editPageId, 10) !== parseInt(node.attributes.nodeData.id, 10)) {
+                       returnUrl = encodeURIComponent(TYPO3.Utility.updateQueryStringParameter(decodeReturnUrl, 'id', node.attributes.nodeData.id));
+               }
+
                TYPO3.Backend.ContentContainer.setUrl(
                        TYPO3.settings.FormEngine.moduleUrl + '&edit[pages][' + node.attributes.nodeData.id + ']=edit&returnUrl=' + returnUrl
                );