[BUGFIX] Select first element in tree when deleting selected node 91/57791/14
authorPaweł Rogowicz <rogowicz.pawel@gmail.com>
Fri, 3 Aug 2018 13:49:04 +0000 (15:49 +0200)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Thu, 9 Aug 2018 13:06:52 +0000 (15:06 +0200)
This patch fixes a bug which occured when deleting a currently selected
node. After deleting this node the first element of the tree is
displayed.

Releases: master
Resolves: #85431
Change-Id: I64cd7c4ebd8415a2c261da3f62f8e412575b0075
Reviewed-on: https://review.typo3.org/57791
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Łukasz Uznański <l.uznanski@macopedia.pl>
Tested-by: Łukasz Uznański <l.uznanski@macopedia.pl>
Reviewed-by: Joerg Kummer <typo3@enobe.de>
Tested-by: Joerg Kummer <typo3@enobe.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
typo3/sysext/backend/Resources/Private/TypeScript/ContextMenuActions.ts
typo3/sysext/backend/Resources/Private/TypeScript/Viewport/NavigationComponentInterface.ts
typo3/sysext/backend/Resources/Private/TypeScript/Viewport/PageTree.ts
typo3/sysext/backend/Resources/Public/JavaScript/ContextMenuActions.js
typo3/sysext/backend/Resources/Public/JavaScript/PageTree/PageTree.js
typo3/sysext/backend/Resources/Public/JavaScript/Viewport/PageTree.js
typo3/sysext/beuser/Classes/Controller/PermissionController.php

index c902630..3736b45 100644 (file)
@@ -208,6 +208,11 @@ class ContextMenuActions {
           + '&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);
+            }
+
             Viewport.NavigationContainer.PageTree.refreshTree();
           }
         });
index 6114911..d6b61e2 100644 (file)
@@ -21,4 +21,5 @@ export interface NavigationComponentInterface {
   refreshTree: Function;
   setTemporaryMountPoint: SetTemporaryMountPoint;
   unsetTemporaryMountPoint: Function;
+  selectNode: Function;
 }
index 9e0c336..68d97af 100644 (file)
@@ -37,6 +37,12 @@ class PageTree {
       this.instance.unsetTemporaryMountPoint();
     }
   }
+
+  public selectNode(node: object): void {
+    if (this.instance !== null) {
+      this.instance.selectNode(node);
+    }
+  }
 }
 
 export = PageTree;
index af487d7..b1a00fd 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){s.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+t+"]["+n+"]=edit&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(){"pages"===t&&s.NavigationContainer.PageTree&&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,o,r,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){s.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+t+"]["+n+"]=edit&returnUrl="+e.getReturnUrl())},e.viewRecord=function(e,t){var n=o(this).data("preview-url");n&&window.open(n,"newTYPO3frontendWindow").focus()},e.openInfoPopUp=function(e,t){r.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,r){var i=o(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:o(this).data("page-uid");i.App.showModule("web_list","id="+n)},e.pagesSort=function(e,t){var n=o(this).data("pages-sort-url");n&&s.ContentContainer.setUrl(n)},e.pagesNewMultiple=function(e,t){var n=o(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,r){var i=o(this);a.confirm(i.data("title"),i.data("message"),n.SeverityEnum.warning,[{text:o(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o(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+"]["+r+"][delete]=1").done(function(){if("pages"===t&&s.NavigationContainer.PageTree){if(r===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 r=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=1&CB[setCopyMode]=1";o.ajax(r).always(function(){e.triggerRefresh(s.ContentContainer.get().location.href)})},e.clipboardRelease=function(t,n){var r=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=0";o.ajax(r).always(function(){e.triggerRefresh(s.ContentContainer.get().location.href)})},e.cut=function(t,n){var r=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+n+"]=1&CB[setCopyMode]=0";o.ajax(r).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";o.ajax(n)},e.pasteAfter=function(t,n){e.pasteInto.bind(o(this))(t,-n)},e.pasteInto=function(t,r){var i=o(this),l=function(){var n="&CB[paste]="+t+"%7C"+r+"&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:o(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:o(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
index fcfbac7..5797f00 100644 (file)
@@ -138,6 +138,9 @@ define(['jquery',
         params = '&data[pages][' + data.uid + '][' + data.nameSourceField + ']=' + encodeURIComponent(data.title);
       } else {
         if (data.command === 'delete') {
+          if (data.uid === fsMod.recentIds.web) {
+            _this.selectNode(_this.nodes[0]);
+          }
           params = '&cmd[pages][' + data.uid + '][delete]=1';
         } else {
           params = 'cmd[pages][' + data.uid + '][' + data.command + ']=' + targetUid;
index 0ae29c3..d9f8077 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports"],function(n,t){"use strict";return function(){function n(n){this.instance=null,this.instance=n}return n.prototype.refreshTree=function(){null!==this.instance&&this.instance.refreshTree()},n.prototype.setTemporaryMountPoint=function(n){null!==this.instance&&this.instance.setTemporaryMountPoint(n)},n.prototype.unsetTemporaryMountPoint=function(){null!==this.instance&&this.instance.unsetTemporaryMountPoint()},n}()});
\ No newline at end of file
+define(["require","exports"],function(t,n){"use strict";return function(){function t(t){this.instance=null,this.instance=t}return t.prototype.refreshTree=function(){null!==this.instance&&this.instance.refreshTree()},t.prototype.setTemporaryMountPoint=function(t){null!==this.instance&&this.instance.setTemporaryMountPoint(t)},t.prototype.unsetTemporaryMountPoint=function(){null!==this.instance&&this.instance.unsetTemporaryMountPoint()},t.prototype.selectNode=function(t){null!==this.instance&&this.instance.selectNode(t)},t}()});
\ No newline at end of file
index c601bec..7ec762f 100644 (file)
@@ -97,12 +97,16 @@ class PermissionController extends ActionController
             $this->id = (int)$this->request->getArgument('id');
         }
 
+        if (!BackendUtility::getRecord('pages', $this->id)) {
+            $this->id = 0;
+        }
+
         $this->returnUrl = GeneralUtility::_GP('returnUrl');
         if ($this->request->hasArgument('returnUrl')) {
             $this->returnUrl = $this->request->getArgument('returnUrl');
         }
 
-        $this->pageInfo = BackendUtility::readPageAccess($this->id, ' 1=1');
+        $this->setPageInfo();
     }
 
     /**
@@ -113,6 +117,7 @@ class PermissionController extends ActionController
     protected function initializeView(ViewInterface $view)
     {
         parent::initializeView($view);
+        $this->setPageInfo();
         $view->assign(
             'previewUrl',
             BackendUtility::viewOnClick(
@@ -390,6 +395,14 @@ class PermissionController extends ActionController
     }
 
     /**
+     * Check if page record exists and set pageInfo
+     */
+    protected function setPageInfo(): void
+    {
+        $this->pageInfo = BackendUtility::readPageAccess(BackendUtility::getRecord('pages', $this->id) ? $this->id : 0, ' 1=1');
+    }
+
+    /**
      * Returns LanguageService
      *
      * @return \TYPO3\CMS\Core\Localization\LanguageService