diff --git a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ContextMenuActions.ts b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ContextMenuActions.ts index a1d0c06816579671a50af19b42793aeafadee17d..c004142ca3512eeb5424a132b480c7ee47eea958 100644 --- a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ContextMenuActions.ts +++ b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ContextMenuActions.ts @@ -245,7 +245,7 @@ class ContextMenuActions { top.document.dispatchEvent(new CustomEvent('typo3:pagetree:selectFirstNode')); } ContextMenuActions.refreshPageTree(); - } else if (table === 'tt_content' && top.currentModuleLoaded === 'web_layout') { + } else if (table === 'tt_content') { Viewport.ContentContainer.refresh(); } }); diff --git a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/LiveSearch.ts b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/LiveSearch.ts index 0407e4d40e97ea49f9a21a2c6c8ed00c3e49e1eb..048f00c565373edadca2e6815c8c308ba429d67f 100644 --- a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/LiveSearch.ts +++ b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/LiveSearch.ts @@ -19,6 +19,7 @@ import './Input/Clearable'; import {html, render} from 'lit'; import {unsafeHTML} from 'lit/directives/unsafe-html'; import {renderHTML} from 'TYPO3/CMS/Core/lit-helper'; +import {ModuleStateStorage} from 'TYPO3/CMS/Backend/Storage/ModuleStateStorage'; enum Identifiers { containerSelector = '#typo3-cms-backend-backend-toolbaritems-livesearchtoolbaritem', @@ -115,7 +116,7 @@ class LiveSearch { </div> <div class="dropdown-table-column dropdown-table-title"> <a class="dropdown-table-title-ellipsis dropdown-list-link" - href="#" data-pageid="${suggestion.data.pageId}" data-target="${suggestion.data.editLink}"> + data-pageid="${suggestion.data.pageId}" href="${suggestion.data.editLink}"> ${suggestion.data.title} </a> </div> @@ -190,9 +191,12 @@ class LiveSearch { const $autocompleteContainer = $('.' + Identifiers.toolbarItem.substr(1, Identifiers.toolbarItem.length)); $autocompleteContainer.on('click.autocomplete', '.dropdown-list-link', (evt: JQueryEventObject): void => { evt.preventDefault(); - const $me = $(evt.currentTarget); - top.jump($me.data('target'), 'web_list', 'web', $me.data('pageid')); + // Load the list module of the page + ModuleStateStorage.updateWithCurrentMount('web', $me.data('pageid'), true); + const router = document.querySelector('typo3-backend-module-router'); + router.setAttribute('endpoint', $me.attr('href')) + router.setAttribute('module', 'web_list') $searchField.val('').trigger('change'); }); } diff --git a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ModuleMenu.ts b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ModuleMenu.ts index cb0ee6bb91f9e0ff7e2c3c3984e764d7399a8126..2d63a9b4dec36f601cd9e6351289f4d8f47e3160 100644 --- a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ModuleMenu.ts +++ b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ModuleMenu.ts @@ -205,12 +205,16 @@ class ModuleMenu { const result = await response.resolve(); document.getElementById('modulemenu').outerHTML = result.menu; this.initializeModuleMenuEvents(); - if (top.currentModuleLoaded) { - ModuleMenu.highlightModuleMenuItem(top.currentModuleLoaded); + if (this.loadedModule) { + ModuleMenu.highlightModuleMenuItem(this.loadedModule); } }); } + public getCurrentModule(): string|null { + return this.loadedModule; + } + /** * Reloads the frames * @@ -409,38 +413,38 @@ class ModuleMenu { if (!moduleName || this.loadedModule === moduleName) { return; } + const moduleData = getRecordFromName(moduleName); + if (!moduleData.link) { + return; + } + ModuleMenu.highlightModuleMenuItem(moduleName); $('#' + moduleName).focus(); this.loadedModule = moduleName; - const moduleData = getRecordFromName(moduleName); - - // compatibility - if (moduleData.link) { - top.currentSubScript = moduleData.link; - } + // compatibility, will be removed in TYPO3 v12.0. + top.currentSubScript = moduleData.link; + // compatibility, will be removed in TYPO3 v12.0. top.currentModuleLoaded = moduleName; // Synchronisze navigation container if module is a standalone module (linked via ModuleMenu). // Do not hide navigation for intermediate modules like record_edit, which may be used // with our without a navigation component, depending on the context. - if (moduleData.link) { - if (moduleData.navigationComponentId) { - Viewport.NavigationContainer.showComponent(moduleData.navigationComponentId); - } else if (moduleData.navigationFrameScript) { - Viewport.NavigationContainer.show('typo3-navigationIframe'); - const interactionRequest = new ClientRequest('typo3.showModule', event); - this.openInNavFrame( - moduleData.navigationFrameScript, - moduleData.navigationFrameScriptParam, - new TriggerRequest( - 'typo3.loadModuleComponents', - new ClientRequest('typo3.showModule', null) - ), - ); - } else { - Viewport.NavigationContainer.hide(false); - } + if (moduleData.navigationComponentId) { + Viewport.NavigationContainer.showComponent(moduleData.navigationComponentId); + } else if (moduleData.navigationFrameScript) { + Viewport.NavigationContainer.show('typo3-navigationIframe'); + const interactionRequest = new ClientRequest('typo3.showModule', event); + this.openInNavFrame( + moduleData.navigationFrameScript, + moduleData.navigationFrameScriptParam, + new TriggerRequest( + 'typo3.loadModuleComponents', + new ClientRequest('typo3.showModule', null) + ), + ); + } else { + Viewport.NavigationContainer.hide(false); } }; document.addEventListener('typo3-module-load', moduleLoadListener); @@ -495,8 +499,9 @@ class ModuleMenu { ), ); - // compatibility + // compatibility, will be removed in TYPO3 v12.0. top.currentSubScript = moduleData.link; + // compatibility, will be removed in TYPO3 v12.0. top.currentModuleLoaded = moduleName; }); return deferred; @@ -538,6 +543,7 @@ class ModuleMenu { let deferred; if (top.nextLoadModuleUrl) { + console.warn('Using nextLoadModuleUrl is deprecated, and will not work in TYPO3 v12.0. anymores.'); deferred = Viewport.ContentContainer.setUrl( top.nextLoadModuleUrl, new TriggerRequest('typo3.openInContentFrame', interactionRequest), diff --git a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/PageTree/PageTreeElement.ts b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/PageTree/PageTreeElement.ts index 5da6f3bcca07a1803fd7f830830efa1a49bf13f1..81b2ef4ed1baf6e87a66847d7ab5b1d59d9c2d01 100644 --- a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/PageTree/PageTreeElement.ts +++ b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/PageTree/PageTreeElement.ts @@ -20,6 +20,7 @@ import {TreeNode} from './../Tree/TreeNode'; import AjaxRequest from 'TYPO3/CMS/Core/Ajax/AjaxRequest'; import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse'; import Persistent from 'TYPO3/CMS/Backend/Storage/Persistent'; +import {getRecordFromName} from '../Module'; import ContextMenu = require('../ContextMenu'); import * as d3selection from 'd3-selection'; import {KeyTypesEnum as KeyTypes} from 'TYPO3/CMS/Backend/Enum/KeyTypes'; @@ -405,14 +406,11 @@ export class PageTreeNavigationComponent extends LitElement { return; } - let separator = '?'; - if (top.window.currentSubScript.indexOf('?') !== -1) { - separator = '&'; - } - - top.TYPO3.Backend.ContentContainer.setUrl( - top.window.currentSubScript + separator + 'id=' + node.identifier - ); + // Load the currently selected module with the updated URL + const moduleMenu = top.TYPO3.ModuleMenu.App; + let contentUrl = getRecordFromName(moduleMenu.getCurrentModule()).link; + contentUrl += contentUrl.includes('?') ? '&' : '?'; + top.TYPO3.Backend.ContentContainer.setUrl(contentUrl + 'id=' + node.identifier); } private showContextMenu = (evt: CustomEvent): void => { diff --git a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Toolbar/ShortcutMenu.ts b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Toolbar/ShortcutMenu.ts index 44b56317f2f37395b56b06b36649a1ffe04951c3..47217cbda31c21451ff86c6a6b030fa65618011a 100644 --- a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Toolbar/ShortcutMenu.ts +++ b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Toolbar/ShortcutMenu.ts @@ -19,6 +19,7 @@ import Modal = require('../Modal'); import Notification = require('../Notification'); import Viewport = require('../Viewport'); import SecurityUtility from 'TYPO3/CMS/Core/SecurityUtility'; +import {ModuleStateStorage} from 'TYPO3/CMS/Backend/Storage/ModuleStateStorage'; enum Identifiers { containerSelector = '#typo3-cms-backend-backend-toolbaritems-shortcuttoolbaritem', @@ -26,6 +27,7 @@ enum Identifiers { toolbarMenuSelector = '.dropdown-menu', shortcutItemSelector = '.t3js-topbar-shortcut', + shortcutJumpSelector = '.t3js-shortcut-jump', shortcutDeleteSelector = '.t3js-shortcut-delete', shortcutEditSelector = '.t3js-shortcut-edit', @@ -122,6 +124,16 @@ class ShortcutMenu { evt.preventDefault(); evt.stopImmediatePropagation(); this.refreshMenu(); + }).on('click', Identifiers.shortcutJumpSelector, (evt: JQueryEventObject): void => { + evt.preventDefault(); + evt.stopImmediatePropagation(); + const pageId = $(evt.currentTarget).data('pageid'); + if (pageId) { + ModuleStateStorage.updateWithCurrentMount('web', pageId, true); + } + const router = document.querySelector('typo3-backend-module-router'); + router.setAttribute('endpoint', $(evt.currentTarget).attr('href')) + router.setAttribute('module', $(evt.currentTarget).data('module')); }); } diff --git a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Tree/FileStorageTreeContainer.ts b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Tree/FileStorageTreeContainer.ts index b4dc7e17cf8f5acc4171b33068275b170815a94b..2b702d799c274e73763f078e94899ad230163ee0 100644 --- a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Tree/FileStorageTreeContainer.ts +++ b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Tree/FileStorageTreeContainer.ts @@ -26,6 +26,7 @@ import Notification = require('../Notification'); import AjaxRequest from 'TYPO3/CMS/Core/Ajax/AjaxRequest'; import {TreeNodeSelection, Toolbar} from '../SvgTree'; import {ModuleStateStorage} from '../Storage/ModuleStateStorage'; +import {getRecordFromName} from '../Module'; export const navigationComponentName: string = 'typo3-backend-navigation-component-filestoragetree'; @@ -156,10 +157,11 @@ export class FileStorageTreeNavigationComponent extends LitElement { return; } - const separator = (window.currentSubScript.indexOf('?') !== -1) ? '&' : '?'; - TYPO3.Backend.ContentContainer.setUrl( - window.currentSubScript + separator + 'id=' + node.identifier - ); + // Load the currently selected module with the updated URL + const moduleMenu = top.TYPO3.ModuleMenu.App; + let contentUrl = getRecordFromName(moduleMenu.getCurrentModule()).link; + contentUrl += contentUrl.includes('?') ? '&' : '?'; + top.TYPO3.Backend.ContentContainer.setUrl(contentUrl + 'id=' + node.identifier); } private showContextMenu = (evt: CustomEvent): void => { diff --git a/Build/Sources/TypeScript/opendocs/Resources/Public/TypeScript/Toolbar/OpendocsMenu.ts b/Build/Sources/TypeScript/opendocs/Resources/Public/TypeScript/Toolbar/OpendocsMenu.ts index f06eff1f729c93141a2db8578ba4f63d9e87b200..2b5708379f877348c41d9b14aaf9fdc35808d748 100644 --- a/Build/Sources/TypeScript/opendocs/Resources/Public/TypeScript/Toolbar/OpendocsMenu.ts +++ b/Build/Sources/TypeScript/opendocs/Resources/Public/TypeScript/Toolbar/OpendocsMenu.ts @@ -16,6 +16,7 @@ import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse'; import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest'); import Icons = require('TYPO3/CMS/Backend/Icons'); import Viewport = require('TYPO3/CMS/Backend/Viewport'); +import {ModuleStateStorage} from 'TYPO3/CMS/Backend/Storage/ModuleStateStorage'; enum Selectors { containerSelector = '#typo3-cms-opendocs-backend-toolbaritems-opendocstoolbaritem', @@ -84,7 +85,9 @@ class OpendocsMenu { const $entry = $(evt.currentTarget); this.toggleMenu(); - window.jump($entry.attr('href'), 'web_list', 'web', $entry.data('pid')); + ModuleStateStorage.updateWithCurrentMount('web', $entry.data('pid'), true); + const router = document.querySelector('typo3-backend-module-router'); + router.setAttribute('endpoint', $entry.attr('href')) }); } diff --git a/Build/Sources/TypeScript/workspaces/Resources/Public/TypeScript/Toolbar/WorkspacesMenu.ts b/Build/Sources/TypeScript/workspaces/Resources/Public/TypeScript/Toolbar/WorkspacesMenu.ts index e8a0f5906528ca2c61a9f8958a7832db038d77fd..8c0aa893ffb5634dc0035702891a8d825d53a440 100644 --- a/Build/Sources/TypeScript/workspaces/Resources/Public/TypeScript/Toolbar/WorkspacesMenu.ts +++ b/Build/Sources/TypeScript/workspaces/Resources/Public/TypeScript/Toolbar/WorkspacesMenu.ts @@ -154,22 +154,18 @@ class WorkspacesMenu { this.performWorkspaceSwitch(parseInt(data.workspaceId, 10)); + const currentModule = ModuleMenu.App.getCurrentModule(); // append the returned page ID to the current module URL if (data.pageId) { - // @todo actually that's superfluous, since that information was known already when doing the AJAX call - ModuleStateStorage.update('web', data.pageId, true); let url = TYPO3.Backend.ContentContainer.getUrl(); - url += (!url.includes('?') ? '?' : '&') + '&id=' + data.pageId; - WorkspacesMenu.refreshPageTree(); + url += (!url.includes('?') ? '?' : '&') + 'id=' + data.pageId; Viewport.ContentContainer.setUrl(url); // when in web module reload, otherwise send the user to the web module - } else if (top.currentModuleLoaded.startsWith('web_')) { - WorkspacesMenu.refreshPageTree(); - - if (top.currentModuleLoaded === 'web_WorkspacesWorkspaces') { + } else if (currentModule.startsWith('web_')) { + if (currentModule === 'web_WorkspacesWorkspaces') { // Reload the workspace module and override the workspace id - ModuleMenu.App.showModule(top.currentModuleLoaded, 'workspace=' + workspaceId); + ModuleMenu.App.showModule(currentModule, 'workspace=' + workspaceId); } else { ModuleMenu.App.reloadFrames(); } @@ -177,6 +173,8 @@ class WorkspacesMenu { ModuleMenu.App.showModule(TYPO3.configuration.pageModule); } + // Refresh the pagetree if visible + WorkspacesMenu.refreshPageTree(); // reload the module menu ModuleMenu.App.refreshMenu(); }); diff --git a/typo3/sysext/backend/Classes/Backend/Shortcut/ShortcutRepository.php b/typo3/sysext/backend/Classes/Backend/Shortcut/ShortcutRepository.php index 9228f25b2d09541fca89c9573b464233662aab2f..d6b2c7f705ca6da22c18a57b0b66ae7ccc7531ad 100644 --- a/typo3/sysext/backend/Classes/Backend/Shortcut/ShortcutRepository.php +++ b/typo3/sysext/backend/Classes/Backend/Shortcut/ShortcutRepository.php @@ -578,11 +578,10 @@ class ShortcutRepository $shortcut['group'] = $shortcutGroup; $shortcut['icon'] = $this->getShortcutIcon($routeIdentifier, $moduleName, $shortcut); $shortcut['label'] = $description; - $shortcut['action'] = 'jump(' - . GeneralUtility::quoteJSvalue($shortcutUrl) - . ',' . GeneralUtility::quoteJSvalue($moduleName) - . ',' . GeneralUtility::quoteJSvalue($moduleName) - . ', ' . $pageId . ');'; + $shortcut['href'] = $shortcutUrl; + $shortcut['route'] = $routeIdentifier; + $shortcut['module'] = $moduleName; + $shortcut['pageId'] = $pageId; $shortcuts[] = $shortcut; } diff --git a/typo3/sysext/backend/Resources/Private/Partials/ShortcutToolbarItem/Shortcut.html b/typo3/sysext/backend/Resources/Private/Partials/ShortcutToolbarItem/Shortcut.html index a893c7e0cdc943cfc535142eb95c7a8f3f7d39ad..0d129901c8d8c7d37237496a616b8fa45f23aef3 100644 --- a/typo3/sysext/backend/Resources/Private/Partials/ShortcutToolbarItem/Shortcut.html +++ b/typo3/sysext/backend/Resources/Private/Partials/ShortcutToolbarItem/Shortcut.html @@ -1,6 +1,6 @@ <div class="dropdown-table-row t3js-topbar-shortcut" data-shortcutid="{shortcut.raw.uid}" data-shortcutgroup="{group.id}"> <div class="dropdown-table-column dropdown-table-title"> - <a href="#" class="dropdown-table-title-ellipsis" onclick="{shortcut.action} return false;"> + <a href="{shortcut.href}" class="dropdown-table-title-ellipsis t3js-shortcut-jump" data-module="{shortcut.module}" data-route="{shortcut.route}" data-pageid="{shortcut.pageId}"> <span title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:toolbarItems.shortcut')}"> <f:format.raw>{shortcut.icon}</f:format.raw> </span> diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/ContextMenuActions.js b/typo3/sysext/backend/Resources/Public/JavaScript/ContextMenuActions.js index 0234f012631657f08d71cba4e87026992c6a320f..81b06a9217ab5d64954b4f39ecbbad92315368e8 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/ContextMenuActions.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/ContextMenuActions.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","./Enum/Severity","jquery","./AjaxDataHandler","TYPO3/CMS/Core/Ajax/AjaxRequest","./InfoWindow","./Modal","./ModuleMenu","TYPO3/CMS/Backend/Notification","./Viewport","./Storage/ModuleStateStorage"],(function(e,t,n,a,r,o,s,i,l,d,c,u){"use strict";a=__importDefault(a);class g{static getReturnUrl(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)}static editRecord(e,t){let n="",r=a.default(this).data("pages-language-uid");r&&(n="&overrideVals[pages][sys_language_uid]="+r),c.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+e+"]["+t+"]=edit"+n+"&returnUrl="+g.getReturnUrl())}static viewRecord(){const e=a.default(this).data("preview-url");if(e){window.open(e,"newTYPO3frontendWindow").focus()}}static openInfoPopUp(e,t){s.showItem(e,t)}static mountAsTreeRoot(e,t){if("pages"===e){const e=new CustomEvent("typo3:pagetree:mountPoint",{detail:{pageId:t}});top.document.dispatchEvent(e)}}static newPageWizard(e,t){c.ContentContainer.setUrl(top.TYPO3.settings.NewRecord.moduleUrl+"&id="+t+"&pagesOnly=1&returnUrl="+g.getReturnUrl())}static newContentWizard(){const e=a.default(this);let t=e.data("new-wizard-url");t&&(t+="&returnUrl="+g.getReturnUrl(),i.advanced({title:e.data("title"),type:i.types.ajax,size:i.sizes.medium,content:t,severity:n.SeverityEnum.notice}))}static newRecord(e,t){c.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+e+"][-"+t+"]=new&returnUrl="+g.getReturnUrl())}static openHistoryPopUp(e,t){c.ContentContainer.setUrl(top.TYPO3.settings.RecordHistory.moduleUrl+"&element="+e+":"+t+"&returnUrl="+g.getReturnUrl())}static openListModule(e,t){const n="pages"===e?t:a.default(this).data("page-uid");l.App.showModule("web_list","id="+n)}static pagesSort(){const e=a.default(this).data("pages-sort-url");e&&c.ContentContainer.setUrl(e)}static pagesNewMultiple(){const e=a.default(this).data("pages-new-multiple-url");e&&c.ContentContainer.setUrl(e)}static disableRecord(e,t){const n=a.default(this).data("disable-field")||"hidden";c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"]["+n+"]=1&redirect="+g.getReturnUrl()).done(()=>{g.refreshPageTree()})}static enableRecord(e,t){const n=a.default(this).data("disable-field")||"hidden";c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"]["+n+"]=0&redirect="+g.getReturnUrl()).done(()=>{g.refreshPageTree()})}static showInMenus(e,t){c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][nav_hide]=0&redirect="+g.getReturnUrl()).done(()=>{g.refreshPageTree()})}static hideInMenus(e,t){c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][nav_hide]=1&redirect="+g.getReturnUrl()).done(()=>{g.refreshPageTree()})}static deleteRecord(e,t){const o=a.default(this);i.confirm(o.data("title"),o.data("message"),n.SeverityEnum.warning,[{text:a.default(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a.default(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",n=>{if("delete"===n.target.getAttribute("name")){const n={component:"contextmenu",action:"delete",table:e,uid:t};r.process("cmd["+e+"]["+t+"][delete]=1",n).then(()=>{"pages"===e?(u.ModuleStateStorage.current("web").identifier===t.toString()&&top.document.dispatchEvent(new CustomEvent("typo3:pagetree:selectFirstNode")),g.refreshPageTree()):"tt_content"===e&&"web_layout"===top.currentModuleLoaded&&c.ContentContainer.refresh()})}i.dismiss()})}static copy(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=1&CB[setCopyMode]=1";new o(n).get().finally(()=>{g.triggerRefresh(c.ContentContainer.get().location.href)})}static clipboardRelease(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=0";new o(n).get().finally(()=>{g.triggerRefresh(c.ContentContainer.get().location.href)})}static cut(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=1&CB[setCopyMode]=0";new o(n).get().finally(()=>{g.triggerRefresh(c.ContentContainer.get().location.href)})}static triggerRefresh(e){e.includes("record%2Fedit")||c.ContentContainer.refresh()}static clearCache(e,t){new o(TYPO3.settings.ajaxUrls.web_list_clearpagecache).withQueryArguments({id:t}).get({cache:"no-cache"}).then(async e=>{const t=await e.resolve();!0===t.success?d.success(t.title,t.message,1):d.error(t.title,t.message,1)},()=>{d.error("Clearing page caches went wrong on the server side.")})}static pasteAfter(e,t){g.pasteInto.bind(a.default(this))(e,-t)}static pasteInto(e,t){const r=a.default(this),o=()=>{const n="&CB[paste]="+e+"%7C"+t+"&CB[pad]=normal&redirect="+g.getReturnUrl();c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+n).done(()=>{"pages"===e&&g.refreshPageTree()})};if(!r.data("title"))return void o();i.confirm(r.data("title"),r.data("message"),n.SeverityEnum.warning,[{text:a.default(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a.default(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",e=>{"ok"===e.target.getAttribute("name")&&o(),i.dismiss()})}static refreshPageTree(){top.document.dispatchEvent(new CustomEvent("typo3:pagetree:refresh"))}}return g})); \ No newline at end of file +var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","./Enum/Severity","jquery","./AjaxDataHandler","TYPO3/CMS/Core/Ajax/AjaxRequest","./InfoWindow","./Modal","./ModuleMenu","TYPO3/CMS/Backend/Notification","./Viewport","./Storage/ModuleStateStorage"],(function(e,t,n,a,r,o,s,i,l,d,c,u){"use strict";a=__importDefault(a);class g{static getReturnUrl(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)}static editRecord(e,t){let n="",r=a.default(this).data("pages-language-uid");r&&(n="&overrideVals[pages][sys_language_uid]="+r),c.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+e+"]["+t+"]=edit"+n+"&returnUrl="+g.getReturnUrl())}static viewRecord(){const e=a.default(this).data("preview-url");if(e){window.open(e,"newTYPO3frontendWindow").focus()}}static openInfoPopUp(e,t){s.showItem(e,t)}static mountAsTreeRoot(e,t){if("pages"===e){const e=new CustomEvent("typo3:pagetree:mountPoint",{detail:{pageId:t}});top.document.dispatchEvent(e)}}static newPageWizard(e,t){c.ContentContainer.setUrl(top.TYPO3.settings.NewRecord.moduleUrl+"&id="+t+"&pagesOnly=1&returnUrl="+g.getReturnUrl())}static newContentWizard(){const e=a.default(this);let t=e.data("new-wizard-url");t&&(t+="&returnUrl="+g.getReturnUrl(),i.advanced({title:e.data("title"),type:i.types.ajax,size:i.sizes.medium,content:t,severity:n.SeverityEnum.notice}))}static newRecord(e,t){c.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+e+"][-"+t+"]=new&returnUrl="+g.getReturnUrl())}static openHistoryPopUp(e,t){c.ContentContainer.setUrl(top.TYPO3.settings.RecordHistory.moduleUrl+"&element="+e+":"+t+"&returnUrl="+g.getReturnUrl())}static openListModule(e,t){const n="pages"===e?t:a.default(this).data("page-uid");l.App.showModule("web_list","id="+n)}static pagesSort(){const e=a.default(this).data("pages-sort-url");e&&c.ContentContainer.setUrl(e)}static pagesNewMultiple(){const e=a.default(this).data("pages-new-multiple-url");e&&c.ContentContainer.setUrl(e)}static disableRecord(e,t){const n=a.default(this).data("disable-field")||"hidden";c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"]["+n+"]=1&redirect="+g.getReturnUrl()).done(()=>{g.refreshPageTree()})}static enableRecord(e,t){const n=a.default(this).data("disable-field")||"hidden";c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"]["+n+"]=0&redirect="+g.getReturnUrl()).done(()=>{g.refreshPageTree()})}static showInMenus(e,t){c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][nav_hide]=0&redirect="+g.getReturnUrl()).done(()=>{g.refreshPageTree()})}static hideInMenus(e,t){c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][nav_hide]=1&redirect="+g.getReturnUrl()).done(()=>{g.refreshPageTree()})}static deleteRecord(e,t){const o=a.default(this);i.confirm(o.data("title"),o.data("message"),n.SeverityEnum.warning,[{text:a.default(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a.default(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",n=>{if("delete"===n.target.getAttribute("name")){const n={component:"contextmenu",action:"delete",table:e,uid:t};r.process("cmd["+e+"]["+t+"][delete]=1",n).then(()=>{"pages"===e?(u.ModuleStateStorage.current("web").identifier===t.toString()&&top.document.dispatchEvent(new CustomEvent("typo3:pagetree:selectFirstNode")),g.refreshPageTree()):"tt_content"===e&&c.ContentContainer.refresh()})}i.dismiss()})}static copy(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=1&CB[setCopyMode]=1";new o(n).get().finally(()=>{g.triggerRefresh(c.ContentContainer.get().location.href)})}static clipboardRelease(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=0";new o(n).get().finally(()=>{g.triggerRefresh(c.ContentContainer.get().location.href)})}static cut(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=1&CB[setCopyMode]=0";new o(n).get().finally(()=>{g.triggerRefresh(c.ContentContainer.get().location.href)})}static triggerRefresh(e){e.includes("record%2Fedit")||c.ContentContainer.refresh()}static clearCache(e,t){new o(TYPO3.settings.ajaxUrls.web_list_clearpagecache).withQueryArguments({id:t}).get({cache:"no-cache"}).then(async e=>{const t=await e.resolve();!0===t.success?d.success(t.title,t.message,1):d.error(t.title,t.message,1)},()=>{d.error("Clearing page caches went wrong on the server side.")})}static pasteAfter(e,t){g.pasteInto.bind(a.default(this))(e,-t)}static pasteInto(e,t){const r=a.default(this),o=()=>{const n="&CB[paste]="+e+"%7C"+t+"&CB[pad]=normal&redirect="+g.getReturnUrl();c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+n).done(()=>{"pages"===e&&g.refreshPageTree()})};if(!r.data("title"))return void o();i.confirm(r.data("title"),r.data("message"),n.SeverityEnum.warning,[{text:a.default(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a.default(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",e=>{"ok"===e.target.getAttribute("name")&&o(),i.dismiss()})}static refreshPageTree(){top.document.dispatchEvent(new CustomEvent("typo3:pagetree:refresh"))}}return g})); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js b/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js index 3dff2cdacb82ca681b664315ee66f4ddcca0752f..6129af1fb72bf3dbb0aa706a4a429354bc0bc67e 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js @@ -10,8 +10,8 @@ * * The TYPO3 project - inspiring people to share! */ -var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","jquery","./Viewport","./Icons","lit","lit/directives/unsafe-html","TYPO3/CMS/Core/lit-helper","jquery/autocomplete","./Input/Clearable"],(function(e,t,l,o,a,r,s,n){"use strict";var i;l=__importDefault(l),function(e){e.containerSelector="#typo3-cms-backend-backend-toolbaritems-livesearchtoolbaritem",e.toolbarItem=".t3js-toolbar-item-search",e.dropdownToggle=".t3js-toolbar-search-dropdowntoggle",e.searchFieldSelector=".t3js-topbar-navigation-search-field",e.formSelector=".t3js-topbar-navigation-search"}(i||(i={}));return new class{constructor(){this.url=TYPO3.settings.ajaxUrls.livesearch,o.Topbar.Toolbar.registerEvent(()=>{let e;this.registerAutocomplete(),this.registerEvents(),l.default(i.toolbarItem).removeAttr("style"),null!==(e=document.querySelector(i.searchFieldSelector))&&e.clearable({onClear:()=>{l.default(i.dropdownToggle).hasClass("show")&&l.default(i.dropdownToggle).dropdown("toggle")}})})}registerAutocomplete(){l.default(i.searchFieldSelector).autocomplete({serviceUrl:this.url,paramName:"q",dataType:"json",minChars:2,width:"100%",groupBy:"typeLabel",noCache:!0,containerClass:i.toolbarItem.substr(1,i.toolbarItem.length),appendTo:i.containerSelector+" .dropdown-menu",forceFixPosition:!1,preserveInput:!0,showNoSuggestionNotice:!0,triggerSelectOnValidInput:!1,preventBadQueries:!1,noSuggestionNotice:'<h3 class="dropdown-headline">'+TYPO3.lang.liveSearch_listEmptyText+"</h3><p>"+TYPO3.lang.liveSearch_helpTitle+"</p><hr><p>"+TYPO3.lang.liveSearch_helpDescription+"<br>"+TYPO3.lang.liveSearch_helpDescriptionPages+"</p>",transformResult:e=>({suggestions:l.default.map(e,e=>({value:e.title,data:e}))}),formatGroup:(e,t,l)=>n.renderHTML(r.html` - ${l>0?r.html`<hr>`:""} +var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","jquery","./Viewport","./Icons","lit","lit/directives/unsafe-html","TYPO3/CMS/Core/lit-helper","TYPO3/CMS/Backend/Storage/ModuleStateStorage","jquery/autocomplete","./Input/Clearable"],(function(e,t,o,l,a,r,s,n,d){"use strict";var i;o=__importDefault(o),function(e){e.containerSelector="#typo3-cms-backend-backend-toolbaritems-livesearchtoolbaritem",e.toolbarItem=".t3js-toolbar-item-search",e.dropdownToggle=".t3js-toolbar-search-dropdowntoggle",e.searchFieldSelector=".t3js-topbar-navigation-search-field",e.formSelector=".t3js-topbar-navigation-search"}(i||(i={}));return new class{constructor(){this.url=TYPO3.settings.ajaxUrls.livesearch,l.Topbar.Toolbar.registerEvent(()=>{let e;this.registerAutocomplete(),this.registerEvents(),o.default(i.toolbarItem).removeAttr("style"),null!==(e=document.querySelector(i.searchFieldSelector))&&e.clearable({onClear:()=>{o.default(i.dropdownToggle).hasClass("show")&&o.default(i.dropdownToggle).dropdown("toggle")}})})}registerAutocomplete(){o.default(i.searchFieldSelector).autocomplete({serviceUrl:this.url,paramName:"q",dataType:"json",minChars:2,width:"100%",groupBy:"typeLabel",noCache:!0,containerClass:i.toolbarItem.substr(1,i.toolbarItem.length),appendTo:i.containerSelector+" .dropdown-menu",forceFixPosition:!1,preserveInput:!0,showNoSuggestionNotice:!0,triggerSelectOnValidInput:!1,preventBadQueries:!1,noSuggestionNotice:'<h3 class="dropdown-headline">'+TYPO3.lang.liveSearch_listEmptyText+"</h3><p>"+TYPO3.lang.liveSearch_helpTitle+"</p><hr><p>"+TYPO3.lang.liveSearch_helpDescription+"<br>"+TYPO3.lang.liveSearch_helpDescriptionPages+"</p>",transformResult:e=>({suggestions:o.default.map(e,e=>({value:e.title,data:e}))}),formatGroup:(e,t,o)=>n.renderHTML(r.html` + ${o>0?r.html`<hr>`:""} <h3 class="dropdown-headline">${t}</h3> `),formatResult:e=>n.renderHTML(r.html` <div class="dropdown-table"> @@ -21,10 +21,10 @@ var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModu </div> <div class="dropdown-table-column dropdown-table-title"> <a class="dropdown-table-title-ellipsis dropdown-list-link" - href="#" data-pageid="${e.data.pageId}" data-target="${e.data.editLink}"> + data-pageid="${e.data.pageId}" href="${e.data.editLink}"> ${e.data.title} </a> </div> </div> </div> - `),onSearchStart:()=>{const e=l.default(i.toolbarItem);e.hasClass("loading")||(e.addClass("loading"),a.getIcon("spinner-circle-light",a.sizes.small,"",a.states.default,a.markupIdentifiers.inline).then(t=>{e.find(".icon-apps-toolbar-menu-search").replaceWith(t)}))},onSearchComplete:()=>{const e=l.default(i.toolbarItem),t=l.default(i.searchFieldSelector);!l.default(i.dropdownToggle).hasClass("show")&&t.val().length>1&&(l.default(i.dropdownToggle).dropdown("toggle"),t.focus()),e.hasClass("loading")&&(e.removeClass("loading"),a.getIcon("apps-toolbar-menu-search",a.sizes.small,"",a.states.default,a.markupIdentifiers.inline).then(t=>{e.find(".icon-spinner-circle-light").replaceWith(t)}))},beforeRender:e=>{e.append('<hr><div><a href="#" class="btn btn-primary pull-right t3js-live-search-show-all">'+TYPO3.lang.liveSearch_showAllResults+"</a></div>"),l.default(i.dropdownToggle).hasClass("show")||(l.default(i.dropdownToggle).dropdown("show"),l.default(i.searchFieldSelector).focus())},onHide:()=>{l.default(i.dropdownToggle).hasClass("show")&&l.default(i.dropdownToggle).dropdown("hide")}})}registerEvents(){const e=l.default(i.searchFieldSelector);if(l.default(i.containerSelector).on("click",".t3js-live-search-show-all",t=>{t.preventDefault(),TYPO3.ModuleMenu.App.showModule("web_list","id=0&search_levels=-1&search_field="+encodeURIComponent(e.val())),e.val("").trigger("change")}),e.length){l.default("."+i.toolbarItem.substr(1,i.toolbarItem.length)).on("click.autocomplete",".dropdown-list-link",t=>{t.preventDefault();const o=l.default(t.currentTarget);top.jump(o.data("target"),"web_list","web",o.data("pageid")),e.val("").trigger("change")})}l.default(i.formSelector).on("submit",e=>{e.preventDefault()})}}})); \ No newline at end of file + `),onSearchStart:()=>{const e=o.default(i.toolbarItem);e.hasClass("loading")||(e.addClass("loading"),a.getIcon("spinner-circle-light",a.sizes.small,"",a.states.default,a.markupIdentifiers.inline).then(t=>{e.find(".icon-apps-toolbar-menu-search").replaceWith(t)}))},onSearchComplete:()=>{const e=o.default(i.toolbarItem),t=o.default(i.searchFieldSelector);!o.default(i.dropdownToggle).hasClass("show")&&t.val().length>1&&(o.default(i.dropdownToggle).dropdown("toggle"),t.focus()),e.hasClass("loading")&&(e.removeClass("loading"),a.getIcon("apps-toolbar-menu-search",a.sizes.small,"",a.states.default,a.markupIdentifiers.inline).then(t=>{e.find(".icon-spinner-circle-light").replaceWith(t)}))},beforeRender:e=>{e.append('<hr><div><a href="#" class="btn btn-primary pull-right t3js-live-search-show-all">'+TYPO3.lang.liveSearch_showAllResults+"</a></div>"),o.default(i.dropdownToggle).hasClass("show")||(o.default(i.dropdownToggle).dropdown("show"),o.default(i.searchFieldSelector).focus())},onHide:()=>{o.default(i.dropdownToggle).hasClass("show")&&o.default(i.dropdownToggle).dropdown("hide")}})}registerEvents(){const e=o.default(i.searchFieldSelector);if(o.default(i.containerSelector).on("click",".t3js-live-search-show-all",t=>{t.preventDefault(),TYPO3.ModuleMenu.App.showModule("web_list","id=0&search_levels=-1&search_field="+encodeURIComponent(e.val())),e.val("").trigger("change")}),e.length){o.default("."+i.toolbarItem.substr(1,i.toolbarItem.length)).on("click.autocomplete",".dropdown-list-link",t=>{t.preventDefault();const l=o.default(t.currentTarget);d.ModuleStateStorage.updateWithCurrentMount("web",l.data("pageid"),!0);const a=document.querySelector("typo3-backend-module-router");a.setAttribute("endpoint",l.attr("href")),a.setAttribute("module","web_list"),e.val("").trigger("change")})}o.default(i.formSelector).on("submit",e=>{e.preventDefault()})}}})); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js b/typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js index a869c7e5c3cd33cccdeb0869d7742bf2bbe74b00..a227aa23532f011cb2eee88ac417e60429f28844 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","./Enum/Viewport/ScaffoldIdentifier","./Module","jquery","./Storage/Persistent","./Viewport","./Event/ClientRequest","./Event/TriggerRequest","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Core/Event/RegularEvent","./Storage/ModuleStateStorage"],(function(e,t,n,o,a,l,i,r,s,d,u,m){"use strict";a=__importDefault(a);class c{constructor(){this.loadedModule=null,this.spaceKeyPressedOnCollapsible=!1,a.default(()=>this.initialize())}static getCollapsedMainMenuItems(){return l.isset("modulemenu")?JSON.parse(l.get("modulemenu")):{}}static addCollapsedMainMenuItem(e){const t=c.getCollapsedMainMenuItems();t[e]=!0,l.set("modulemenu",JSON.stringify(t))}static removeCollapseMainMenuItem(e){const t=this.getCollapsedMainMenuItems();delete t[e],l.set("modulemenu",JSON.stringify(t))}static includeId(e,t){if(!e.navigationComponentId&&!e.navigationFrameScript)return t;let n="";n="TYPO3/CMS/Backend/PageTree/PageTreeElement"===e.navigationComponentId?"web":e.name.split("_")[0];const o=m.ModuleStateStorage.current(n);return o.selection&&(t="id="+o.selection+"&"+t),t}static toggleMenu(e){const t=a.default(n.ScaffoldIdentifierEnum.scaffold);void 0===e&&(e=t.hasClass("scaffold-modulemenu-expanded")),t.toggleClass("scaffold-modulemenu-expanded",!e),e||a.default(".scaffold").removeClass("scaffold-search-expanded").removeClass("scaffold-toolbar-expanded"),l.set("BackendComponents.States.typo3-module-menu",{collapsed:e})}static toggleModuleGroup(e){const t=e.closest(".modulemenu-group"),n=t.querySelector(".modulemenu-group-container"),o="true"===e.attributes.getNamedItem("aria-expanded").value;o?c.addCollapsedMainMenuItem(e.id):c.removeCollapseMainMenuItem(e.id),t.classList.toggle("modulemenu-group-collapsed",o),t.classList.toggle("modulemenu-group-expanded",!o),e.attributes.getNamedItem("aria-expanded").value=(!o).toString(),a.default(n).stop().slideToggle()}static highlightModuleMenuItem(e){a.default(".modulemenu-action.modulemenu-action-active").removeClass("modulemenu-action-active").removeAttr("aria-current"),a.default("#"+e).addClass("modulemenu-action-active").attr("aria-current","location")}static getPreviousItem(e){let t=e.parentElement.previousElementSibling;return null===t?c.getLastItem(e):t.firstElementChild}static getNextItem(e){let t=e.parentElement.nextElementSibling;return null===t?c.getFirstItem(e):t.firstElementChild}static getFirstItem(e){return e.parentElement.parentElement.firstElementChild.firstElementChild}static getLastItem(e){return e.parentElement.parentElement.lastElementChild.firstElementChild}static getParentItem(e){return e.parentElement.parentElement.parentElement.firstElementChild}static getFirstChildItem(e){return e.nextElementSibling.firstElementChild.firstElementChild}static getLastChildItem(e){return e.nextElementSibling.lastElementChild.firstElementChild}refreshMenu(){new d(TYPO3.settings.ajaxUrls.modulemenu).get().then(async e=>{const t=await e.resolve();document.getElementById("modulemenu").outerHTML=t.menu,this.initializeModuleMenuEvents(),top.currentModuleLoaded&&c.highlightModuleMenuItem(top.currentModuleLoaded)})}reloadFrames(){i.NavigationContainer.refresh(),i.ContentContainer.refresh()}showModule(e,t,n=null){t=t||"";const a=o.getRecordFromName(e);return this.loadModuleComponents(a,t,new r("typo3.showModule",n))}initialize(){if(null===document.querySelector(".t3js-modulemenu"))return;let e=a.default.Deferred();e.resolve(),e.then(()=>{this.initializeModuleMenuEvents(),i.Topbar.Toolbar.registerEvent(()=>{document.querySelector(".t3js-scaffold-toolbar")&&this.initializeTopBarEvents()})})}keyboardNavigation(e,t,n=!1){const o=t.parentElement.attributes.getNamedItem("data-level").value;let a=null;switch(n&&(this.spaceKeyPressedOnCollapsible=!1),e.code){case"ArrowUp":a=c.getPreviousItem(t);break;case"ArrowDown":a=c.getNextItem(t);break;case"ArrowLeft":"1"===o&&t.classList.contains("t3js-modulemenu-collapsible")?("false"===t.attributes.getNamedItem("aria-expanded").value&&c.toggleModuleGroup(t),a=c.getLastChildItem(t)):"2"===o&&(a=c.getPreviousItem(c.getParentItem(t)));break;case"ArrowRight":"1"===o&&t.classList.contains("t3js-modulemenu-collapsible")?("false"===t.attributes.getNamedItem("aria-expanded").value&&c.toggleModuleGroup(t),a=c.getFirstChildItem(t)):"2"===o&&(a=c.getNextItem(c.getParentItem(t)));break;case"Home":a=e.ctrlKey&&"2"===o?c.getFirstItem(c.getParentItem(t)):c.getFirstItem(t);break;case"End":a=e.ctrlKey&&"2"===o?c.getLastItem(c.getParentItem(t)):c.getLastItem(t);break;case"Space":case"Enter":"1"===o&&t.classList.contains("t3js-modulemenu-collapsible")&&("Enter"===e.code&&e.preventDefault(),c.toggleModuleGroup(t),"true"===t.attributes.getNamedItem("aria-expanded").value&&(a=c.getFirstChildItem(t),"Space"===e.code&&(this.spaceKeyPressedOnCollapsible=!0)));break;case"Esc":case"Escape":"2"===o&&(a=c.getParentItem(t),c.toggleModuleGroup(a));break;default:a=null}null!==a&&(e.defaultPrevented||e.preventDefault(),a.focus())}initializeModuleMenuEvents(){const e=document.querySelector(".t3js-modulemenu"),t=function(e){"Space"===e.code&&this.spaceKeyPressedOnCollapsible&&(e.preventDefault(),this.spaceKeyPressedOnCollapsible=!1)}.bind(this);new u("keydown",this.keyboardNavigation).delegateTo(e,".t3js-modulemenu-action"),e.querySelectorAll('[data-level="2"] .t3js-modulemenu-action[data-link]').forEach(e=>{e.addEventListener("keyup",t)}),new u("keyup",(e,t)=>{"Space"===e.code&&e.preventDefault()}).delegateTo(e,".t3js-modulemenu-collapsible"),new u("click",(e,t)=>{e.preventDefault(),this.showModule(t.id,"",e)}).delegateTo(e,".t3js-modulemenu-action[data-link]"),new u("click",(e,t)=>{e.preventDefault(),c.toggleModuleGroup(t)}).delegateTo(e,".t3js-modulemenu-collapsible")}initializeTopBarEvents(){const e=document.querySelector(".t3js-scaffold-toolbar");new u("keydown",(e,t)=>{this.keyboardNavigation(e,t)}).delegateTo(e,".t3js-modulemenu-action"),new u("click",(e,t)=>{e.preventDefault(),this.showModule(t.id,"",e)}).delegateTo(e,".t3js-modulemenu-action[data-link]"),new u("click",e=>{e.preventDefault(),c.toggleMenu()}).bindTo(document.querySelector(".t3js-topbar-button-modulemenu")),new u("click",e=>{e.preventDefault(),c.toggleMenu(!0)}).bindTo(document.querySelector(".t3js-scaffold-content-overlay"));const t=e=>{const t=e.detail.module;if(!t||this.loadedModule===t)return;c.highlightModuleMenuItem(t),a.default("#"+t).focus(),this.loadedModule=t;const n=o.getRecordFromName(t);if(n.link&&(top.currentSubScript=n.link),top.currentModuleLoaded=t,n.link)if(n.navigationComponentId)i.NavigationContainer.showComponent(n.navigationComponentId);else if(n.navigationFrameScript){i.NavigationContainer.show("typo3-navigationIframe");new r("typo3.showModule",event);this.openInNavFrame(n.navigationFrameScript,n.navigationFrameScriptParam,new s("typo3.loadModuleComponents",new r("typo3.showModule",null)))}else i.NavigationContainer.hide(!1)};document.addEventListener("typo3-module-load",t),document.addEventListener("typo3-module-loaded",t)}loadModuleComponents(e,t,n){const o=e.name,a=i.ContentContainer.beforeSetUrl(n);return a.then(()=>{e.navigationComponentId?i.NavigationContainer.showComponent(e.navigationComponentId):e.navigationFrameScript?(i.NavigationContainer.show("typo3-navigationIframe"),this.openInNavFrame(e.navigationFrameScript,e.navigationFrameScriptParam,new s("typo3.loadModuleComponents",n))):i.NavigationContainer.hide(!0),c.highlightModuleMenuItem(o),this.loadedModule=o,t=c.includeId(e,t),this.openInContentContainer(o,e.link,t,new s("typo3.loadModuleComponents",n)),top.currentSubScript=e.link,top.currentModuleLoaded=o}),a}openInNavFrame(e,t,n){const o=e+(t?(e.includes("?")?"&":"?")+t:""),a=i.NavigationContainer.getUrl(),l=i.NavigationContainer.setUrl(e,new s("typo3.openInNavFrame",n));return a!==o&&("resolved"===l.state()?i.NavigationContainer.refresh():l.then(i.NavigationContainer.refresh)),l}openInContentContainer(e,t,n,o){let a;if(top.nextLoadModuleUrl)a=i.ContentContainer.setUrl(top.nextLoadModuleUrl,new s("typo3.openInContentFrame",o),null),top.nextLoadModuleUrl="";else{const l=t+(n?(t.includes("?")?"&":"?")+n:"");a=i.ContentContainer.setUrl(l,new s("typo3.openInContentFrame",o),e)}return a}}top.TYPO3.ModuleMenu||(top.TYPO3.ModuleMenu={App:new c});return top.TYPO3.ModuleMenu})); \ No newline at end of file +var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","./Enum/Viewport/ScaffoldIdentifier","./Module","jquery","./Storage/Persistent","./Viewport","./Event/ClientRequest","./Event/TriggerRequest","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Core/Event/RegularEvent","./Storage/ModuleStateStorage"],(function(e,t,n,o,a,l,i,r,s,d,u,m){"use strict";a=__importDefault(a);class c{constructor(){this.loadedModule=null,this.spaceKeyPressedOnCollapsible=!1,a.default(()=>this.initialize())}static getCollapsedMainMenuItems(){return l.isset("modulemenu")?JSON.parse(l.get("modulemenu")):{}}static addCollapsedMainMenuItem(e){const t=c.getCollapsedMainMenuItems();t[e]=!0,l.set("modulemenu",JSON.stringify(t))}static removeCollapseMainMenuItem(e){const t=this.getCollapsedMainMenuItems();delete t[e],l.set("modulemenu",JSON.stringify(t))}static includeId(e,t){if(!e.navigationComponentId&&!e.navigationFrameScript)return t;let n="";n="TYPO3/CMS/Backend/PageTree/PageTreeElement"===e.navigationComponentId?"web":e.name.split("_")[0];const o=m.ModuleStateStorage.current(n);return o.selection&&(t="id="+o.selection+"&"+t),t}static toggleMenu(e){const t=a.default(n.ScaffoldIdentifierEnum.scaffold);void 0===e&&(e=t.hasClass("scaffold-modulemenu-expanded")),t.toggleClass("scaffold-modulemenu-expanded",!e),e||a.default(".scaffold").removeClass("scaffold-search-expanded").removeClass("scaffold-toolbar-expanded"),l.set("BackendComponents.States.typo3-module-menu",{collapsed:e})}static toggleModuleGroup(e){const t=e.closest(".modulemenu-group"),n=t.querySelector(".modulemenu-group-container"),o="true"===e.attributes.getNamedItem("aria-expanded").value;o?c.addCollapsedMainMenuItem(e.id):c.removeCollapseMainMenuItem(e.id),t.classList.toggle("modulemenu-group-collapsed",o),t.classList.toggle("modulemenu-group-expanded",!o),e.attributes.getNamedItem("aria-expanded").value=(!o).toString(),a.default(n).stop().slideToggle()}static highlightModuleMenuItem(e){a.default(".modulemenu-action.modulemenu-action-active").removeClass("modulemenu-action-active").removeAttr("aria-current"),a.default("#"+e).addClass("modulemenu-action-active").attr("aria-current","location")}static getPreviousItem(e){let t=e.parentElement.previousElementSibling;return null===t?c.getLastItem(e):t.firstElementChild}static getNextItem(e){let t=e.parentElement.nextElementSibling;return null===t?c.getFirstItem(e):t.firstElementChild}static getFirstItem(e){return e.parentElement.parentElement.firstElementChild.firstElementChild}static getLastItem(e){return e.parentElement.parentElement.lastElementChild.firstElementChild}static getParentItem(e){return e.parentElement.parentElement.parentElement.firstElementChild}static getFirstChildItem(e){return e.nextElementSibling.firstElementChild.firstElementChild}static getLastChildItem(e){return e.nextElementSibling.lastElementChild.firstElementChild}refreshMenu(){new d(TYPO3.settings.ajaxUrls.modulemenu).get().then(async e=>{const t=await e.resolve();document.getElementById("modulemenu").outerHTML=t.menu,this.initializeModuleMenuEvents(),this.loadedModule&&c.highlightModuleMenuItem(this.loadedModule)})}getCurrentModule(){return this.loadedModule}reloadFrames(){i.NavigationContainer.refresh(),i.ContentContainer.refresh()}showModule(e,t,n=null){t=t||"";const a=o.getRecordFromName(e);return this.loadModuleComponents(a,t,new r("typo3.showModule",n))}initialize(){if(null===document.querySelector(".t3js-modulemenu"))return;let e=a.default.Deferred();e.resolve(),e.then(()=>{this.initializeModuleMenuEvents(),i.Topbar.Toolbar.registerEvent(()=>{document.querySelector(".t3js-scaffold-toolbar")&&this.initializeTopBarEvents()})})}keyboardNavigation(e,t,n=!1){const o=t.parentElement.attributes.getNamedItem("data-level").value;let a=null;switch(n&&(this.spaceKeyPressedOnCollapsible=!1),e.code){case"ArrowUp":a=c.getPreviousItem(t);break;case"ArrowDown":a=c.getNextItem(t);break;case"ArrowLeft":"1"===o&&t.classList.contains("t3js-modulemenu-collapsible")?("false"===t.attributes.getNamedItem("aria-expanded").value&&c.toggleModuleGroup(t),a=c.getLastChildItem(t)):"2"===o&&(a=c.getPreviousItem(c.getParentItem(t)));break;case"ArrowRight":"1"===o&&t.classList.contains("t3js-modulemenu-collapsible")?("false"===t.attributes.getNamedItem("aria-expanded").value&&c.toggleModuleGroup(t),a=c.getFirstChildItem(t)):"2"===o&&(a=c.getNextItem(c.getParentItem(t)));break;case"Home":a=e.ctrlKey&&"2"===o?c.getFirstItem(c.getParentItem(t)):c.getFirstItem(t);break;case"End":a=e.ctrlKey&&"2"===o?c.getLastItem(c.getParentItem(t)):c.getLastItem(t);break;case"Space":case"Enter":"1"===o&&t.classList.contains("t3js-modulemenu-collapsible")&&("Enter"===e.code&&e.preventDefault(),c.toggleModuleGroup(t),"true"===t.attributes.getNamedItem("aria-expanded").value&&(a=c.getFirstChildItem(t),"Space"===e.code&&(this.spaceKeyPressedOnCollapsible=!0)));break;case"Esc":case"Escape":"2"===o&&(a=c.getParentItem(t),c.toggleModuleGroup(a));break;default:a=null}null!==a&&(e.defaultPrevented||e.preventDefault(),a.focus())}initializeModuleMenuEvents(){const e=document.querySelector(".t3js-modulemenu"),t=function(e){"Space"===e.code&&this.spaceKeyPressedOnCollapsible&&(e.preventDefault(),this.spaceKeyPressedOnCollapsible=!1)}.bind(this);new u("keydown",this.keyboardNavigation).delegateTo(e,".t3js-modulemenu-action"),e.querySelectorAll('[data-level="2"] .t3js-modulemenu-action[data-link]').forEach(e=>{e.addEventListener("keyup",t)}),new u("keyup",(e,t)=>{"Space"===e.code&&e.preventDefault()}).delegateTo(e,".t3js-modulemenu-collapsible"),new u("click",(e,t)=>{e.preventDefault(),this.showModule(t.id,"",e)}).delegateTo(e,".t3js-modulemenu-action[data-link]"),new u("click",(e,t)=>{e.preventDefault(),c.toggleModuleGroup(t)}).delegateTo(e,".t3js-modulemenu-collapsible")}initializeTopBarEvents(){const e=document.querySelector(".t3js-scaffold-toolbar");new u("keydown",(e,t)=>{this.keyboardNavigation(e,t)}).delegateTo(e,".t3js-modulemenu-action"),new u("click",(e,t)=>{e.preventDefault(),this.showModule(t.id,"",e)}).delegateTo(e,".t3js-modulemenu-action[data-link]"),new u("click",e=>{e.preventDefault(),c.toggleMenu()}).bindTo(document.querySelector(".t3js-topbar-button-modulemenu")),new u("click",e=>{e.preventDefault(),c.toggleMenu(!0)}).bindTo(document.querySelector(".t3js-scaffold-content-overlay"));const t=e=>{const t=e.detail.module;if(!t||this.loadedModule===t)return;const n=o.getRecordFromName(t);if(n.link)if(c.highlightModuleMenuItem(t),a.default("#"+t).focus(),this.loadedModule=t,top.currentSubScript=n.link,top.currentModuleLoaded=t,n.navigationComponentId)i.NavigationContainer.showComponent(n.navigationComponentId);else if(n.navigationFrameScript){i.NavigationContainer.show("typo3-navigationIframe");new r("typo3.showModule",event);this.openInNavFrame(n.navigationFrameScript,n.navigationFrameScriptParam,new s("typo3.loadModuleComponents",new r("typo3.showModule",null)))}else i.NavigationContainer.hide(!1)};document.addEventListener("typo3-module-load",t),document.addEventListener("typo3-module-loaded",t)}loadModuleComponents(e,t,n){const o=e.name,a=i.ContentContainer.beforeSetUrl(n);return a.then(()=>{e.navigationComponentId?i.NavigationContainer.showComponent(e.navigationComponentId):e.navigationFrameScript?(i.NavigationContainer.show("typo3-navigationIframe"),this.openInNavFrame(e.navigationFrameScript,e.navigationFrameScriptParam,new s("typo3.loadModuleComponents",n))):i.NavigationContainer.hide(!0),c.highlightModuleMenuItem(o),this.loadedModule=o,t=c.includeId(e,t),this.openInContentContainer(o,e.link,t,new s("typo3.loadModuleComponents",n)),top.currentSubScript=e.link,top.currentModuleLoaded=o}),a}openInNavFrame(e,t,n){const o=e+(t?(e.includes("?")?"&":"?")+t:""),a=i.NavigationContainer.getUrl(),l=i.NavigationContainer.setUrl(e,new s("typo3.openInNavFrame",n));return a!==o&&("resolved"===l.state()?i.NavigationContainer.refresh():l.then(i.NavigationContainer.refresh)),l}openInContentContainer(e,t,n,o){let a;if(top.nextLoadModuleUrl)console.warn("Using nextLoadModuleUrl is deprecated, and will not work in TYPO3 v12.0. anymores."),a=i.ContentContainer.setUrl(top.nextLoadModuleUrl,new s("typo3.openInContentFrame",o),null),top.nextLoadModuleUrl="";else{const l=t+(n?(t.includes("?")?"&":"?")+n:"");a=i.ContentContainer.setUrl(l,new s("typo3.openInContentFrame",o),e)}return a}}top.TYPO3.ModuleMenu||(top.TYPO3.ModuleMenu={App:new c});return top.TYPO3.ModuleMenu})); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/PageTree/PageTreeElement.js b/typo3/sysext/backend/Resources/Public/JavaScript/PageTree/PageTreeElement.js index db2f01f5aaca8c946a5f7c38533777a197eaad59..2e0f83e8315dcfdd839dce70a42d24d613acbdcf 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/PageTree/PageTreeElement.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/PageTree/PageTreeElement.js @@ -10,7 +10,7 @@ * * The TYPO3 project - inspiring people to share! */ -var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,i,o){void 0===o&&(o=i),Object.defineProperty(e,o,{enumerable:!0,get:function(){return t[i]}})}:function(e,t,i,o){void 0===o&&(o=i),e[o]=t[i]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__decorate=this&&this.__decorate||function(e,t,i,o){var n,s=arguments.length,r=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(s<3?n(r):s>3?n(t,i,r):n(t,i))||r);return s>3&&r&&Object.defineProperty(t,i,r),r},__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&__createBinding(t,e,i);return __setModuleDefault(t,e),t},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","lit","lit/decorators","lit/directives/until","TYPO3/CMS/Core/lit-helper","./PageTree","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/Storage/Persistent","../ContextMenu","d3-selection","TYPO3/CMS/Backend/Enum/KeyTypes","../SvgTree","../Tree/DragDrop","../Modal","../Severity","../Storage/ModuleStateStorage"],(function(e,t,i,o,n,s,r,a,d,l,h,p,c,g,u,m,v){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PageTreeNavigationComponent=t.EditablePageTree=t.navigationComponentName=void 0,a=__importDefault(a),d=__importDefault(d),h=__importStar(h),t.navigationComponentName="typo3-backend-navigation-component-pagetree";let f=class extends r.PageTree{selectFirstNode(){this.selectNode(this.nodes[0],!0)}sendChangeCommand(e){let t="",i=0;if(e.target&&(i=e.target.identifier,"after"===e.position&&(i=-i)),"new"===e.command)t="&data[pages][NEW_1][pid]="+i+"&data[pages][NEW_1][title]="+encodeURIComponent(e.name)+"&data[pages][NEW_1][doktype]="+e.type;else if("edit"===e.command)t="&data[pages]["+e.uid+"]["+e.nameSourceField+"]="+encodeURIComponent(e.title);else if("delete"===e.command){const i=v.ModuleStateStorage.current("web");e.uid===i.identifier&&this.selectFirstNode(),t="&cmd[pages]["+e.uid+"][delete]=1"}else t="cmd[pages]["+e.uid+"]["+e.command+"]="+i;this.requestTreeUpdate(t).then(e=>{e&&e.hasErrors?(this.errorNotification(e.messages,!1),this.nodesContainer.selectAll(".node").remove(),this.updateVisibleNodes(),this.nodesRemovePlaceholder()):this.refreshOrFilterTree()})}switchFocusNode(e){this.nodeIsEdit||this.switchFocus(this.getNodeElement(e))}nodesUpdate(e){return super.nodesUpdate.call(this,e).call(this.initializeDragForNode())}updateNodeBgClass(e){return super.updateNodeBgClass.call(this,e).call(this.initializeDragForNode())}initializeDragForNode(){return this.dragDrop.connectDragHandler(new N(this,this.dragDrop))}removeEditedText(){const e=h.selectAll(".node-edit");if(e.size())try{e.remove(),this.nodeIsEdit=!1}catch(e){}}appendTextElement(e){let t=0;return super.appendTextElement(e).on("click",(e,i)=>{"0"!==i.identifier?1==++t&&setTimeout(()=>{1===t?this.selectNode(i,!0):this.editNodeLabel(i),t=0},300):this.selectNode(i,!0)})}sendEditNodeLabelCommand(e){const t="&data[pages]["+e.identifier+"]["+e.nameSourceField+"]="+encodeURIComponent(e.newName);this.requestTreeUpdate(t,e).then(t=>{t&&t.hasErrors?this.errorNotification(t.messages,!1):e.name=e.newName,this.refreshOrFilterTree()})}requestTreeUpdate(e,t=null){return this.nodesAddPlaceholder(t),new a.default(top.TYPO3.settings.ajaxUrls.record_process).post(e,{headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"}}).then(e=>e.resolve()).catch(e=>{this.errorNotification(e,!0)})}editNodeLabel(e){e.allowEdit&&(this.removeEditedText(),this.nodeIsEdit=!0,h.select(this.svg.node().parentNode).append("input").attr("class","node-edit").style("top",()=>e.y+this.settings.marginTop+"px").style("left",e.x+this.textPosition+5+"px").style("width",this.settings.width-(e.x+this.textPosition+20)+"px").style("height",this.settings.nodeHeight+"px").attr("type","text").attr("value",e.name).on("keydown",t=>{const i=t.keyCode;if(i===p.KeyTypesEnum.ENTER||i===p.KeyTypesEnum.TAB){const i=t.target.value.trim();this.nodeIsEdit=!1,this.removeEditedText(),i.length&&i!==e.name&&(e.nameSourceField=e.nameSourceField||"title",e.newName=i,this.sendEditNodeLabelCommand(e))}else i===p.KeyTypesEnum.ESCAPE&&(this.nodeIsEdit=!1,this.removeEditedText())}).on("blur",t=>{if(!this.nodeIsEdit)return;const i=t.target.value.trim();i.length&&i!==e.name&&(e.nameSourceField=e.nameSourceField||"title",e.newName=i,this.sendEditNodeLabelCommand(e)),this.removeEditedText()}).node().select())}};f=__decorate([o.customElement("typo3-backend-navigation-component-pagetree-tree")],f),t.EditablePageTree=f;let D=class extends i.LitElement{constructor(){super(...arguments),this.mountPointPath=null,this.configuration=null,this.refresh=()=>{this.tree.refreshOrFilterTree()},this.setMountPoint=e=>{this.setTemporaryMountPoint(e.detail.pageId)},this.selectFirstNode=()=>{this.tree.selectFirstNode()},this.toggleExpandState=e=>{const t=e.detail.node;t&&d.default.set("BackendComponents.States.Pagetree.stateHash."+t.stateIdentifier,t.expanded?"1":"0")},this.loadContent=e=>{const t=e.detail.node;if(!(null==t?void 0:t.checked))return;if(v.ModuleStateStorage.update("web",t.identifier,!0,t.stateIdentifier.split("_")[0]),!1===e.detail.propagate)return;let i="?";-1!==top.window.currentSubScript.indexOf("?")&&(i="&"),top.TYPO3.Backend.ContentContainer.setUrl(top.window.currentSubScript+i+"id="+t.identifier)},this.showContextMenu=e=>{const t=e.detail.node;t&&l.show(t.itemType,parseInt(t.identifier,10),"tree","","",this.tree.getNodeElement(t))},this.selectActiveNode=e=>{const t=v.ModuleStateStorage.current("web").selection;let i=e.detail.nodes;e.detail.nodes=i.map(e=>(e.stateIdentifier===t&&(e.checked=!0),e))}}connectedCallback(){super.connectedCallback(),document.addEventListener("typo3:pagetree:refresh",this.refresh),document.addEventListener("typo3:pagetree:mountPoint",this.setMountPoint),document.addEventListener("typo3:pagetree:selectFirstNode",this.selectFirstNode)}disconnectedCallback(){document.removeEventListener("typo3:pagetree:refresh",this.refresh),document.removeEventListener("typo3:pagetree:mountPoint",this.setMountPoint),document.removeEventListener("typo3:pagetree:selectFirstNode",this.selectFirstNode),super.disconnectedCallback()}createRenderRoot(){return this}render(){return i.html` +var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,i,o){void 0===o&&(o=i),Object.defineProperty(e,o,{enumerable:!0,get:function(){return t[i]}})}:function(e,t,i,o){void 0===o&&(o=i),e[o]=t[i]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__decorate=this&&this.__decorate||function(e,t,i,o){var n,s=arguments.length,r=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(s<3?n(r):s>3?n(t,i,r):n(t,i))||r);return s>3&&r&&Object.defineProperty(t,i,r),r},__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&__createBinding(t,e,i);return __setModuleDefault(t,e),t},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","lit","lit/decorators","lit/directives/until","TYPO3/CMS/Core/lit-helper","./PageTree","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/Storage/Persistent","../Module","../ContextMenu","d3-selection","TYPO3/CMS/Backend/Enum/KeyTypes","../SvgTree","../Tree/DragDrop","../Modal","../Severity","../Storage/ModuleStateStorage"],(function(e,t,i,o,n,s,r,a,d,l,h,p,c,g,u,m,v,f){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PageTreeNavigationComponent=t.EditablePageTree=t.navigationComponentName=void 0,a=__importDefault(a),d=__importDefault(d),p=__importStar(p),t.navigationComponentName="typo3-backend-navigation-component-pagetree";let D=class extends r.PageTree{selectFirstNode(){this.selectNode(this.nodes[0],!0)}sendChangeCommand(e){let t="",i=0;if(e.target&&(i=e.target.identifier,"after"===e.position&&(i=-i)),"new"===e.command)t="&data[pages][NEW_1][pid]="+i+"&data[pages][NEW_1][title]="+encodeURIComponent(e.name)+"&data[pages][NEW_1][doktype]="+e.type;else if("edit"===e.command)t="&data[pages]["+e.uid+"]["+e.nameSourceField+"]="+encodeURIComponent(e.title);else if("delete"===e.command){const i=f.ModuleStateStorage.current("web");e.uid===i.identifier&&this.selectFirstNode(),t="&cmd[pages]["+e.uid+"][delete]=1"}else t="cmd[pages]["+e.uid+"]["+e.command+"]="+i;this.requestTreeUpdate(t).then(e=>{e&&e.hasErrors?(this.errorNotification(e.messages,!1),this.nodesContainer.selectAll(".node").remove(),this.updateVisibleNodes(),this.nodesRemovePlaceholder()):this.refreshOrFilterTree()})}switchFocusNode(e){this.nodeIsEdit||this.switchFocus(this.getNodeElement(e))}nodesUpdate(e){return super.nodesUpdate.call(this,e).call(this.initializeDragForNode())}updateNodeBgClass(e){return super.updateNodeBgClass.call(this,e).call(this.initializeDragForNode())}initializeDragForNode(){return this.dragDrop.connectDragHandler(new T(this,this.dragDrop))}removeEditedText(){const e=p.selectAll(".node-edit");if(e.size())try{e.remove(),this.nodeIsEdit=!1}catch(e){}}appendTextElement(e){let t=0;return super.appendTextElement(e).on("click",(e,i)=>{"0"!==i.identifier?1==++t&&setTimeout(()=>{1===t?this.selectNode(i,!0):this.editNodeLabel(i),t=0},300):this.selectNode(i,!0)})}sendEditNodeLabelCommand(e){const t="&data[pages]["+e.identifier+"]["+e.nameSourceField+"]="+encodeURIComponent(e.newName);this.requestTreeUpdate(t,e).then(t=>{t&&t.hasErrors?this.errorNotification(t.messages,!1):e.name=e.newName,this.refreshOrFilterTree()})}requestTreeUpdate(e,t=null){return this.nodesAddPlaceholder(t),new a.default(top.TYPO3.settings.ajaxUrls.record_process).post(e,{headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"}}).then(e=>e.resolve()).catch(e=>{this.errorNotification(e,!0)})}editNodeLabel(e){e.allowEdit&&(this.removeEditedText(),this.nodeIsEdit=!0,p.select(this.svg.node().parentNode).append("input").attr("class","node-edit").style("top",()=>e.y+this.settings.marginTop+"px").style("left",e.x+this.textPosition+5+"px").style("width",this.settings.width-(e.x+this.textPosition+20)+"px").style("height",this.settings.nodeHeight+"px").attr("type","text").attr("value",e.name).on("keydown",t=>{const i=t.keyCode;if(i===c.KeyTypesEnum.ENTER||i===c.KeyTypesEnum.TAB){const i=t.target.value.trim();this.nodeIsEdit=!1,this.removeEditedText(),i.length&&i!==e.name&&(e.nameSourceField=e.nameSourceField||"title",e.newName=i,this.sendEditNodeLabelCommand(e))}else i===c.KeyTypesEnum.ESCAPE&&(this.nodeIsEdit=!1,this.removeEditedText())}).on("blur",t=>{if(!this.nodeIsEdit)return;const i=t.target.value.trim();i.length&&i!==e.name&&(e.nameSourceField=e.nameSourceField||"title",e.newName=i,this.sendEditNodeLabelCommand(e)),this.removeEditedText()}).node().select())}};D=__decorate([o.customElement("typo3-backend-navigation-component-pagetree-tree")],D),t.EditablePageTree=D;let y=class extends i.LitElement{constructor(){super(...arguments),this.mountPointPath=null,this.configuration=null,this.refresh=()=>{this.tree.refreshOrFilterTree()},this.setMountPoint=e=>{this.setTemporaryMountPoint(e.detail.pageId)},this.selectFirstNode=()=>{this.tree.selectFirstNode()},this.toggleExpandState=e=>{const t=e.detail.node;t&&d.default.set("BackendComponents.States.Pagetree.stateHash."+t.stateIdentifier,t.expanded?"1":"0")},this.loadContent=e=>{const t=e.detail.node;if(!(null==t?void 0:t.checked))return;if(f.ModuleStateStorage.update("web",t.identifier,!0,t.stateIdentifier.split("_")[0]),!1===e.detail.propagate)return;const i=top.TYPO3.ModuleMenu.App;let o=l.getRecordFromName(i.getCurrentModule()).link;o+=o.includes("?")?"&":"?",top.TYPO3.Backend.ContentContainer.setUrl(o+"id="+t.identifier)},this.showContextMenu=e=>{const t=e.detail.node;t&&h.show(t.itemType,parseInt(t.identifier,10),"tree","","",this.tree.getNodeElement(t))},this.selectActiveNode=e=>{const t=f.ModuleStateStorage.current("web").selection;let i=e.detail.nodes;e.detail.nodes=i.map(e=>(e.stateIdentifier===t&&(e.checked=!0),e))}}connectedCallback(){super.connectedCallback(),document.addEventListener("typo3:pagetree:refresh",this.refresh),document.addEventListener("typo3:pagetree:mountPoint",this.setMountPoint),document.addEventListener("typo3:pagetree:selectFirstNode",this.selectFirstNode)}disconnectedCallback(){document.removeEventListener("typo3:pagetree:refresh",this.refresh),document.removeEventListener("typo3:pagetree:mountPoint",this.setMountPoint),document.removeEventListener("typo3:pagetree:selectFirstNode",this.selectFirstNode),super.disconnectedCallback()}createRenderRoot(){return this}render(){return i.html` <div id="typo3-pagetree" class="svg-tree"> ${n.until(this.renderTree(),this.renderLoader())} </div> @@ -19,7 +19,7 @@ var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,i,o) <typo3-backend-navigation-component-pagetree-toolbar id="typo3-pagetree-toolbar" class="svg-toolbar" .tree="${this.tree}"></typo3-backend-navigation-component-pagetree-toolbar> <div id="typo3-pagetree-treeContainer" class="navigation-tree-container"> ${this.renderMountPoint()} - <typo3-backend-navigation-component-pagetree-tree id="typo3-pagetree-tree" class="svg-tree-wrapper" .setup=${e} @svg-tree:initialized=${()=>{this.tree.dragDrop=new b(this.tree),this.toolbar.tree=this.tree,this.tree.addEventListener("typo3:svg-tree:expand-toggle",this.toggleExpandState),this.tree.addEventListener("typo3:svg-tree:node-selected",this.loadContent),this.tree.addEventListener("typo3:svg-tree:node-context",this.showContextMenu),this.tree.addEventListener("typo3:svg-tree:nodes-prepared",this.selectActiveNode)}}></typo3-backend-navigation-component-pagetree-tree> + <typo3-backend-navigation-component-pagetree-tree id="typo3-pagetree-tree" class="svg-tree-wrapper" .setup=${e} @svg-tree:initialized=${()=>{this.tree.dragDrop=new P(this.tree),this.toolbar.tree=this.tree,this.tree.addEventListener("typo3:svg-tree:expand-toggle",this.toggleExpandState),this.tree.addEventListener("typo3:svg-tree:node-selected",this.loadContent),this.tree.addEventListener("typo3:svg-tree:node-context",this.showContextMenu),this.tree.addEventListener("typo3:svg-tree:nodes-prepared",this.selectActiveNode)}}></typo3-backend-navigation-component-pagetree-tree> </div> </div> ${this.renderLoader()} @@ -35,7 +35,7 @@ var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,i,o) <typo3-backend-icon identifier="actions-close" size="small"></typo3-backend-icon> </div> </div> - `}setTemporaryMountPoint(e){new a.default(this.configuration.setTemporaryMountPointUrl).post("pid="+e,{headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"}}).then(e=>e.resolve()).then(e=>{e&&e.hasErrors?(this.tree.errorNotification(e.message,!0),this.tree.updateVisibleNodes()):(this.mountPointPath=e.mountPointPath,this.tree.refreshOrFilterTree())}).catch(e=>{this.tree.errorNotification(e,!0)})}};__decorate([o.property({type:String})],D.prototype,"mountPointPath",void 0),__decorate([o.query(".svg-tree-wrapper")],D.prototype,"tree",void 0),__decorate([o.query("typo3-backend-navigation-component-pagetree-toolbar")],D.prototype,"toolbar",void 0),D=__decorate([o.customElement(t.navigationComponentName)],D),t.PageTreeNavigationComponent=D;let y=class extends c.Toolbar{constructor(){super(...arguments),this.tree=null}initializeDragDrop(e){var t,i,o;(null===(o=null===(i=null===(t=this.tree)||void 0===t?void 0:t.settings)||void 0===i?void 0:i.doktypes)||void 0===o?void 0:o.length)&&this.tree.settings.doktypes.forEach(t=>{if(t.icon){const i=this.querySelector('[data-tree-icon="'+t.icon+'"]');h.select(i).call(this.dragToolbar(t,e))}else console.warn("Missing icon definition for doktype: "+t.nodeType)})}updated(e){e.forEach((e,t)=>{"tree"===t&&null!==this.tree&&this.initializeDragDrop(this.tree.dragDrop)})}render(){var e,t,o;return i.html` + `}setTemporaryMountPoint(e){new a.default(this.configuration.setTemporaryMountPointUrl).post("pid="+e,{headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"}}).then(e=>e.resolve()).then(e=>{e&&e.hasErrors?(this.tree.errorNotification(e.message,!0),this.tree.updateVisibleNodes()):(this.mountPointPath=e.mountPointPath,this.tree.refreshOrFilterTree())}).catch(e=>{this.tree.errorNotification(e,!0)})}};__decorate([o.property({type:String})],y.prototype,"mountPointPath",void 0),__decorate([o.query(".svg-tree-wrapper")],y.prototype,"tree",void 0),__decorate([o.query("typo3-backend-navigation-component-pagetree-toolbar")],y.prototype,"toolbar",void 0),y=__decorate([o.customElement(t.navigationComponentName)],y),t.PageTreeNavigationComponent=y;let b=class extends g.Toolbar{constructor(){super(...arguments),this.tree=null}initializeDragDrop(e){var t,i,o;(null===(o=null===(i=null===(t=this.tree)||void 0===t?void 0:t.settings)||void 0===i?void 0:i.doktypes)||void 0===o?void 0:o.length)&&this.tree.settings.doktypes.forEach(t=>{if(t.icon){const i=this.querySelector('[data-tree-icon="'+t.icon+'"]');p.select(i).call(this.dragToolbar(t,e))}else console.warn("Missing icon definition for doktype: "+t.nodeType)})}updated(e){e.forEach((e,t)=>{"tree"===t&&null!==this.tree&&this.initializeDragDrop(this.tree.dragDrop)})}render(){var e,t,o;return i.html` <div class="tree-toolbar"> <div class="svg-toolbar__menu"> <div class="svg-toolbar__search"> @@ -54,4 +54,4 @@ var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,i,o) `):""} </div> </div> - `}dragToolbar(e,t){return t.connectDragHandler(new P(e,this.tree,t))}};__decorate([o.property({type:f})],y.prototype,"tree",void 0),y=__decorate([o.customElement("typo3-backend-navigation-component-pagetree-toolbar")],y);class b extends g.DragDrop{changeNodePosition(e,t=""){const i=this.tree.nodes,o=this.tree.settings.nodeDrag.identifier;let n=this.tree.settings.nodeDragPosition,s=e||this.tree.settings.nodeDrag;if(o===s.identifier&&"delete"!==t)return null;if(n===g.DraggablePositionEnum.BEFORE){const t=i.indexOf(e),o=this.setNodePositionAndTarget(t);if(null===o)return null;n=o.position,s=o.target}return{node:this.tree.settings.nodeDrag,uid:o,target:s,position:n,command:t}}setNodePositionAndTarget(e){const t=this.tree.nodes,i=t[e].depth;e>0&&e--;const o=t[e].depth,n=this.tree.nodes[e];if(o===i)return{position:g.DraggablePositionEnum.AFTER,target:n};if(o<i)return{position:g.DraggablePositionEnum.INSIDE,target:n};for(let o=e;o>=0;o--){if(t[o].depth===i)return{position:g.DraggablePositionEnum.AFTER,target:this.tree.nodes[o]};if(t[o].depth<i)return{position:g.DraggablePositionEnum.AFTER,target:t[o]}}return null}}class P{constructor(e,t,i){this.startDrag=!1,this.startPageX=0,this.startPageY=0,this.id="",this.name="",this.tooltip="",this.icon="",this.isDragged=!1,this.id=e.nodeType,this.name=e.title,this.tooltip=e.tooltip,this.icon=e.icon,this.tree=t,this.dragDrop=i}dragStart(e){return this.isDragged=!1,this.startDrag=!1,this.startPageX=e.sourceEvent.pageX,this.startPageY=e.sourceEvent.pageY,!0}dragDragged(e){return!!this.dragDrop.isDragNodeDistanceMore(e,this)&&(this.startDrag=!0,!1===this.isDragged&&(this.isDragged=!0,this.dragDrop.createDraggable("#icon-"+this.icon,this.name)),this.dragDrop.openNodeTimeout(),this.dragDrop.updateDraggablePosition(e),this.dragDrop.changeNodeClasses(e),!0)}dragEnd(e){return!!this.startDrag&&(this.isDragged=!1,this.dragDrop.removeNodeDdClass(),!(!0!==this.tree.settings.allowDragMove||!this.tree.hoveredNode||!this.tree.isOverSvg)&&(this.tree.settings.canNodeDrag&&this.addNewNode({type:this.id,name:this.name,tooltip:this.tooltip,icon:this.icon,position:this.tree.settings.nodeDragPosition,target:this.tree.hoveredNode}),!0))}addNewNode(e){const t=e.target;let i=this.tree.nodes.indexOf(t);const o={command:"new"};if(o.type=e.type,o.identifier="-1",o.target=t,o.parents=t.parents,o.parentsStateIdentifier=t.parentsStateIdentifier,o.depth=t.depth,o.position=e.position,o.name=void 0!==e.title?e.title:TYPO3.lang["tree.defaultPageTitle"],o.y=o.y||o.target.y,o.x=o.x||o.target.x,this.tree.nodeIsEdit=!0,e.position===g.DraggablePositionEnum.INSIDE&&(o.depth++,o.parents.unshift(i),o.parentsStateIdentifier.unshift(this.tree.nodes[i].stateIdentifier),this.tree.nodes[i].hasChildren=!0,this.tree.showChildren(this.tree.nodes[i])),e.position!==g.DraggablePositionEnum.INSIDE&&e.position!==g.DraggablePositionEnum.AFTER||i++,e.icon&&(o.icon=e.icon),o.position===g.DraggablePositionEnum.BEFORE){const e=this.dragDrop.setNodePositionAndTarget(i);null!==e&&(o.position=e.position,o.target=e.target)}this.tree.nodes.splice(i,0,o),this.tree.setParametersNode(),this.tree.prepareDataForVisibleNodes(),this.tree.updateVisibleNodes(),this.tree.removeEditedText(),h.select(this.tree.svg.node().parentNode).append("input").attr("class","node-edit").style("top",o.y+this.tree.settings.marginTop+"px").style("left",o.x+this.tree.textPosition+5+"px").style("width",this.tree.settings.width-(o.x+this.tree.textPosition+20)+"px").style("height",this.tree.settings.nodeHeight+"px").attr("text","text").attr("value",o.name).on("keydown",e=>{const t=e.target,i=e.keyCode;if(13===i||9===i){this.tree.nodeIsEdit=!1;const e=t.value.trim();e.length?(o.name=e,this.tree.removeEditedText(),this.tree.sendChangeCommand(o)):this.removeNode(o)}else 27===i&&(this.tree.nodeIsEdit=!1,this.removeNode(o))}).on("blur",e=>{if(this.tree.nodeIsEdit&&this.tree.nodes.indexOf(o)>-1){const t=e.target.value.trim();t.length?(o.name=t,this.tree.removeEditedText(),this.tree.sendChangeCommand(o)):this.removeNode(o)}}).node().select()}removeNode(e){let t=this.tree.nodes.indexOf(e);this.tree.nodes[t-1].depth==e.depth||this.tree.nodes[t+1]&&this.tree.nodes[t+1].depth==e.depth||(this.tree.nodes[t-1].hasChildren=!1),this.tree.nodes.splice(t,1),this.tree.setParametersNode(),this.tree.prepareDataForVisibleNodes(),this.tree.updateVisibleNodes(),this.tree.removeEditedText()}}class N{constructor(e,t){this.startDrag=!1,this.startPageX=0,this.startPageY=0,this.isDragged=!1,this.nodeIsOverDelete=!1,this.tree=e,this.dragDrop=t}dragStart(e){const t=e.subject;return!0===this.tree.settings.allowDragMove&&0!==t.depth&&(this.dropZoneDelete=null,t.allowDelete&&(this.dropZoneDelete=this.tree.nodesContainer.select('.node[data-state-id="'+t.stateIdentifier+'"]').append("g").attr("class","nodes-drop-zone").attr("height",this.tree.settings.nodeHeight),this.nodeIsOverDelete=!1,this.dropZoneDelete.append("rect").attr("height",this.tree.settings.nodeHeight).attr("width","50px").attr("x",0).attr("y",0).on("mouseover",()=>{this.nodeIsOverDelete=!0}).on("mouseout",()=>{this.nodeIsOverDelete=!1}),this.dropZoneDelete.append("text").text(TYPO3.lang.deleteItem).attr("dx",5).attr("dy",15),this.dropZoneDelete.node().dataset.open="false",this.dropZoneDelete.node().style.transform=this.getDropZoneCloseTransform(t)),this.startPageX=e.sourceEvent.pageX,this.startPageY=e.sourceEvent.pageY,this.startDrag=!1,!0)}dragDragged(e){const t=e.subject;if(!this.dragDrop.isDragNodeDistanceMore(e,this))return!1;if(this.startDrag=!0,!0!==this.tree.settings.allowDragMove||0===t.depth)return!1;this.tree.settings.nodeDrag=t;const i=this.tree.svg.node().querySelector('.node-bg[data-state-id="'+t.stateIdentifier+'"]'),o=this.tree.svg.node().parentNode.querySelector(".node-dd");return this.isDragged||(this.isDragged=!0,this.dragDrop.createDraggable(this.tree.getIconId(t),t.name),i.classList.add("node-bg--dragging")),this.tree.settings.nodeDragPosition=!1,this.dragDrop.openNodeTimeout(),this.dragDrop.updateDraggablePosition(e),t.isOver||this.tree.hoveredNode&&-1!==this.tree.hoveredNode.parentsStateIdentifier.indexOf(t.stateIdentifier)||!this.tree.isOverSvg?(this.dragDrop.addNodeDdClass(o,"nodrop"),this.tree.isOverSvg||this.tree.nodesBgContainer.selectAll(".node-bg__border").style("display","none"),this.dropZoneDelete&&"true"!==this.dropZoneDelete.node().dataset.open&&this.tree.isOverSvg&&this.animateDropZone("show",this.dropZoneDelete.node(),t)):this.tree.hoveredNode?this.dropZoneDelete&&"false"!==this.dropZoneDelete.node().dataset.open&&this.animateDropZone("hide",this.dropZoneDelete.node(),t):(this.dragDrop.addNodeDdClass(o,"nodrop"),this.tree.nodesBgContainer.selectAll(".node-bg__border").style("display","none")),this.dragDrop.changeNodeClasses(e),!0}dragEnd(e){const t=e.subject;if(this.dropZoneDelete&&"true"===this.dropZoneDelete.node().dataset.open){const e=this.dropZoneDelete;this.animateDropZone("hide",this.dropZoneDelete.node(),t,()=>{e.remove(),this.dropZoneDelete=null})}else this.dropZoneDelete&&"false"===this.dropZoneDelete.node().dataset.open?(this.dropZoneDelete.remove(),this.dropZoneDelete=null):this.dropZoneDelete=null;if(!this.startDrag||!0!==this.tree.settings.allowDragMove||0===t.depth)return!1;const i=this.tree.hoveredNode;if(this.isDragged=!1,this.dragDrop.removeNodeDdClass(),t.isOver||i&&-1!==i.parentsStateIdentifier.indexOf(t.stateIdentifier)||!this.tree.settings.canNodeDrag||!this.tree.isOverSvg){if(this.nodeIsOverDelete){const e=this.dragDrop.changeNodePosition(i,"delete");if(null===e)return!1;if(this.tree.settings.displayDeleteConfirmation){u.confirm(TYPO3.lang.deleteItem,TYPO3.lang["mess.delete"].replace("%s",e.node.name),m.warning,[{text:TYPO3.lang["labels.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:TYPO3.lang["cm.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",t=>{"delete"===t.target.name&&this.tree.sendChangeCommand(e),u.dismiss()})}else this.tree.sendChangeCommand(e)}}else{const e=this.dragDrop.changeNodePosition(i,"");if(null===e)return!1;let t=e.position===g.DraggablePositionEnum.INSIDE?TYPO3.lang["mess.move_into"]:TYPO3.lang["mess.move_after"];t=t.replace("%s",e.node.name).replace("%s",e.target.name),u.confirm(TYPO3.lang.move_page,t,m.warning,[{text:TYPO3.lang["labels.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:TYPO3.lang["cm.copy"]||"Copy",btnClass:"btn-warning",name:"copy"},{text:TYPO3.lang["labels.move"]||"Move",btnClass:"btn-warning",name:"move"}]).on("button.clicked",t=>{const i=t.target;"move"===i.name?(e.command="move",this.tree.sendChangeCommand(e)):"copy"===i.name&&(e.command="copy",this.tree.sendChangeCommand(e)),u.dismiss()})}return!0}getDropZoneOpenTransform(e){return"translate("+((parseFloat(this.tree.svg.style("width"))||300)-58-e.x)+"px, -10px)"}getDropZoneCloseTransform(e){return"translate("+((parseFloat(this.tree.svg.style("width"))||300)-e.x)+"px, -10px)"}animateDropZone(e,t,i,o=null){t.classList.add("animating"),t.dataset.open="show"===e?"true":"false";let n=[{transform:this.getDropZoneCloseTransform(i)},{transform:this.getDropZoneOpenTransform(i)}];"show"!==e&&(n=n.reverse());const s=function(){t.style.transform=n[1].transform,t.classList.remove("animating"),o&&o()};"animate"in t?t.animate(n,{duration:300,easing:"cubic-bezier(.02, .01, .47, 1)"}).onfinish=s:s()}}})); \ No newline at end of file + `}dragToolbar(e,t){return t.connectDragHandler(new N(e,this.tree,t))}};__decorate([o.property({type:D})],b.prototype,"tree",void 0),b=__decorate([o.customElement("typo3-backend-navigation-component-pagetree-toolbar")],b);class P extends u.DragDrop{changeNodePosition(e,t=""){const i=this.tree.nodes,o=this.tree.settings.nodeDrag.identifier;let n=this.tree.settings.nodeDragPosition,s=e||this.tree.settings.nodeDrag;if(o===s.identifier&&"delete"!==t)return null;if(n===u.DraggablePositionEnum.BEFORE){const t=i.indexOf(e),o=this.setNodePositionAndTarget(t);if(null===o)return null;n=o.position,s=o.target}return{node:this.tree.settings.nodeDrag,uid:o,target:s,position:n,command:t}}setNodePositionAndTarget(e){const t=this.tree.nodes,i=t[e].depth;e>0&&e--;const o=t[e].depth,n=this.tree.nodes[e];if(o===i)return{position:u.DraggablePositionEnum.AFTER,target:n};if(o<i)return{position:u.DraggablePositionEnum.INSIDE,target:n};for(let o=e;o>=0;o--){if(t[o].depth===i)return{position:u.DraggablePositionEnum.AFTER,target:this.tree.nodes[o]};if(t[o].depth<i)return{position:u.DraggablePositionEnum.AFTER,target:t[o]}}return null}}class N{constructor(e,t,i){this.startDrag=!1,this.startPageX=0,this.startPageY=0,this.id="",this.name="",this.tooltip="",this.icon="",this.isDragged=!1,this.id=e.nodeType,this.name=e.title,this.tooltip=e.tooltip,this.icon=e.icon,this.tree=t,this.dragDrop=i}dragStart(e){return this.isDragged=!1,this.startDrag=!1,this.startPageX=e.sourceEvent.pageX,this.startPageY=e.sourceEvent.pageY,!0}dragDragged(e){return!!this.dragDrop.isDragNodeDistanceMore(e,this)&&(this.startDrag=!0,!1===this.isDragged&&(this.isDragged=!0,this.dragDrop.createDraggable("#icon-"+this.icon,this.name)),this.dragDrop.openNodeTimeout(),this.dragDrop.updateDraggablePosition(e),this.dragDrop.changeNodeClasses(e),!0)}dragEnd(e){return!!this.startDrag&&(this.isDragged=!1,this.dragDrop.removeNodeDdClass(),!(!0!==this.tree.settings.allowDragMove||!this.tree.hoveredNode||!this.tree.isOverSvg)&&(this.tree.settings.canNodeDrag&&this.addNewNode({type:this.id,name:this.name,tooltip:this.tooltip,icon:this.icon,position:this.tree.settings.nodeDragPosition,target:this.tree.hoveredNode}),!0))}addNewNode(e){const t=e.target;let i=this.tree.nodes.indexOf(t);const o={command:"new"};if(o.type=e.type,o.identifier="-1",o.target=t,o.parents=t.parents,o.parentsStateIdentifier=t.parentsStateIdentifier,o.depth=t.depth,o.position=e.position,o.name=void 0!==e.title?e.title:TYPO3.lang["tree.defaultPageTitle"],o.y=o.y||o.target.y,o.x=o.x||o.target.x,this.tree.nodeIsEdit=!0,e.position===u.DraggablePositionEnum.INSIDE&&(o.depth++,o.parents.unshift(i),o.parentsStateIdentifier.unshift(this.tree.nodes[i].stateIdentifier),this.tree.nodes[i].hasChildren=!0,this.tree.showChildren(this.tree.nodes[i])),e.position!==u.DraggablePositionEnum.INSIDE&&e.position!==u.DraggablePositionEnum.AFTER||i++,e.icon&&(o.icon=e.icon),o.position===u.DraggablePositionEnum.BEFORE){const e=this.dragDrop.setNodePositionAndTarget(i);null!==e&&(o.position=e.position,o.target=e.target)}this.tree.nodes.splice(i,0,o),this.tree.setParametersNode(),this.tree.prepareDataForVisibleNodes(),this.tree.updateVisibleNodes(),this.tree.removeEditedText(),p.select(this.tree.svg.node().parentNode).append("input").attr("class","node-edit").style("top",o.y+this.tree.settings.marginTop+"px").style("left",o.x+this.tree.textPosition+5+"px").style("width",this.tree.settings.width-(o.x+this.tree.textPosition+20)+"px").style("height",this.tree.settings.nodeHeight+"px").attr("text","text").attr("value",o.name).on("keydown",e=>{const t=e.target,i=e.keyCode;if(13===i||9===i){this.tree.nodeIsEdit=!1;const e=t.value.trim();e.length?(o.name=e,this.tree.removeEditedText(),this.tree.sendChangeCommand(o)):this.removeNode(o)}else 27===i&&(this.tree.nodeIsEdit=!1,this.removeNode(o))}).on("blur",e=>{if(this.tree.nodeIsEdit&&this.tree.nodes.indexOf(o)>-1){const t=e.target.value.trim();t.length?(o.name=t,this.tree.removeEditedText(),this.tree.sendChangeCommand(o)):this.removeNode(o)}}).node().select()}removeNode(e){let t=this.tree.nodes.indexOf(e);this.tree.nodes[t-1].depth==e.depth||this.tree.nodes[t+1]&&this.tree.nodes[t+1].depth==e.depth||(this.tree.nodes[t-1].hasChildren=!1),this.tree.nodes.splice(t,1),this.tree.setParametersNode(),this.tree.prepareDataForVisibleNodes(),this.tree.updateVisibleNodes(),this.tree.removeEditedText()}}class T{constructor(e,t){this.startDrag=!1,this.startPageX=0,this.startPageY=0,this.isDragged=!1,this.nodeIsOverDelete=!1,this.tree=e,this.dragDrop=t}dragStart(e){const t=e.subject;return!0===this.tree.settings.allowDragMove&&0!==t.depth&&(this.dropZoneDelete=null,t.allowDelete&&(this.dropZoneDelete=this.tree.nodesContainer.select('.node[data-state-id="'+t.stateIdentifier+'"]').append("g").attr("class","nodes-drop-zone").attr("height",this.tree.settings.nodeHeight),this.nodeIsOverDelete=!1,this.dropZoneDelete.append("rect").attr("height",this.tree.settings.nodeHeight).attr("width","50px").attr("x",0).attr("y",0).on("mouseover",()=>{this.nodeIsOverDelete=!0}).on("mouseout",()=>{this.nodeIsOverDelete=!1}),this.dropZoneDelete.append("text").text(TYPO3.lang.deleteItem).attr("dx",5).attr("dy",15),this.dropZoneDelete.node().dataset.open="false",this.dropZoneDelete.node().style.transform=this.getDropZoneCloseTransform(t)),this.startPageX=e.sourceEvent.pageX,this.startPageY=e.sourceEvent.pageY,this.startDrag=!1,!0)}dragDragged(e){const t=e.subject;if(!this.dragDrop.isDragNodeDistanceMore(e,this))return!1;if(this.startDrag=!0,!0!==this.tree.settings.allowDragMove||0===t.depth)return!1;this.tree.settings.nodeDrag=t;const i=this.tree.svg.node().querySelector('.node-bg[data-state-id="'+t.stateIdentifier+'"]'),o=this.tree.svg.node().parentNode.querySelector(".node-dd");return this.isDragged||(this.isDragged=!0,this.dragDrop.createDraggable(this.tree.getIconId(t),t.name),i.classList.add("node-bg--dragging")),this.tree.settings.nodeDragPosition=!1,this.dragDrop.openNodeTimeout(),this.dragDrop.updateDraggablePosition(e),t.isOver||this.tree.hoveredNode&&-1!==this.tree.hoveredNode.parentsStateIdentifier.indexOf(t.stateIdentifier)||!this.tree.isOverSvg?(this.dragDrop.addNodeDdClass(o,"nodrop"),this.tree.isOverSvg||this.tree.nodesBgContainer.selectAll(".node-bg__border").style("display","none"),this.dropZoneDelete&&"true"!==this.dropZoneDelete.node().dataset.open&&this.tree.isOverSvg&&this.animateDropZone("show",this.dropZoneDelete.node(),t)):this.tree.hoveredNode?this.dropZoneDelete&&"false"!==this.dropZoneDelete.node().dataset.open&&this.animateDropZone("hide",this.dropZoneDelete.node(),t):(this.dragDrop.addNodeDdClass(o,"nodrop"),this.tree.nodesBgContainer.selectAll(".node-bg__border").style("display","none")),this.dragDrop.changeNodeClasses(e),!0}dragEnd(e){const t=e.subject;if(this.dropZoneDelete&&"true"===this.dropZoneDelete.node().dataset.open){const e=this.dropZoneDelete;this.animateDropZone("hide",this.dropZoneDelete.node(),t,()=>{e.remove(),this.dropZoneDelete=null})}else this.dropZoneDelete&&"false"===this.dropZoneDelete.node().dataset.open?(this.dropZoneDelete.remove(),this.dropZoneDelete=null):this.dropZoneDelete=null;if(!this.startDrag||!0!==this.tree.settings.allowDragMove||0===t.depth)return!1;const i=this.tree.hoveredNode;if(this.isDragged=!1,this.dragDrop.removeNodeDdClass(),t.isOver||i&&-1!==i.parentsStateIdentifier.indexOf(t.stateIdentifier)||!this.tree.settings.canNodeDrag||!this.tree.isOverSvg){if(this.nodeIsOverDelete){const e=this.dragDrop.changeNodePosition(i,"delete");if(null===e)return!1;if(this.tree.settings.displayDeleteConfirmation){m.confirm(TYPO3.lang.deleteItem,TYPO3.lang["mess.delete"].replace("%s",e.node.name),v.warning,[{text:TYPO3.lang["labels.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:TYPO3.lang["cm.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",t=>{"delete"===t.target.name&&this.tree.sendChangeCommand(e),m.dismiss()})}else this.tree.sendChangeCommand(e)}}else{const e=this.dragDrop.changeNodePosition(i,"");if(null===e)return!1;let t=e.position===u.DraggablePositionEnum.INSIDE?TYPO3.lang["mess.move_into"]:TYPO3.lang["mess.move_after"];t=t.replace("%s",e.node.name).replace("%s",e.target.name),m.confirm(TYPO3.lang.move_page,t,v.warning,[{text:TYPO3.lang["labels.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:TYPO3.lang["cm.copy"]||"Copy",btnClass:"btn-warning",name:"copy"},{text:TYPO3.lang["labels.move"]||"Move",btnClass:"btn-warning",name:"move"}]).on("button.clicked",t=>{const i=t.target;"move"===i.name?(e.command="move",this.tree.sendChangeCommand(e)):"copy"===i.name&&(e.command="copy",this.tree.sendChangeCommand(e)),m.dismiss()})}return!0}getDropZoneOpenTransform(e){return"translate("+((parseFloat(this.tree.svg.style("width"))||300)-58-e.x)+"px, -10px)"}getDropZoneCloseTransform(e){return"translate("+((parseFloat(this.tree.svg.style("width"))||300)-e.x)+"px, -10px)"}animateDropZone(e,t,i,o=null){t.classList.add("animating"),t.dataset.open="show"===e?"true":"false";let n=[{transform:this.getDropZoneCloseTransform(i)},{transform:this.getDropZoneOpenTransform(i)}];"show"!==e&&(n=n.reverse());const s=function(){t.style.transform=n[1].transform,t.classList.remove("animating"),o&&o()};"animate"in t?t.animate(n,{duration:300,easing:"cubic-bezier(.02, .01, .47, 1)"}).onfinish=s:s()}}})); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/ShortcutMenu.js b/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/ShortcutMenu.js index 404bd945103029bab15d3aacd57c38afafc2001b..7ee29965f417c2dfd5641376bc4702145d8b70ae 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/ShortcutMenu.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/ShortcutMenu.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};define(["require","exports","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","../Icons","../Modal","../Notification","../Viewport","TYPO3/CMS/Core/SecurityUtility"],(function(t,e,o,r,c,a,s,l,n){"use strict";var u;o=__importDefault(o),n=__importDefault(n),function(t){t.containerSelector="#typo3-cms-backend-backend-toolbaritems-shortcuttoolbaritem",t.toolbarIconSelector=".dropdown-toggle span.icon",t.toolbarMenuSelector=".dropdown-menu",t.shortcutItemSelector=".t3js-topbar-shortcut",t.shortcutDeleteSelector=".t3js-shortcut-delete",t.shortcutEditSelector=".t3js-shortcut-edit",t.shortcutFormTitleSelector='input[name="shortcut-title"]',t.shortcutFormGroupSelector='select[name="shortcut-group"]',t.shortcutFormSaveSelector=".shortcut-form-save",t.shortcutFormCancelSelector=".shortcut-form-cancel",t.shortcutFormSelector=".shortcut-form"}(u||(u={}));let i=new class{constructor(){this.initializeEvents=()=>{o.default(u.containerSelector).on("click",u.shortcutDeleteSelector,t=>{t.preventDefault(),t.stopImmediatePropagation(),this.deleteShortcut(o.default(t.currentTarget).closest(u.shortcutItemSelector))}).on("click",u.shortcutFormGroupSelector,t=>{t.preventDefault(),t.stopImmediatePropagation()}).on("click",u.shortcutEditSelector,t=>{t.preventDefault(),t.stopImmediatePropagation(),this.editShortcut(o.default(t.currentTarget).closest(u.shortcutItemSelector))}).on("click",u.shortcutFormSaveSelector,t=>{t.preventDefault(),t.stopImmediatePropagation(),this.saveShortcutForm(o.default(t.currentTarget).closest(u.shortcutFormSelector))}).on("submit",u.shortcutFormSelector,t=>{t.preventDefault(),t.stopImmediatePropagation(),this.saveShortcutForm(o.default(t.currentTarget).closest(u.shortcutFormSelector))}).on("click",u.shortcutFormCancelSelector,t=>{t.preventDefault(),t.stopImmediatePropagation(),this.refreshMenu()})},l.Topbar.Toolbar.registerEvent(this.initializeEvents)}createShortcut(t,e,s,l,i){void 0!==l&&a.confirm(TYPO3.lang["bookmark.create"],l).on("confirm.button.ok",a=>{const l=o.default(u.toolbarIconSelector,u.containerSelector),h=l.clone();c.getIcon("spinner-circle-light",c.sizes.small).then(t=>{l.replaceWith(t)}),new r(TYPO3.settings.ajaxUrls.shortcut_create).post({routeIdentifier:t,arguments:e,displayName:s}).then(()=>{if(this.refreshMenu(),o.default(u.toolbarIconSelector,u.containerSelector).replaceWith(h),"object"==typeof i){const t=o.default(i).hasClass("dropdown-item"),e=new n.default;c.getIcon("actions-system-shortcut-active",c.sizes.small).then(r=>{o.default(i).html(r+(t?" "+e.encodeHtml(TYPO3.lang["labels.alreadyBookmarked"]):""))}),o.default(i).addClass(t?"disabled":"active"),o.default(i).attr("onclick",null),o.default(i).attr("title",TYPO3.lang["labels.alreadyBookmarked"])}}),o.default(a.currentTarget).trigger("modal-dismiss")}).on("confirm.button.cancel",t=>{o.default(t.currentTarget).trigger("modal-dismiss")})}deleteShortcut(t){a.confirm(TYPO3.lang["bookmark.delete"],TYPO3.lang["bookmark.confirmDelete"]).on("confirm.button.ok",e=>{new r(TYPO3.settings.ajaxUrls.shortcut_remove).post({shortcutId:t.data("shortcutid")}).then(()=>{this.refreshMenu()}),o.default(e.currentTarget).trigger("modal-dismiss")}).on("confirm.button.cancel",t=>{o.default(t.currentTarget).trigger("modal-dismiss")})}editShortcut(t){new r(TYPO3.settings.ajaxUrls.shortcut_editform).withQueryArguments({shortcutId:t.data("shortcutid"),shortcutGroup:t.data("shortcutgroup")}).get({cache:"no-cache"}).then(async t=>{o.default(u.containerSelector).find(u.toolbarMenuSelector).html(await t.resolve())})}saveShortcutForm(t){new r(TYPO3.settings.ajaxUrls.shortcut_saveform).post({shortcutId:t.data("shortcutid"),shortcutTitle:t.find(u.shortcutFormTitleSelector).val(),shortcutGroup:t.find(u.shortcutFormGroupSelector).val()}).then(()=>{s.success(TYPO3.lang["bookmark.savedTitle"],TYPO3.lang["bookmark.savedMessage"]),this.refreshMenu()})}refreshMenu(){new r(TYPO3.settings.ajaxUrls.shortcut_list).get({cache:"no-cache"}).then(async t=>{o.default(u.toolbarMenuSelector,u.containerSelector).html(await t.resolve())})}};return TYPO3.ShortcutMenu=i,i})); \ No newline at end of file +var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};define(["require","exports","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","../Icons","../Modal","../Notification","../Viewport","TYPO3/CMS/Core/SecurityUtility","TYPO3/CMS/Backend/Storage/ModuleStateStorage"],(function(t,e,o,r,a,c,s,l,n,u){"use strict";var i;o=__importDefault(o),n=__importDefault(n),function(t){t.containerSelector="#typo3-cms-backend-backend-toolbaritems-shortcuttoolbaritem",t.toolbarIconSelector=".dropdown-toggle span.icon",t.toolbarMenuSelector=".dropdown-menu",t.shortcutItemSelector=".t3js-topbar-shortcut",t.shortcutJumpSelector=".t3js-shortcut-jump",t.shortcutDeleteSelector=".t3js-shortcut-delete",t.shortcutEditSelector=".t3js-shortcut-edit",t.shortcutFormTitleSelector='input[name="shortcut-title"]',t.shortcutFormGroupSelector='select[name="shortcut-group"]',t.shortcutFormSaveSelector=".shortcut-form-save",t.shortcutFormCancelSelector=".shortcut-form-cancel",t.shortcutFormSelector=".shortcut-form"}(i||(i={}));let d=new class{constructor(){this.initializeEvents=()=>{o.default(i.containerSelector).on("click",i.shortcutDeleteSelector,t=>{t.preventDefault(),t.stopImmediatePropagation(),this.deleteShortcut(o.default(t.currentTarget).closest(i.shortcutItemSelector))}).on("click",i.shortcutFormGroupSelector,t=>{t.preventDefault(),t.stopImmediatePropagation()}).on("click",i.shortcutEditSelector,t=>{t.preventDefault(),t.stopImmediatePropagation(),this.editShortcut(o.default(t.currentTarget).closest(i.shortcutItemSelector))}).on("click",i.shortcutFormSaveSelector,t=>{t.preventDefault(),t.stopImmediatePropagation(),this.saveShortcutForm(o.default(t.currentTarget).closest(i.shortcutFormSelector))}).on("submit",i.shortcutFormSelector,t=>{t.preventDefault(),t.stopImmediatePropagation(),this.saveShortcutForm(o.default(t.currentTarget).closest(i.shortcutFormSelector))}).on("click",i.shortcutFormCancelSelector,t=>{t.preventDefault(),t.stopImmediatePropagation(),this.refreshMenu()}).on("click",i.shortcutJumpSelector,t=>{t.preventDefault(),t.stopImmediatePropagation();const e=o.default(t.currentTarget).data("pageid");e&&u.ModuleStateStorage.updateWithCurrentMount("web",e,!0);const r=document.querySelector("typo3-backend-module-router");r.setAttribute("endpoint",o.default(t.currentTarget).attr("href")),r.setAttribute("module",o.default(t.currentTarget).data("module"))})},l.Topbar.Toolbar.registerEvent(this.initializeEvents)}createShortcut(t,e,s,l,u){void 0!==l&&c.confirm(TYPO3.lang["bookmark.create"],l).on("confirm.button.ok",c=>{const l=o.default(i.toolbarIconSelector,i.containerSelector),d=l.clone();a.getIcon("spinner-circle-light",a.sizes.small).then(t=>{l.replaceWith(t)}),new r(TYPO3.settings.ajaxUrls.shortcut_create).post({routeIdentifier:t,arguments:e,displayName:s}).then(()=>{if(this.refreshMenu(),o.default(i.toolbarIconSelector,i.containerSelector).replaceWith(d),"object"==typeof u){const t=o.default(u).hasClass("dropdown-item"),e=new n.default;a.getIcon("actions-system-shortcut-active",a.sizes.small).then(r=>{o.default(u).html(r+(t?" "+e.encodeHtml(TYPO3.lang["labels.alreadyBookmarked"]):""))}),o.default(u).addClass(t?"disabled":"active"),o.default(u).attr("onclick",null),o.default(u).attr("title",TYPO3.lang["labels.alreadyBookmarked"])}}),o.default(c.currentTarget).trigger("modal-dismiss")}).on("confirm.button.cancel",t=>{o.default(t.currentTarget).trigger("modal-dismiss")})}deleteShortcut(t){c.confirm(TYPO3.lang["bookmark.delete"],TYPO3.lang["bookmark.confirmDelete"]).on("confirm.button.ok",e=>{new r(TYPO3.settings.ajaxUrls.shortcut_remove).post({shortcutId:t.data("shortcutid")}).then(()=>{this.refreshMenu()}),o.default(e.currentTarget).trigger("modal-dismiss")}).on("confirm.button.cancel",t=>{o.default(t.currentTarget).trigger("modal-dismiss")})}editShortcut(t){new r(TYPO3.settings.ajaxUrls.shortcut_editform).withQueryArguments({shortcutId:t.data("shortcutid"),shortcutGroup:t.data("shortcutgroup")}).get({cache:"no-cache"}).then(async t=>{o.default(i.containerSelector).find(i.toolbarMenuSelector).html(await t.resolve())})}saveShortcutForm(t){new r(TYPO3.settings.ajaxUrls.shortcut_saveform).post({shortcutId:t.data("shortcutid"),shortcutTitle:t.find(i.shortcutFormTitleSelector).val(),shortcutGroup:t.find(i.shortcutFormGroupSelector).val()}).then(()=>{s.success(TYPO3.lang["bookmark.savedTitle"],TYPO3.lang["bookmark.savedMessage"]),this.refreshMenu()})}refreshMenu(){new r(TYPO3.settings.ajaxUrls.shortcut_list).get({cache:"no-cache"}).then(async t=>{o.default(i.toolbarMenuSelector,i.containerSelector).html(await t.resolve())})}};return TYPO3.ShortcutMenu=d,d})); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Tree/FileStorageTreeContainer.js b/typo3/sysext/backend/Resources/Public/JavaScript/Tree/FileStorageTreeContainer.js index c809d89504ef2cb1c15feb553665af98812c8654..62e9c975ee49f6cf141559f0ec4feb2a405286e2 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/Tree/FileStorageTreeContainer.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Tree/FileStorageTreeContainer.js @@ -10,7 +10,7 @@ * * The TYPO3 project - inspiring people to share! */ -var __decorate=this&&this.__decorate||function(e,t,r,i){var n,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(s<3?n(o):s>3?n(t,r,o):n(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","lit","lit/decorators","./FileStorageTree","TYPO3/CMS/Backend/Storage/Persistent","../ContextMenu","./DragDrop","../Modal","../Severity","../Notification","TYPO3/CMS/Core/Ajax/AjaxRequest","../Storage/ModuleStateStorage","TYPO3/CMS/Backend/Element/IconElement"],(function(e,t,r,i,n,s,o,a,d,l,c,g,h){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileStorageTreeNavigationComponent=t.navigationComponentName=void 0,s=__importDefault(s),g=__importDefault(g),t.navigationComponentName="typo3-backend-navigation-component-filestoragetree";let p=class extends n.FileStorageTree{constructor(){super(),this.actionHandler=new f(this)}updateNodeBgClass(e){return super.updateNodeBgClass.call(this,e).call(this.initializeDragForNode())}nodesUpdate(e){return super.nodesUpdate.call(this,e).call(this.initializeDragForNode())}initializeDragForNode(){return this.actionHandler.connectDragHandler(new v(this,this.actionHandler))}};p=__decorate([i.customElement("typo3-backend-navigation-component-filestorage-tree")],p);let u=class extends r.LitElement{constructor(){super(...arguments),this.refresh=()=>{this.tree.refreshOrFilterTree()},this.selectFirstNode=()=>{const e=this.tree.nodes[0];e&&this.tree.selectNode(e,!0)},this.treeUpdateRequested=e=>{const t=encodeURIComponent(e.detail.payload.identifier);let r=this.tree.nodes.filter(e=>e.identifier===t)[0];r&&0===this.tree.getSelectedNodes().filter(e=>e.identifier===r.identifier).length&&this.tree.selectNode(r,!1)},this.toggleExpandState=e=>{const t=e.detail.node;t&&s.default.set("BackendComponents.States.FileStorageTree.stateHash."+t.stateIdentifier,t.expanded?"1":"0")},this.loadContent=e=>{const t=e.detail.node;if(!(null==t?void 0:t.checked))return;if(h.ModuleStateStorage.update("file",t.identifier,!0),!1===e.detail.propagate)return;const r=-1!==window.currentSubScript.indexOf("?")?"&":"?";TYPO3.Backend.ContentContainer.setUrl(window.currentSubScript+r+"id="+t.identifier)},this.showContextMenu=e=>{const t=e.detail.node;t&&o.show(t.itemType,decodeURIComponent(t.identifier),"tree","","",this.tree.getNodeElement(t))},this.selectActiveNode=e=>{const t=h.ModuleStateStorage.current("file").selection;let r=e.detail.nodes;e.detail.nodes=r.map(e=>(e.identifier===t&&(e.checked=!0),e))}}connectedCallback(){super.connectedCallback(),document.addEventListener("typo3:filestoragetree:refresh",this.refresh),document.addEventListener("typo3:filestoragetree:selectFirstNode",this.selectFirstNode),document.addEventListener("typo3:filelist:treeUpdateRequested",this.treeUpdateRequested)}disconnectedCallback(){document.removeEventListener("typo3:filestoragetree:refresh",this.refresh),document.removeEventListener("typo3:filestoragetree:selectFirstNode",this.selectFirstNode),document.removeEventListener("typo3:filelist:treeUpdateRequested",this.treeUpdateRequested),super.disconnectedCallback()}createRenderRoot(){return this}render(){const e={dataUrl:top.TYPO3.settings.ajaxUrls.filestorage_tree_data,filterUrl:top.TYPO3.settings.ajaxUrls.filestorage_tree_filter,showIcons:!0};return r.html` +var __decorate=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","lit","lit/decorators","./FileStorageTree","TYPO3/CMS/Backend/Storage/Persistent","../ContextMenu","./DragDrop","../Modal","../Severity","../Notification","TYPO3/CMS/Core/Ajax/AjaxRequest","../Storage/ModuleStateStorage","../Module","TYPO3/CMS/Backend/Element/IconElement"],(function(e,t,r,i,n,o,s,a,d,l,c,g,h,p){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileStorageTreeNavigationComponent=t.navigationComponentName=void 0,o=__importDefault(o),g=__importDefault(g),t.navigationComponentName="typo3-backend-navigation-component-filestoragetree";let u=class extends n.FileStorageTree{constructor(){super(),this.actionHandler=new m(this)}updateNodeBgClass(e){return super.updateNodeBgClass.call(this,e).call(this.initializeDragForNode())}nodesUpdate(e){return super.nodesUpdate.call(this,e).call(this.initializeDragForNode())}initializeDragForNode(){return this.actionHandler.connectDragHandler(new v(this,this.actionHandler))}};u=__decorate([i.customElement("typo3-backend-navigation-component-filestorage-tree")],u);let f=class extends r.LitElement{constructor(){super(...arguments),this.refresh=()=>{this.tree.refreshOrFilterTree()},this.selectFirstNode=()=>{const e=this.tree.nodes[0];e&&this.tree.selectNode(e,!0)},this.treeUpdateRequested=e=>{const t=encodeURIComponent(e.detail.payload.identifier);let r=this.tree.nodes.filter(e=>e.identifier===t)[0];r&&0===this.tree.getSelectedNodes().filter(e=>e.identifier===r.identifier).length&&this.tree.selectNode(r,!1)},this.toggleExpandState=e=>{const t=e.detail.node;t&&o.default.set("BackendComponents.States.FileStorageTree.stateHash."+t.stateIdentifier,t.expanded?"1":"0")},this.loadContent=e=>{const t=e.detail.node;if(!(null==t?void 0:t.checked))return;if(h.ModuleStateStorage.update("file",t.identifier,!0),!1===e.detail.propagate)return;const r=top.TYPO3.ModuleMenu.App;let i=p.getRecordFromName(r.getCurrentModule()).link;i+=i.includes("?")?"&":"?",top.TYPO3.Backend.ContentContainer.setUrl(i+"id="+t.identifier)},this.showContextMenu=e=>{const t=e.detail.node;t&&s.show(t.itemType,decodeURIComponent(t.identifier),"tree","","",this.tree.getNodeElement(t))},this.selectActiveNode=e=>{const t=h.ModuleStateStorage.current("file").selection;let r=e.detail.nodes;e.detail.nodes=r.map(e=>(e.identifier===t&&(e.checked=!0),e))}}connectedCallback(){super.connectedCallback(),document.addEventListener("typo3:filestoragetree:refresh",this.refresh),document.addEventListener("typo3:filestoragetree:selectFirstNode",this.selectFirstNode),document.addEventListener("typo3:filelist:treeUpdateRequested",this.treeUpdateRequested)}disconnectedCallback(){document.removeEventListener("typo3:filestoragetree:refresh",this.refresh),document.removeEventListener("typo3:filestoragetree:selectFirstNode",this.selectFirstNode),document.removeEventListener("typo3:filelist:treeUpdateRequested",this.treeUpdateRequested),super.disconnectedCallback()}createRenderRoot(){return this}render(){const e={dataUrl:top.TYPO3.settings.ajaxUrls.filestorage_tree_data,filterUrl:top.TYPO3.settings.ajaxUrls.filestorage_tree_filter,showIcons:!0};return r.html` <div id="typo3-filestoragetree" class="svg-tree"> <div> <typo3-backend-tree-toolbar .tree="${this.tree}" id="filestoragetree-toolbar" class="svg-toolbar"></typo3-backend-tree-toolbar> @@ -22,4 +22,4 @@ var __decorate=this&&this.__decorate||function(e,t,r,i){var n,s=arguments.length <typo3-backend-icon identifier="spinner-circle-light" size="large"></typo3-backend-icon> </div> </div> - `}firstUpdated(){this.toolbar.tree=this.tree,this.tree.addEventListener("typo3:svg-tree:expand-toggle",this.toggleExpandState),this.tree.addEventListener("typo3:svg-tree:node-selected",this.loadContent),this.tree.addEventListener("typo3:svg-tree:node-context",this.showContextMenu),this.tree.addEventListener("typo3:svg-tree:nodes-prepared",this.selectActiveNode)}};__decorate([i.query(".svg-tree-wrapper")],u.prototype,"tree",void 0),__decorate([i.query("typo3-backend-tree-toolbar")],u.prototype,"toolbar",void 0),u=__decorate([i.customElement(t.navigationComponentName)],u),t.FileStorageTreeNavigationComponent=u;class f extends a.DragDrop{changeNodePosition(e){const t=this.tree.nodes,r=this.tree.settings.nodeDrag.identifier;let i=this.tree.settings.nodeDragPosition,n=e||this.tree.settings.nodeDrag;if(r===n.identifier)return null;if(i===a.DraggablePositionEnum.BEFORE){const r=t.indexOf(e),s=this.setNodePositionAndTarget(r);if(null===s)return null;i=s.position,n=s.target}return{node:this.tree.settings.nodeDrag,identifier:r,target:n,position:i}}setNodePositionAndTarget(e){const t=this.tree.nodes,r=t[e].depth;e>0&&e--;const i=t[e].depth,n=this.tree.nodes[e];if(i===r)return{position:a.DraggablePositionEnum.AFTER,target:n};if(i<r)return{position:a.DraggablePositionEnum.INSIDE,target:n};for(let i=e;i>=0;i--){if(t[i].depth===r)return{position:a.DraggablePositionEnum.AFTER,target:this.tree.nodes[i]};if(t[i].depth<r)return{position:a.DraggablePositionEnum.AFTER,target:t[i]}}return null}changeNodeClasses(e){const t=this.tree.svg.select(".node-over"),r=this.tree.svg.node().parentNode.querySelector(".node-dd");t.size()&&this.tree.isOverSvg&&(this.tree.nodesBgContainer.selectAll(".node-bg__border").style("display","none"),this.addNodeDdClass(r,"ok-append"),this.tree.settings.nodeDragPosition=a.DraggablePositionEnum.INSIDE)}}class v{constructor(e,t){this.startDrag=!1,this.startPageX=0,this.startPageY=0,this.isDragged=!1,this.tree=e,this.actionHandler=t}dragStart(e){return 0!==e.subject.depth&&(this.startPageX=e.sourceEvent.pageX,this.startPageY=e.sourceEvent.pageY,this.startDrag=!1,!0)}dragDragged(e){let t=e.subject;if(!this.actionHandler.isDragNodeDistanceMore(e,this))return!1;if(this.startDrag=!0,0===t.depth)return!1;this.tree.settings.nodeDrag=t;let r=this.tree.svg.node().querySelector('.node-bg[data-state-id="'+t.stateIdentifier+'"]'),i=this.tree.svg.node().parentNode.querySelector(".node-dd");return this.isDragged||(this.isDragged=!0,this.actionHandler.createDraggable(this.tree.getIconId(t),t.name),null==r||r.classList.add("node-bg--dragging")),this.tree.settings.nodeDragPosition=!1,this.actionHandler.openNodeTimeout(),this.actionHandler.updateDraggablePosition(e),(t.isOver||this.tree.hoveredNode&&-1!==this.tree.hoveredNode.parentsStateIdentifier.indexOf(t.stateIdentifier)||!this.tree.isOverSvg)&&(this.actionHandler.addNodeDdClass(i,"nodrop"),this.tree.isOverSvg||this.tree.nodesBgContainer.selectAll(".node-bg__border").style("display","none")),!this.tree.hoveredNode||this.isInSameParentNode(t,this.tree.hoveredNode)?(this.actionHandler.addNodeDdClass(i,"nodrop"),this.tree.nodesBgContainer.selectAll(".node-bg__border").style("display","none")):this.actionHandler.changeNodeClasses(e),!0}isInSameParentNode(e,t){return e.stateIdentifier==t.stateIdentifier||e.parentsStateIdentifier[0]==t.stateIdentifier||t.parentsStateIdentifier.includes(e.stateIdentifier)}dragEnd(e){let t=e.subject;if(!this.startDrag||0===t.depth)return!1;let r=this.tree.hoveredNode;if(this.isDragged=!1,this.actionHandler.removeNodeDdClass(),!(t.isOver||r&&-1!==r.parentsStateIdentifier.indexOf(t.stateIdentifier))&&this.tree.settings.canNodeDrag&&this.tree.isOverSvg){let e=this.actionHandler.changeNodePosition(r),t=e.position===a.DraggablePositionEnum.INSIDE?TYPO3.lang["mess.move_into"]:TYPO3.lang["mess.move_after"];t=t.replace("%s",e.node.name).replace("%s",e.target.name),d.confirm(TYPO3.lang.move_folder,t,l.warning,[{text:TYPO3.lang["labels.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:TYPO3.lang["cm.copy"]||"Copy",btnClass:"btn-warning",name:"copy"},{text:TYPO3.lang["labels.move"]||"Move",btnClass:"btn-warning",name:"move"}]).on("button.clicked",t=>{const r=t.target;"move"===r.name?this.sendChangeCommand("move",e):"copy"===r.name&&this.sendChangeCommand("copy",e),d.dismiss()})}return!0}sendChangeCommand(e,t){let r={data:{}};if("copy"===e)r.data.copy=[],r.copy.push({data:decodeURIComponent(t.identifier),target:decodeURIComponent(t.target.identifier)});else{if("move"!==e)return;r.data.move=[],r.data.move.push({data:decodeURIComponent(t.identifier),target:decodeURIComponent(t.target.identifier)})}this.tree.nodesAddPlaceholder(),new g.default(top.TYPO3.settings.ajaxUrls.file_process+"&includeMessages=1").post(r).then(e=>e.resolve()).then(e=>{e&&e.hasErrors?(this.tree.errorNotification(e.messages,!1),this.tree.nodesContainer.selectAll(".node").remove(),this.tree.updateVisibleNodes(),this.tree.nodesRemovePlaceholder()):(e.messages&&e.messages.forEach(e=>{c.showMessage(e.title||"",e.message||"",e.severity)}),this.tree.refreshOrFilterTree())}).catch(e=>{this.tree.errorNotification(e,!0)})}}})); \ No newline at end of file + `}firstUpdated(){this.toolbar.tree=this.tree,this.tree.addEventListener("typo3:svg-tree:expand-toggle",this.toggleExpandState),this.tree.addEventListener("typo3:svg-tree:node-selected",this.loadContent),this.tree.addEventListener("typo3:svg-tree:node-context",this.showContextMenu),this.tree.addEventListener("typo3:svg-tree:nodes-prepared",this.selectActiveNode)}};__decorate([i.query(".svg-tree-wrapper")],f.prototype,"tree",void 0),__decorate([i.query("typo3-backend-tree-toolbar")],f.prototype,"toolbar",void 0),f=__decorate([i.customElement(t.navigationComponentName)],f),t.FileStorageTreeNavigationComponent=f;class m extends a.DragDrop{changeNodePosition(e){const t=this.tree.nodes,r=this.tree.settings.nodeDrag.identifier;let i=this.tree.settings.nodeDragPosition,n=e||this.tree.settings.nodeDrag;if(r===n.identifier)return null;if(i===a.DraggablePositionEnum.BEFORE){const r=t.indexOf(e),o=this.setNodePositionAndTarget(r);if(null===o)return null;i=o.position,n=o.target}return{node:this.tree.settings.nodeDrag,identifier:r,target:n,position:i}}setNodePositionAndTarget(e){const t=this.tree.nodes,r=t[e].depth;e>0&&e--;const i=t[e].depth,n=this.tree.nodes[e];if(i===r)return{position:a.DraggablePositionEnum.AFTER,target:n};if(i<r)return{position:a.DraggablePositionEnum.INSIDE,target:n};for(let i=e;i>=0;i--){if(t[i].depth===r)return{position:a.DraggablePositionEnum.AFTER,target:this.tree.nodes[i]};if(t[i].depth<r)return{position:a.DraggablePositionEnum.AFTER,target:t[i]}}return null}changeNodeClasses(e){const t=this.tree.svg.select(".node-over"),r=this.tree.svg.node().parentNode.querySelector(".node-dd");t.size()&&this.tree.isOverSvg&&(this.tree.nodesBgContainer.selectAll(".node-bg__border").style("display","none"),this.addNodeDdClass(r,"ok-append"),this.tree.settings.nodeDragPosition=a.DraggablePositionEnum.INSIDE)}}class v{constructor(e,t){this.startDrag=!1,this.startPageX=0,this.startPageY=0,this.isDragged=!1,this.tree=e,this.actionHandler=t}dragStart(e){return 0!==e.subject.depth&&(this.startPageX=e.sourceEvent.pageX,this.startPageY=e.sourceEvent.pageY,this.startDrag=!1,!0)}dragDragged(e){let t=e.subject;if(!this.actionHandler.isDragNodeDistanceMore(e,this))return!1;if(this.startDrag=!0,0===t.depth)return!1;this.tree.settings.nodeDrag=t;let r=this.tree.svg.node().querySelector('.node-bg[data-state-id="'+t.stateIdentifier+'"]'),i=this.tree.svg.node().parentNode.querySelector(".node-dd");return this.isDragged||(this.isDragged=!0,this.actionHandler.createDraggable(this.tree.getIconId(t),t.name),null==r||r.classList.add("node-bg--dragging")),this.tree.settings.nodeDragPosition=!1,this.actionHandler.openNodeTimeout(),this.actionHandler.updateDraggablePosition(e),(t.isOver||this.tree.hoveredNode&&-1!==this.tree.hoveredNode.parentsStateIdentifier.indexOf(t.stateIdentifier)||!this.tree.isOverSvg)&&(this.actionHandler.addNodeDdClass(i,"nodrop"),this.tree.isOverSvg||this.tree.nodesBgContainer.selectAll(".node-bg__border").style("display","none")),!this.tree.hoveredNode||this.isInSameParentNode(t,this.tree.hoveredNode)?(this.actionHandler.addNodeDdClass(i,"nodrop"),this.tree.nodesBgContainer.selectAll(".node-bg__border").style("display","none")):this.actionHandler.changeNodeClasses(e),!0}isInSameParentNode(e,t){return e.stateIdentifier==t.stateIdentifier||e.parentsStateIdentifier[0]==t.stateIdentifier||t.parentsStateIdentifier.includes(e.stateIdentifier)}dragEnd(e){let t=e.subject;if(!this.startDrag||0===t.depth)return!1;let r=this.tree.hoveredNode;if(this.isDragged=!1,this.actionHandler.removeNodeDdClass(),!(t.isOver||r&&-1!==r.parentsStateIdentifier.indexOf(t.stateIdentifier))&&this.tree.settings.canNodeDrag&&this.tree.isOverSvg){let e=this.actionHandler.changeNodePosition(r),t=e.position===a.DraggablePositionEnum.INSIDE?TYPO3.lang["mess.move_into"]:TYPO3.lang["mess.move_after"];t=t.replace("%s",e.node.name).replace("%s",e.target.name),d.confirm(TYPO3.lang.move_folder,t,l.warning,[{text:TYPO3.lang["labels.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:TYPO3.lang["cm.copy"]||"Copy",btnClass:"btn-warning",name:"copy"},{text:TYPO3.lang["labels.move"]||"Move",btnClass:"btn-warning",name:"move"}]).on("button.clicked",t=>{const r=t.target;"move"===r.name?this.sendChangeCommand("move",e):"copy"===r.name&&this.sendChangeCommand("copy",e),d.dismiss()})}return!0}sendChangeCommand(e,t){let r={data:{}};if("copy"===e)r.data.copy=[],r.copy.push({data:decodeURIComponent(t.identifier),target:decodeURIComponent(t.target.identifier)});else{if("move"!==e)return;r.data.move=[],r.data.move.push({data:decodeURIComponent(t.identifier),target:decodeURIComponent(t.target.identifier)})}this.tree.nodesAddPlaceholder(),new g.default(top.TYPO3.settings.ajaxUrls.file_process+"&includeMessages=1").post(r).then(e=>e.resolve()).then(e=>{e&&e.hasErrors?(this.tree.errorNotification(e.messages,!1),this.tree.nodesContainer.selectAll(".node").remove(),this.tree.updateVisibleNodes(),this.tree.nodesRemovePlaceholder()):(e.messages&&e.messages.forEach(e=>{c.showMessage(e.title||"",e.message||"",e.severity)}),this.tree.refreshOrFilterTree())}).catch(e=>{this.tree.errorNotification(e,!0)})}}})); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/backend.js b/typo3/sysext/backend/Resources/Public/JavaScript/backend.js index cf3403b68cf2c18f5e7fddbbd4f21761be216e62..7663f18ca50299aa3296533eaf68b157a65b75ba 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/backend.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/backend.js @@ -24,27 +24,31 @@ var TYPO3 = TYPO3 || {}; /** * jump the backend to a module + * @deprecated will be removed in TYPO3 v12.0. */ function jump(url, modName, mainModName, pageId) { - if (isNaN(pageId)) { - pageId = -2; - } - // @todo Once available, should be using ESM native import + console.warn('Using jump is deprecated, use `typo3-backend-module-router` instead.'); require(['TYPO3/CMS/Backend/Storage/ModuleStateStorage'], () => { // clear information about which entry in nav. tree that might have been highlighted. - ModuleStateStorage.updateWithCurrentMount('web', pageId); - top.nextLoadModuleUrl = url; - top.TYPO3.ModuleMenu.App.showModule(modName); + if (!isNaN(pageId)) { + ModuleStateStorage.updateWithCurrentMount('web', pageId, true); + } + const router = document.querySelector('typo3-backend-module-router'); + router.setAttribute('endpoint', url); + router.setAttribute('module', modName); }); } /** * Returns incoming URL (to a module) unless nextLoadModuleUrl is set. If that is the case nextLoadModuleUrl is returned (and cleared) * Used by the shortcut frame to set a "intermediate URL" + * @deprecated will be removed in TYPO3 v12.0. */ var nextLoadModuleUrl = ""; -// Used by Frameset Modules +/** + * @deprecated will be removed in TYPO3 v12.0. + */ var currentSubScript = ""; /** diff --git a/typo3/sysext/backend/Tests/Functional/Backend/Shortcut/ShortcutRepositoryTest.php b/typo3/sysext/backend/Tests/Functional/Backend/Shortcut/ShortcutRepositoryTest.php index 45cb190e7bbd525afc86eaa18455364767948775..96e988e764effb00a3e72910188a39aa128dcc47 100644 --- a/typo3/sysext/backend/Tests/Functional/Backend/Shortcut/ShortcutRepositoryTest.php +++ b/typo3/sysext/backend/Tests/Functional/Backend/Shortcut/ShortcutRepositoryTest.php @@ -141,7 +141,7 @@ class ShortcutRepositoryTest extends FunctionalTestCase 'type' => 'other', 'icon' => 'data-identifier="module-web_list"', 'label' => 'Recordlist', - 'action' => 'id=123\u0026GET%5BclipBoard%5D=1\',\'web_list\',\'web_list\', 123);' + 'href' => '/typo3/module/web/list?token=%s&id=123&GET%5BclipBoard%5D=1', ], 2 => [ 'table' => 'tt_content', @@ -150,7 +150,7 @@ class ShortcutRepositoryTest extends FunctionalTestCase 'type' => 'edit', 'label' => 'Edit Content', 'icon' => 'data-identifier="mimetypes-x-content-text"', - 'action' => '\u0026edit%5Btt_content%5D%5B113%5D=edit\',\'record_edit\',\'record_edit\', 321);' + 'href' => '/typo3/record/edit?token=%s&edit%5Btt_content%5D%5B113%5D=edit', ], 6 => [ 'table' => null, @@ -159,7 +159,7 @@ class ShortcutRepositoryTest extends FunctionalTestCase 'type' => 'other', 'label' => 'Page content', 'icon' => 'data-identifier="module-web_layout"', - 'action' => '\u0026id=123\',\'web_layout\',\'web_layout\', 123);' + 'href' => '/typo3/module/web/layout?token=%s&id=123' ] ]; @@ -175,7 +175,7 @@ class ShortcutRepositoryTest extends FunctionalTestCase self::assertEquals($expected[$id]['type'], $shortcut['type']); self::assertEquals($expected[$id]['label'], $shortcut['label']); self::assertStringContainsString($expected[$id]['icon'], $shortcut['icon']); - self::assertStringContainsString($expected[$id]['action'], $shortcut['action']); + self::assertStringMatchesFormat($expected[$id]['href'], $shortcut['href']); } } } diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-95011-VariousGlobalJavaScriptFunctionsAndVariables.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-95011-VariousGlobalJavaScriptFunctionsAndVariables.rst new file mode 100644 index 0000000000000000000000000000000000000000..6dbb97c906faa3063cbf7e0229a25f1018cfcc35 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-95011-VariousGlobalJavaScriptFunctionsAndVariables.rst @@ -0,0 +1,54 @@ +.. include:: ../../Includes.txt + +======================================================================= +Deprecation: #95011 - Various global JavaScript functions and variables +======================================================================= + +See :issue:`95011` + +Description +=========== + +The following globally available variables in TYPO3 Backend's JavaScript code have been deprecated: + +* :js:`top.currentSubScript` +* :js:`top.currentModuleLoaded` +* :js:`top.nextLoadModuleUrl` + +In addition the global JavaScript function :js:`jump()` has +been deprecated as well. + +This functionality has been around for a very long time, and +have been superseded by TYPO3's Module Menu Component (since 4.5) and the newly introduced Backend Routing Component in JavaScript +since TYPO3 v11. + + +Impact +====== + +The variables will work and filled as expected in TYPO3 v11, but will not be available anymore in TYPO3 v12. + +Calling :js:`jump()` will trigger a JavaScript warning in ones' +Browser console. + + +Affected Installations +====================== + +TYPO3 installations with custom extensions which utilize Backend +JavaScript and using the legacy functionality, which is highly +unlikely. + + +Migration +========= + +Use the ModuleMenu JavaScript API or the Router API to find out the current module or go to a specific route: + +``` + const router = document.querySelector('typo3-backend-module-router'); + router.setAttribute('endpoint', url); + router.setAttribute('module', moduleName); +``` + +.. index:: Backend, JavaScript, NotScanned, ext:backend \ No newline at end of file diff --git a/typo3/sysext/impexp/Classes/Controller/ExportController.php b/typo3/sysext/impexp/Classes/Controller/ExportController.php index 15b53a1d502a310a059681a510f5f56d57f9938b..a046a8ceeca6c1f79843abd5388ed694b664064c 100644 --- a/typo3/sysext/impexp/Classes/Controller/ExportController.php +++ b/typo3/sysext/impexp/Classes/Controller/ExportController.php @@ -49,7 +49,7 @@ class ExportController extends ImportExportController /** * @var string */ - protected $moduleName = 'tx_impexp_export'; + protected $routeName = 'tx_impexp_export'; /** * @var Export diff --git a/typo3/sysext/impexp/Classes/Controller/ImportController.php b/typo3/sysext/impexp/Classes/Controller/ImportController.php index 0be45ff62d38ac15287b16891ee8e0131f09a390..bb3b491e2664a5db21edb488cc2c88023b27c745 100644 --- a/typo3/sysext/impexp/Classes/Controller/ImportController.php +++ b/typo3/sysext/impexp/Classes/Controller/ImportController.php @@ -47,7 +47,7 @@ class ImportController extends ImportExportController /** * @var string */ - protected $moduleName = 'tx_impexp_import'; + protected $routeName = 'tx_impexp_import'; /** * @var Import diff --git a/typo3/sysext/impexp/Classes/Controller/ImportExportController.php b/typo3/sysext/impexp/Classes/Controller/ImportExportController.php index ee8863a75058613df9e5565dbbfbe3e8b023117a..367aa6364d2606ea5badda4b68a3407bb531b0d3 100644 --- a/typo3/sysext/impexp/Classes/Controller/ImportExportController.php +++ b/typo3/sysext/impexp/Classes/Controller/ImportExportController.php @@ -65,7 +65,7 @@ abstract class ImportExportController /** * @var string */ - protected $moduleName = ''; + protected $routeName = ''; /** * @var ModuleTemplate @@ -138,6 +138,7 @@ abstract class ImportExportController $parsedBody = $request->getParsedBody(); $this->moduleTemplate = $this->moduleTemplateFactory->create($request); + $this->moduleTemplate->setModuleName(''); // Checking page access $this->id = (int)($parsedBody['id'] ?? $queryParams['id'] ?? 0); @@ -158,7 +159,7 @@ abstract class ImportExportController $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Impexp/ImportExport'); $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Element/ImmediateActionElement'); - $this->standaloneView->assign('moduleUrl', (string)$this->uriBuilder->buildUriFromRoute($this->moduleName)); + $this->standaloneView->assign('moduleUrl', (string)$this->uriBuilder->buildUriFromRoute($this->routeName)); $this->standaloneView->assign('id', $this->id); } diff --git a/typo3/sysext/opendocs/Resources/Public/JavaScript/Toolbar/OpendocsMenu.js b/typo3/sysext/opendocs/Resources/Public/JavaScript/Toolbar/OpendocsMenu.js index 291ab9d584b11cef24430c292d1e9b9f174ee251..7c2ba3695618e0a198f8664be11d6ed0caafdb41 100644 --- a/typo3/sysext/opendocs/Resources/Public/JavaScript/Toolbar/OpendocsMenu.js +++ b/typo3/sysext/opendocs/Resources/Public/JavaScript/Toolbar/OpendocsMenu.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/Icons","TYPO3/CMS/Backend/Viewport"],(function(e,t,o,n,c,r){"use strict";var a;o=__importDefault(o),function(e){e.containerSelector="#typo3-cms-opendocs-backend-toolbaritems-opendocstoolbaritem",e.closeSelector=".t3js-topbar-opendocs-close",e.menuContainerSelector=".dropdown-menu",e.toolbarIconSelector=".toolbar-item-icon .t3js-icon",e.openDocumentsItemsSelector=".t3js-topbar-opendocs-item",e.counterSelector="#tx-opendocs-counter",e.entrySelector=".t3js-open-doc"}(a||(a={}));class l{constructor(){this.hashDataAttributeName="opendocsidentifier",this.toggleMenu=()=>{o.default(".scaffold").removeClass("scaffold-toolbar-expanded"),o.default(a.containerSelector).toggleClass("open")},r.Topbar.Toolbar.registerEvent(()=>{this.initializeEvents(),this.updateMenu()})}static updateNumberOfDocs(){const e=o.default(a.containerSelector).find(a.openDocumentsItemsSelector).length;o.default(a.counterSelector).text(e).toggle(e>0)}updateMenu(){let e=o.default(a.toolbarIconSelector,a.containerSelector),t=e.clone();c.getIcon("spinner-circle-light",c.sizes.small).done(t=>{e.replaceWith(t)}),new n(TYPO3.settings.ajaxUrls.opendocs_menu).get().then(async e=>{o.default(a.containerSelector).find(a.menuContainerSelector).html(await e.resolve()),l.updateNumberOfDocs()}).finally(()=>{o.default(a.toolbarIconSelector,a.containerSelector).replaceWith(t)})}initializeEvents(){o.default(a.containerSelector).on("click",a.closeSelector,e=>{e.preventDefault();const t=o.default(e.currentTarget).data(this.hashDataAttributeName);this.closeDocument(t)}).on("click",a.entrySelector,e=>{e.preventDefault();const t=o.default(e.currentTarget);this.toggleMenu(),window.jump(t.attr("href"),"web_list","web",t.data("pid"))})}closeDocument(e){const t={};e&&(t.md5sum=e),new n(TYPO3.settings.ajaxUrls.opendocs_closedoc).post(t).then(async e=>{o.default(a.menuContainerSelector,a.containerSelector).html(await e.resolve()),l.updateNumberOfDocs(),o.default(a.containerSelector).toggleClass("open")})}}let s;return s=new l,"undefined"!=typeof TYPO3&&(TYPO3.OpendocsMenu=s),s})); \ No newline at end of file +var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/Icons","TYPO3/CMS/Backend/Viewport","TYPO3/CMS/Backend/Storage/ModuleStateStorage"],(function(e,t,o,n,r,c,a){"use strict";var l;o=__importDefault(o),function(e){e.containerSelector="#typo3-cms-opendocs-backend-toolbaritems-opendocstoolbaritem",e.closeSelector=".t3js-topbar-opendocs-close",e.menuContainerSelector=".dropdown-menu",e.toolbarIconSelector=".toolbar-item-icon .t3js-icon",e.openDocumentsItemsSelector=".t3js-topbar-opendocs-item",e.counterSelector="#tx-opendocs-counter",e.entrySelector=".t3js-open-doc"}(l||(l={}));class s{constructor(){this.hashDataAttributeName="opendocsidentifier",this.toggleMenu=()=>{o.default(".scaffold").removeClass("scaffold-toolbar-expanded"),o.default(l.containerSelector).toggleClass("open")},c.Topbar.Toolbar.registerEvent(()=>{this.initializeEvents(),this.updateMenu()})}static updateNumberOfDocs(){const e=o.default(l.containerSelector).find(l.openDocumentsItemsSelector).length;o.default(l.counterSelector).text(e).toggle(e>0)}updateMenu(){let e=o.default(l.toolbarIconSelector,l.containerSelector),t=e.clone();r.getIcon("spinner-circle-light",r.sizes.small).done(t=>{e.replaceWith(t)}),new n(TYPO3.settings.ajaxUrls.opendocs_menu).get().then(async e=>{o.default(l.containerSelector).find(l.menuContainerSelector).html(await e.resolve()),s.updateNumberOfDocs()}).finally(()=>{o.default(l.toolbarIconSelector,l.containerSelector).replaceWith(t)})}initializeEvents(){o.default(l.containerSelector).on("click",l.closeSelector,e=>{e.preventDefault();const t=o.default(e.currentTarget).data(this.hashDataAttributeName);this.closeDocument(t)}).on("click",l.entrySelector,e=>{e.preventDefault();const t=o.default(e.currentTarget);this.toggleMenu(),a.ModuleStateStorage.updateWithCurrentMount("web",t.data("pid"),!0);document.querySelector("typo3-backend-module-router").setAttribute("endpoint",t.attr("href"))})}closeDocument(e){const t={};e&&(t.md5sum=e),new n(TYPO3.settings.ajaxUrls.opendocs_closedoc).post(t).then(async e=>{o.default(l.menuContainerSelector,l.containerSelector).html(await e.resolve()),s.updateNumberOfDocs(),o.default(l.containerSelector).toggleClass("open")})}}let i;return i=new s,"undefined"!=typeof TYPO3&&(TYPO3.OpendocsMenu=i),i})); \ No newline at end of file diff --git a/typo3/sysext/workspaces/Resources/Public/JavaScript/Toolbar/WorkspacesMenu.js b/typo3/sysext/workspaces/Resources/Public/JavaScript/Toolbar/WorkspacesMenu.js index 9680797f432f6b537faa6a272f5ebbbc4fde831b..736bba14ec886086d20fb28e8c091f7c6beda4e7 100644 --- a/typo3/sysext/workspaces/Resources/Public/JavaScript/Toolbar/WorkspacesMenu.js +++ b/typo3/sysext/workspaces/Resources/Public/JavaScript/Toolbar/WorkspacesMenu.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/ModuleMenu","TYPO3/CMS/Backend/Viewport","TYPO3/CMS/Core/Event/RegularEvent","TYPO3/CMS/Backend/Storage/ModuleStateStorage"],(function(e,t,a,o,r,s,c,n){"use strict";var l,i;a=__importDefault(a),function(e){e.containerSelector="#typo3-cms-workspaces-backend-toolbaritems-workspaceselectortoolbaritem",e.activeMenuItemLinkSelector=".dropdown-menu .selected",e.menuItemSelector=".t3js-workspace-item",e.menuItemLinkSelector=".t3js-workspaces-switchlink",e.toolbarItemSelector=".dropdown-toggle",e.workspaceModuleLinkSelector=".t3js-workspaces-modulelink"}(l||(l={})),function(e){e.workspaceBodyClass="typo3-in-workspace",e.workspacesTitleInToolbarClass="toolbar-item-name"}(i||(i={}));class p{static refreshPageTree(){document.dispatchEvent(new CustomEvent("typo3:pagetree:refresh"))}static updateWorkspaceState(){const e=document.querySelector(l.containerSelector+" .t3js-workspace-item.selected .t3js-workspaces-switchlink");if(null!==e){const t=parseInt(e.dataset.workspaceid,10),a=e.innerText.trim();top.TYPO3.configuration.inWorkspace=0!==t,top.TYPO3.Backend.workspaceTitle=top.TYPO3.configuration.inWorkspace?a:""}}static updateTopBar(e){if(a.default("."+i.workspacesTitleInToolbarClass,l.containerSelector).remove(),e&&e.length){let t=a.default("<span>",{class:i.workspacesTitleInToolbarClass}).text(e);a.default(l.toolbarItemSelector,l.containerSelector).append(t)}}static updateBackendContext(){let e="";p.updateWorkspaceState(),TYPO3.configuration.inWorkspace?(a.default("body").addClass(i.workspaceBodyClass),e=top.TYPO3.Backend.workspaceTitle||TYPO3.lang["Workspaces.workspaceTitle"]):a.default("body").removeClass(i.workspaceBodyClass),p.updateTopBar(e)}constructor(){s.Topbar.Toolbar.registerEvent(()=>{this.initializeEvents(),p.updateBackendContext()}),new c("typo3:datahandler:process",e=>{const t=e.detail.payload;"sys_workspace"===t.table&&"delete"===t.action&&!1===t.hasErrors&&s.Topbar.refresh()}).bindTo(document)}performWorkspaceSwitch(e){a.default(l.activeMenuItemLinkSelector+" i",l.containerSelector).removeClass("fa fa-check").addClass("fa fa-empty-empty"),a.default(l.activeMenuItemLinkSelector,l.containerSelector).removeClass("selected");const t=a.default(l.menuItemLinkSelector+"[data-workspaceid="+e+"]",l.containerSelector).closest(l.menuItemSelector);t.find("i").removeClass("fa fa-empty-empty").addClass("fa fa-check"),t.addClass("selected"),p.updateBackendContext()}initializeEvents(){a.default(l.containerSelector).on("click",l.workspaceModuleLinkSelector,e=>{e.preventDefault(),r.App.showModule(e.currentTarget.dataset.module)}),a.default(l.containerSelector).on("click",l.menuItemLinkSelector,e=>{e.preventDefault(),this.switchWorkspace(parseInt(e.currentTarget.dataset.workspaceid,10))})}switchWorkspace(e){new o(TYPO3.settings.ajaxUrls.workspace_switch).post({workspaceId:e,pageId:n.ModuleStateStorage.current("web").identifier}).then(async t=>{const a=await t.resolve();if(a.workspaceId||(a.workspaceId=0),this.performWorkspaceSwitch(parseInt(a.workspaceId,10)),a.pageId){n.ModuleStateStorage.update("web",a.pageId,!0);let e=TYPO3.Backend.ContentContainer.getUrl();e+=(e.includes("?")?"&":"?")+"&id="+a.pageId,p.refreshPageTree(),s.ContentContainer.setUrl(e)}else top.currentModuleLoaded.startsWith("web_")?(p.refreshPageTree(),"web_WorkspacesWorkspaces"===top.currentModuleLoaded?r.App.showModule(top.currentModuleLoaded,"workspace="+e):r.App.reloadFrames()):TYPO3.configuration.pageModule&&r.App.showModule(TYPO3.configuration.pageModule);r.App.refreshMenu()})}}const d=new p;return TYPO3.WorkspacesMenu=d,d})); \ No newline at end of file +var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/ModuleMenu","TYPO3/CMS/Backend/Viewport","TYPO3/CMS/Core/Event/RegularEvent","TYPO3/CMS/Backend/Storage/ModuleStateStorage"],(function(e,t,a,o,r,s,c,n){"use strict";var l,i;a=__importDefault(a),function(e){e.containerSelector="#typo3-cms-workspaces-backend-toolbaritems-workspaceselectortoolbaritem",e.activeMenuItemLinkSelector=".dropdown-menu .selected",e.menuItemSelector=".t3js-workspace-item",e.menuItemLinkSelector=".t3js-workspaces-switchlink",e.toolbarItemSelector=".dropdown-toggle",e.workspaceModuleLinkSelector=".t3js-workspaces-modulelink"}(l||(l={})),function(e){e.workspaceBodyClass="typo3-in-workspace",e.workspacesTitleInToolbarClass="toolbar-item-name"}(i||(i={}));class p{static refreshPageTree(){document.dispatchEvent(new CustomEvent("typo3:pagetree:refresh"))}static updateWorkspaceState(){const e=document.querySelector(l.containerSelector+" .t3js-workspace-item.selected .t3js-workspaces-switchlink");if(null!==e){const t=parseInt(e.dataset.workspaceid,10),a=e.innerText.trim();top.TYPO3.configuration.inWorkspace=0!==t,top.TYPO3.Backend.workspaceTitle=top.TYPO3.configuration.inWorkspace?a:""}}static updateTopBar(e){if(a.default("."+i.workspacesTitleInToolbarClass,l.containerSelector).remove(),e&&e.length){let t=a.default("<span>",{class:i.workspacesTitleInToolbarClass}).text(e);a.default(l.toolbarItemSelector,l.containerSelector).append(t)}}static updateBackendContext(){let e="";p.updateWorkspaceState(),TYPO3.configuration.inWorkspace?(a.default("body").addClass(i.workspaceBodyClass),e=top.TYPO3.Backend.workspaceTitle||TYPO3.lang["Workspaces.workspaceTitle"]):a.default("body").removeClass(i.workspaceBodyClass),p.updateTopBar(e)}constructor(){s.Topbar.Toolbar.registerEvent(()=>{this.initializeEvents(),p.updateBackendContext()}),new c("typo3:datahandler:process",e=>{const t=e.detail.payload;"sys_workspace"===t.table&&"delete"===t.action&&!1===t.hasErrors&&s.Topbar.refresh()}).bindTo(document)}performWorkspaceSwitch(e){a.default(l.activeMenuItemLinkSelector+" i",l.containerSelector).removeClass("fa fa-check").addClass("fa fa-empty-empty"),a.default(l.activeMenuItemLinkSelector,l.containerSelector).removeClass("selected");const t=a.default(l.menuItemLinkSelector+"[data-workspaceid="+e+"]",l.containerSelector).closest(l.menuItemSelector);t.find("i").removeClass("fa fa-empty-empty").addClass("fa fa-check"),t.addClass("selected"),p.updateBackendContext()}initializeEvents(){a.default(l.containerSelector).on("click",l.workspaceModuleLinkSelector,e=>{e.preventDefault(),r.App.showModule(e.currentTarget.dataset.module)}),a.default(l.containerSelector).on("click",l.menuItemLinkSelector,e=>{e.preventDefault(),this.switchWorkspace(parseInt(e.currentTarget.dataset.workspaceid,10))})}switchWorkspace(e){new o(TYPO3.settings.ajaxUrls.workspace_switch).post({workspaceId:e,pageId:n.ModuleStateStorage.current("web").identifier}).then(async t=>{const a=await t.resolve();a.workspaceId||(a.workspaceId=0),this.performWorkspaceSwitch(parseInt(a.workspaceId,10));const o=r.App.getCurrentModule();if(a.pageId){let e=TYPO3.Backend.ContentContainer.getUrl();e+=(e.includes("?")?"&":"?")+"id="+a.pageId,s.ContentContainer.setUrl(e)}else o.startsWith("web_")?"web_WorkspacesWorkspaces"===o?r.App.showModule(o,"workspace="+e):r.App.reloadFrames():TYPO3.configuration.pageModule&&r.App.showModule(TYPO3.configuration.pageModule);p.refreshPageTree(),r.App.refreshMenu()})}}const d=new p;return TYPO3.WorkspacesMenu=d,d})); \ No newline at end of file