[BUGFIX] Invoke delete command via AJAX 21/60621/3
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Mon, 29 Apr 2019 16:42:43 +0000 (18:42 +0200)
committerRichard Haeser <richard@maxserv.com>
Mon, 29 Apr 2019 18:43:40 +0000 (20:43 +0200)
The delete command triggered by the page tree's context menu was invoked
by loading a URL in the module iframe which caused timing issues due to
subsequent requests.

This patch invokes an AJAX call instead to deleted pages.

Resolves: #87416
Releases: master, 9.5
Change-Id: I457df1a21e703f98f6b1a182f6165f60cfd13b21
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60621
Tested-by: Josef Glatz <josefglatz@gmail.com>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Richard Haeser <richard@maxserv.com>
Reviewed-by: Josef Glatz <josefglatz@gmail.com>
Reviewed-by: Richard Haeser <richard@maxserv.com>
Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ContextMenuActions.ts
typo3/sysext/backend/Resources/Public/JavaScript/ContextMenuActions.js

index 1998132..5af54ab 100644 (file)
@@ -213,19 +213,21 @@ class ContextMenuActions {
 
     $modal.on('button.clicked', (e: JQueryEventObject): void => {
       if (e.target.getAttribute('name') === 'delete') {
-        Viewport.ContentContainer.setUrl(
-          top.TYPO3.settings.RecordCommit.moduleUrl
-          + '&redirect=' + ContextMenuActions.getReturnUrl()
-          + '&cmd[' + table + '][' + uid + '][delete]=1',
-        ).done((): void => {
-          if (table === 'pages' && Viewport.NavigationContainer.PageTree) {
-            if (uid === top.fsMod.recentIds.web) {
-              let node = Viewport.NavigationContainer.PageTree.instance.nodes[0];
-              Viewport.NavigationContainer.PageTree.selectNode(node);
+        const targetUrl = top.TYPO3.settings.RecordCommit.moduleUrl
+          + '&cmd[' + table + '][' + uid + '][delete]=1';
+
+        $.ajax({
+          url: targetUrl,
+          success: (): void => {
+            if (table === 'pages' && Viewport.NavigationContainer.PageTree) {
+              if (uid === top.fsMod.recentIds.web) {
+                let node = Viewport.NavigationContainer.PageTree.instance.nodes[0];
+                Viewport.NavigationContainer.PageTree.selectNode(node);
+              }
+
+              Viewport.NavigationContainer.PageTree.refreshTree();
             }
-
-            Viewport.NavigationContainer.PageTree.refreshTree();
-          }
+          },
         });
       }
       Modal.dismiss();
index ff33703..3cb8db7 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","./Enum/Severity","jquery","./InfoWindow","./Modal","./ModuleMenu","./Viewport"],function(e,t,n,r,o,a,i,s){"use strict";return function(){function e(){}return e.getReturnUrl=function(){return top.rawurlencode(top.list_frame.document.location.pathname+top.list_frame.document.location.search)},e.editRecord=function(t,n){var o="",a=r(this).data("pages-language-uid");a&&(o="&overrideVals[pages][sys_language_uid]="+a),s.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+t+"]["+n+"]=edit"+o+"&returnUrl="+e.getReturnUrl())},e.viewRecord=function(e,t){var n=r(this).data("preview-url");n&&window.open(n,"newTYPO3frontendWindow").focus()},e.openInfoPopUp=function(e,t){o.showItem(e,t)},e.mountAsTreeRoot=function(e,t){"pages"===e&&s.NavigationContainer.PageTree.setTemporaryMountPoint(t)},e.newPageWizard=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.NewRecord.moduleUrl+"&id="+n+"&pagesOnly=1&returnUrl="+e.getReturnUrl())},e.newContentWizard=function(t,o){var i=r(this),s=i.data("new-wizard-url");s&&(s+="&returnUrl="+e.getReturnUrl(),a.advanced({title:i.data("title"),type:a.types.ajax,size:a.sizes.medium,content:s,severity:n.SeverityEnum.notice}))},e.newRecord=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+t+"][-"+n+"]=new&returnUrl="+e.getReturnUrl())},e.openHistoryPopUp=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.RecordHistory.moduleUrl+"&element="+t+":"+n+"&returnUrl="+e.getReturnUrl())},e.openListModule=function(e,t){var n="pages"===e?t:r(this).data("page-uid");i.App.showModule("web_list","id="+n)},e.pagesSort=function(e,t){var n=r(this).data("pages-sort-url");n&&s.ContentContainer.setUrl(n)},e.pagesNewMultiple=function(e,t){var n=r(this).data("pages-new-multiple-url");n&&s.ContentContainer.setUrl(n)},e.disableRecord=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+t+"]["+n+"][hidden]=1&redirect="+e.getReturnUrl()).done(function(){s.NavigationContainer.PageTree.refreshTree()})},e.enableRecord=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+t+"]["+n+"][hidden]=0&redirect="+e.getReturnUrl()).done(function(){s.NavigationContainer.PageTree.refreshTree()})},e.deleteRecord=function(t,o){var i=r(this);a.confirm(i.data("title"),i.data("message"),n.SeverityEnum.warning,[{text:r(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:r(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",function(n){"delete"===n.target.getAttribute("name")&&s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&redirect="+e.getReturnUrl()+"&cmd["+t+"]["+o+"][delete]=1").done(function(){if("pages"===t&&s.NavigationContainer.PageTree){if(o===top.fsMod.recentIds.web){var e=s.NavigationContainer.PageTree.instance.nodes[0];s.NavigationContainer.PageTree.selectNode(e)}s.NavigationContainer.PageTree.refreshTree()}}),a.dismiss()})},e.copy=function(t,n){var o=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=1&CB[setCopyMode]=1";r.ajax(o).always(function(){e.triggerRefresh(s.ContentContainer.get().location.href)})},e.clipboardRelease=function(t,n){var o=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=0";r.ajax(o).always(function(){e.triggerRefresh(s.ContentContainer.get().location.href)})},e.cut=function(t,n){var o=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=1&CB[setCopyMode]=0";r.ajax(o).always(function(){e.triggerRefresh(s.ContentContainer.get().location.href)})},e.triggerRefresh=function(e){-1===e.indexOf("record%2Fedit")&&s.ContentContainer.refresh(!0)},e.clearCache=function(e,t){var n=top.TYPO3.settings.WebLayout.moduleUrl+"&id="+t+"&clear_cache=1";r.ajax(n)},e.pasteAfter=function(t,n){e.pasteInto.bind(r(this))(t,-n)},e.pasteInto=function(t,o){var i=r(this),l=function(){var n="&CB[paste]="+t+"%7C"+o+"&CB[pad]=normal&redirect="+e.getReturnUrl();s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+n).done(function(){"pages"===t&&s.NavigationContainer.PageTree&&s.NavigationContainer.PageTree.refreshTree()})};i.data("title")?a.confirm(i.data("title"),i.data("message"),n.SeverityEnum.warning,[{text:r(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:r(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",function(e){"ok"===e.target.getAttribute("name")&&l(),a.dismiss()}):l()},e}()});
\ No newline at end of file
+define(["require","exports","./Enum/Severity","jquery","./InfoWindow","./Modal","./ModuleMenu","./Viewport"],function(e,t,n,a,o,r,i,s){"use strict";return function(){function e(){}return e.getReturnUrl=function(){return top.rawurlencode(top.list_frame.document.location.pathname+top.list_frame.document.location.search)},e.editRecord=function(t,n){var o="",r=a(this).data("pages-language-uid");r&&(o="&overrideVals[pages][sys_language_uid]="+r),s.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+t+"]["+n+"]=edit"+o+"&returnUrl="+e.getReturnUrl())},e.viewRecord=function(e,t){var n=a(this).data("preview-url");n&&window.open(n,"newTYPO3frontendWindow").focus()},e.openInfoPopUp=function(e,t){o.showItem(e,t)},e.mountAsTreeRoot=function(e,t){"pages"===e&&s.NavigationContainer.PageTree.setTemporaryMountPoint(t)},e.newPageWizard=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.NewRecord.moduleUrl+"&id="+n+"&pagesOnly=1&returnUrl="+e.getReturnUrl())},e.newContentWizard=function(t,o){var i=a(this),s=i.data("new-wizard-url");s&&(s+="&returnUrl="+e.getReturnUrl(),r.advanced({title:i.data("title"),type:r.types.ajax,size:r.sizes.medium,content:s,severity:n.SeverityEnum.notice}))},e.newRecord=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+t+"][-"+n+"]=new&returnUrl="+e.getReturnUrl())},e.openHistoryPopUp=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.RecordHistory.moduleUrl+"&element="+t+":"+n+"&returnUrl="+e.getReturnUrl())},e.openListModule=function(e,t){var n="pages"===e?t:a(this).data("page-uid");i.App.showModule("web_list","id="+n)},e.pagesSort=function(e,t){var n=a(this).data("pages-sort-url");n&&s.ContentContainer.setUrl(n)},e.pagesNewMultiple=function(e,t){var n=a(this).data("pages-new-multiple-url");n&&s.ContentContainer.setUrl(n)},e.disableRecord=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+t+"]["+n+"][hidden]=1&redirect="+e.getReturnUrl()).done(function(){s.NavigationContainer.PageTree.refreshTree()})},e.enableRecord=function(t,n){s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+t+"]["+n+"][hidden]=0&redirect="+e.getReturnUrl()).done(function(){s.NavigationContainer.PageTree.refreshTree()})},e.deleteRecord=function(e,t){var o=a(this);r.confirm(o.data("title"),o.data("message"),n.SeverityEnum.warning,[{text:a(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",function(n){if("delete"===n.target.getAttribute("name")){var o=top.TYPO3.settings.RecordCommit.moduleUrl+"&cmd["+e+"]["+t+"][delete]=1";a.ajax({url:o,success:function(){if("pages"===e&&s.NavigationContainer.PageTree){if(t===top.fsMod.recentIds.web){var n=s.NavigationContainer.PageTree.instance.nodes[0];s.NavigationContainer.PageTree.selectNode(n)}s.NavigationContainer.PageTree.refreshTree()}}})}r.dismiss()})},e.copy=function(t,n){var o=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=1&CB[setCopyMode]=1";a.ajax(o).always(function(){e.triggerRefresh(s.ContentContainer.get().location.href)})},e.clipboardRelease=function(t,n){var o=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=0";a.ajax(o).always(function(){e.triggerRefresh(s.ContentContainer.get().location.href)})},e.cut=function(t,n){var o=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=1&CB[setCopyMode]=0";a.ajax(o).always(function(){e.triggerRefresh(s.ContentContainer.get().location.href)})},e.triggerRefresh=function(e){-1===e.indexOf("record%2Fedit")&&s.ContentContainer.refresh(!0)},e.clearCache=function(e,t){var n=top.TYPO3.settings.WebLayout.moduleUrl+"&id="+t+"&clear_cache=1";a.ajax(n)},e.pasteAfter=function(t,n){e.pasteInto.bind(a(this))(t,-n)},e.pasteInto=function(t,o){var i=a(this),l=function(){var n="&CB[paste]="+t+"%7C"+o+"&CB[pad]=normal&redirect="+e.getReturnUrl();s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+n).done(function(){"pages"===t&&s.NavigationContainer.PageTree&&s.NavigationContainer.PageTree.refreshTree()})};i.data("title")?r.confirm(i.data("title"),i.data("message"),n.SeverityEnum.warning,[{text:a(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",function(e){"ok"===e.target.getAttribute("name")&&l(),r.dismiss()}):l()},e}()});
\ No newline at end of file