diff --git a/Build/Sources/TypeScript/backend/toolbar/shortcut-menu.ts b/Build/Sources/TypeScript/backend/toolbar/shortcut-menu.ts index 2beea3d7b9bae98bfe57952c7985b8a0431f938a..baae18797f18d0dde3fb560337de6830020a9246 100644 --- a/Build/Sources/TypeScript/backend/toolbar/shortcut-menu.ts +++ b/Build/Sources/TypeScript/backend/toolbar/shortcut-menu.ts @@ -33,9 +33,9 @@ enum Identifiers { shortcutFormTitleSelector = 'input[name="shortcut-title"]', shortcutFormGroupSelector = 'select[name="shortcut-group"]', - shortcutFormSaveSelector = '.shortcut-form-save', - shortcutFormCancelSelector = '.shortcut-form-cancel', - shortcutFormSelector = '.shortcut-form', + shortcutFormSaveSelector = '.t3js-shortcut-form-save', + shortcutFormCancelSelector = '.t3js-shortcut-form-cancel', + shortcutFormSelector = '.t3js-shortcut-form', } /** diff --git a/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/ShortcutToolbarItemEditForm.html b/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/ShortcutToolbarItemEditForm.html index 34d7834d51aa8c3fe5bdc17aefd4225bdfbf8b1d..8a03cc7f5ab68fc68d524d85e6bb15f51dc78d02 100644 --- a/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/ShortcutToolbarItemEditForm.html +++ b/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/ShortcutToolbarItemEditForm.html @@ -1,19 +1,20 @@ -<form class="shortcut-form" role="form" data-shortcutid="{selectedShortcutId}"> - <h3 class="dropdown-header"> +<form class="t3js-shortcut-form" role="form" data-shortcutid="{selectedShortcutId}"> + <h3 class="dropdown-headline"> {f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:toolbarItems.bookmarksEdit')} </h3> <hr class="dropdown-divider" aria-hidden="true"> - <div class="form-group"> - <input type="text" class="form-control" name="shortcut-title" value="{selectedShortcut.label}"/> + <div class="dropdown-item-text"> + <div class="form-group"> + <input type="text" class="form-control" name="shortcut-title" value="{selectedShortcut.label}"/> + </div> + <div class="form-group"> + <select class="form-select" name="shortcut-group"> + <f:for each="{shortcutGroups}" key="shortcutGroupId" as="shortcutGroupTitle"> + <option value="{shortcutGroupId}" {f:if(condition: '{selectedShortcutGroupId} == {shortcutGroupId}', then: 'selected="selected"')}>{shortcutGroupTitle}</option> + </f:for> + </select> + </div> + <input type="button" class="btn btn-default t3js-shortcut-form-cancel" value="Cancel"/> + <input type="button" class="btn btn-success t3js-shortcut-form-save" value="Save"/> </div> - <div class="form-group"> - <select class="form-select" name="shortcut-group"> - <f:for each="{shortcutGroups}" key="shortcutGroupId" as="shortcutGroupTitle"> - <option value="{shortcutGroupId}" {f:if(condition: '{selectedShortcutGroupId} == {shortcutGroupId}', then: 'selected="selected"')}>{shortcutGroupTitle}</option> - </f:for> - </select> - </div> - <hr class="dropdown-divider" aria-hidden="true"> - <input type="button" class="btn btn-default shortcut-form-cancel" value="Cancel"/> - <input type="button" class="btn btn-success shortcut-form-save" value="Save"/> </form> diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/toolbar/shortcut-menu.js b/typo3/sysext/backend/Resources/Public/JavaScript/toolbar/shortcut-menu.js index 644d6559fa6c075d51ec20bc126060185f4175a0..4d34bc2c1aaca50995bac859aab8b79e1f5da309 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/toolbar/shortcut-menu.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/toolbar/shortcut-menu.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -import $ from"jquery";import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import Icons from"@typo3/backend/icons.js";import Modal from"@typo3/backend/modal.js";import Notification from"@typo3/backend/notification.js";import Viewport from"@typo3/backend/viewport.js";import SecurityUtility from"@typo3/core/security-utility.js";import{ModuleStateStorage}from"@typo3/backend/storage/module-state-storage.js";var Identifiers;!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"}(Identifiers||(Identifiers={}));class ShortcutMenu{constructor(){this.initializeEvents=()=>{$(Identifiers.containerSelector).on("click",Identifiers.shortcutDeleteSelector,(t=>{t.preventDefault(),t.stopImmediatePropagation(),this.deleteShortcut($(t.currentTarget).closest(Identifiers.shortcutItemSelector))})).on("click",Identifiers.shortcutFormGroupSelector,(t=>{t.preventDefault(),t.stopImmediatePropagation()})).on("click",Identifiers.shortcutEditSelector,(t=>{t.preventDefault(),t.stopImmediatePropagation(),this.editShortcut($(t.currentTarget).closest(Identifiers.shortcutItemSelector))})).on("click",Identifiers.shortcutFormSaveSelector,(t=>{t.preventDefault(),t.stopImmediatePropagation(),this.saveShortcutForm($(t.currentTarget).closest(Identifiers.shortcutFormSelector))})).on("submit",Identifiers.shortcutFormSelector,(t=>{t.preventDefault(),t.stopImmediatePropagation(),this.saveShortcutForm($(t.currentTarget).closest(Identifiers.shortcutFormSelector))})).on("click",Identifiers.shortcutFormCancelSelector,(t=>{t.preventDefault(),t.stopImmediatePropagation(),this.refreshMenu()})).on("click",Identifiers.shortcutJumpSelector,(t=>{t.preventDefault(),t.stopImmediatePropagation();const e=$(t.currentTarget).data("pageid");e&&ModuleStateStorage.updateWithCurrentMount("web",e,!0);const o=document.querySelector("typo3-backend-module-router");o.setAttribute("endpoint",$(t.currentTarget).attr("href")),o.setAttribute("module",$(t.currentTarget).data("module"))}))},Viewport.Topbar.Toolbar.registerEvent(this.initializeEvents)}createShortcut(t,e,o,r,c){if(void 0!==r){const s=Modal.confirm(TYPO3.lang["bookmark.create"],r);s.addEventListener("confirm.button.ok",(r=>{const i=$(Identifiers.toolbarIconSelector,Identifiers.containerSelector),n=i.clone();Icons.getIcon("spinner-circle-light",Icons.sizes.small).then((t=>{i.replaceWith(t)})),new AjaxRequest(TYPO3.settings.ajaxUrls.shortcut_create).post({routeIdentifier:t,arguments:e,displayName:o}).then((()=>{if(this.refreshMenu(),$(Identifiers.toolbarIconSelector,Identifiers.containerSelector).replaceWith(n),"object"==typeof c){const t=$(c).hasClass("dropdown-item"),e=new SecurityUtility;Icons.getIcon("actions-system-shortcut-active",Icons.sizes.small).then((o=>{$(c).html(o+(t?" "+e.encodeHtml(TYPO3.lang["labels.alreadyBookmarked"]):""))})),$(c).addClass(t?"disabled":"active"),$(c).attr("data-dispatch-disabled","disabled"),$(c).attr("title",TYPO3.lang["labels.alreadyBookmarked"])}})),s.hideModal()})),s.addEventListener("confirm.button.cancel",(()=>s.hideModal()))}}deleteShortcut(t){const e=Modal.confirm(TYPO3.lang["bookmark.delete"],TYPO3.lang["bookmark.confirmDelete"]);e.addEventListener("confirm.button.ok",(()=>{new AjaxRequest(TYPO3.settings.ajaxUrls.shortcut_remove).post({shortcutId:t.data("shortcutid")}).then((()=>{this.refreshMenu()})),e.hideModal()})),e.addEventListener("confirm.button.cancel",(()=>{e.hideModal()}))}editShortcut(t){new AjaxRequest(TYPO3.settings.ajaxUrls.shortcut_editform).withQueryArguments({shortcutId:t.data("shortcutid"),shortcutGroup:t.data("shortcutgroup")}).get({cache:"no-cache"}).then((async t=>{$(Identifiers.containerSelector).find(Identifiers.toolbarMenuSelector).html(await t.resolve())}))}saveShortcutForm(t){new AjaxRequest(TYPO3.settings.ajaxUrls.shortcut_saveform).post({shortcutId:t.data("shortcutid"),shortcutTitle:t.find(Identifiers.shortcutFormTitleSelector).val(),shortcutGroup:t.find(Identifiers.shortcutFormGroupSelector).val()}).then((()=>{Notification.success(TYPO3.lang["bookmark.savedTitle"],TYPO3.lang["bookmark.savedMessage"]),this.refreshMenu()}))}refreshMenu(){new AjaxRequest(TYPO3.settings.ajaxUrls.shortcut_list).get({cache:"no-cache"}).then((async t=>{$(Identifiers.toolbarMenuSelector,Identifiers.containerSelector).html(await t.resolve())}))}}top.TYPO3.ShortcutMenu&&"object"==typeof top.TYPO3.ShortcutMenu||(top.TYPO3.ShortcutMenu=new ShortcutMenu);const shortcutMenuObject=top.TYPO3.ShortcutMenu;export default shortcutMenuObject; \ No newline at end of file +import $ from"jquery";import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import Icons from"@typo3/backend/icons.js";import Modal from"@typo3/backend/modal.js";import Notification from"@typo3/backend/notification.js";import Viewport from"@typo3/backend/viewport.js";import SecurityUtility from"@typo3/core/security-utility.js";import{ModuleStateStorage}from"@typo3/backend/storage/module-state-storage.js";var Identifiers;!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=".t3js-shortcut-form-save",t.shortcutFormCancelSelector=".t3js-shortcut-form-cancel",t.shortcutFormSelector=".t3js-shortcut-form"}(Identifiers||(Identifiers={}));class ShortcutMenu{constructor(){this.initializeEvents=()=>{$(Identifiers.containerSelector).on("click",Identifiers.shortcutDeleteSelector,(t=>{t.preventDefault(),t.stopImmediatePropagation(),this.deleteShortcut($(t.currentTarget).closest(Identifiers.shortcutItemSelector))})).on("click",Identifiers.shortcutFormGroupSelector,(t=>{t.preventDefault(),t.stopImmediatePropagation()})).on("click",Identifiers.shortcutEditSelector,(t=>{t.preventDefault(),t.stopImmediatePropagation(),this.editShortcut($(t.currentTarget).closest(Identifiers.shortcutItemSelector))})).on("click",Identifiers.shortcutFormSaveSelector,(t=>{t.preventDefault(),t.stopImmediatePropagation(),this.saveShortcutForm($(t.currentTarget).closest(Identifiers.shortcutFormSelector))})).on("submit",Identifiers.shortcutFormSelector,(t=>{t.preventDefault(),t.stopImmediatePropagation(),this.saveShortcutForm($(t.currentTarget).closest(Identifiers.shortcutFormSelector))})).on("click",Identifiers.shortcutFormCancelSelector,(t=>{t.preventDefault(),t.stopImmediatePropagation(),this.refreshMenu()})).on("click",Identifiers.shortcutJumpSelector,(t=>{t.preventDefault(),t.stopImmediatePropagation();const e=$(t.currentTarget).data("pageid");e&&ModuleStateStorage.updateWithCurrentMount("web",e,!0);const o=document.querySelector("typo3-backend-module-router");o.setAttribute("endpoint",$(t.currentTarget).attr("href")),o.setAttribute("module",$(t.currentTarget).data("module"))}))},Viewport.Topbar.Toolbar.registerEvent(this.initializeEvents)}createShortcut(t,e,o,r,s){if(void 0!==r){const c=Modal.confirm(TYPO3.lang["bookmark.create"],r);c.addEventListener("confirm.button.ok",(r=>{const i=$(Identifiers.toolbarIconSelector,Identifiers.containerSelector),n=i.clone();Icons.getIcon("spinner-circle-light",Icons.sizes.small).then((t=>{i.replaceWith(t)})),new AjaxRequest(TYPO3.settings.ajaxUrls.shortcut_create).post({routeIdentifier:t,arguments:e,displayName:o}).then((()=>{if(this.refreshMenu(),$(Identifiers.toolbarIconSelector,Identifiers.containerSelector).replaceWith(n),"object"==typeof s){const t=$(s).hasClass("dropdown-item"),e=new SecurityUtility;Icons.getIcon("actions-system-shortcut-active",Icons.sizes.small).then((o=>{$(s).html(o+(t?" "+e.encodeHtml(TYPO3.lang["labels.alreadyBookmarked"]):""))})),$(s).addClass(t?"disabled":"active"),$(s).attr("data-dispatch-disabled","disabled"),$(s).attr("title",TYPO3.lang["labels.alreadyBookmarked"])}})),c.hideModal()})),c.addEventListener("confirm.button.cancel",(()=>c.hideModal()))}}deleteShortcut(t){const e=Modal.confirm(TYPO3.lang["bookmark.delete"],TYPO3.lang["bookmark.confirmDelete"]);e.addEventListener("confirm.button.ok",(()=>{new AjaxRequest(TYPO3.settings.ajaxUrls.shortcut_remove).post({shortcutId:t.data("shortcutid")}).then((()=>{this.refreshMenu()})),e.hideModal()})),e.addEventListener("confirm.button.cancel",(()=>{e.hideModal()}))}editShortcut(t){new AjaxRequest(TYPO3.settings.ajaxUrls.shortcut_editform).withQueryArguments({shortcutId:t.data("shortcutid"),shortcutGroup:t.data("shortcutgroup")}).get({cache:"no-cache"}).then((async t=>{$(Identifiers.containerSelector).find(Identifiers.toolbarMenuSelector).html(await t.resolve())}))}saveShortcutForm(t){new AjaxRequest(TYPO3.settings.ajaxUrls.shortcut_saveform).post({shortcutId:t.data("shortcutid"),shortcutTitle:t.find(Identifiers.shortcutFormTitleSelector).val(),shortcutGroup:t.find(Identifiers.shortcutFormGroupSelector).val()}).then((()=>{Notification.success(TYPO3.lang["bookmark.savedTitle"],TYPO3.lang["bookmark.savedMessage"]),this.refreshMenu()}))}refreshMenu(){new AjaxRequest(TYPO3.settings.ajaxUrls.shortcut_list).get({cache:"no-cache"}).then((async t=>{$(Identifiers.toolbarMenuSelector,Identifiers.containerSelector).html(await t.resolve())}))}}top.TYPO3.ShortcutMenu&&"object"==typeof top.TYPO3.ShortcutMenu||(top.TYPO3.ShortcutMenu=new ShortcutMenu);const shortcutMenuObject=top.TYPO3.ShortcutMenu;export default shortcutMenuObject; \ No newline at end of file diff --git a/typo3/sysext/core/Tests/Acceptance/Application/Topbar/BookmarkCest.php b/typo3/sysext/core/Tests/Acceptance/Application/Topbar/BookmarkCest.php index 8ecc24f2e75db795d8518b439ef1772879393817..486f5ca95f0c6abc7e12e9a6b39a6bcfb1eb73c3 100644 --- a/typo3/sysext/core/Tests/Acceptance/Application/Topbar/BookmarkCest.php +++ b/typo3/sysext/core/Tests/Acceptance/Application/Topbar/BookmarkCest.php @@ -110,9 +110,9 @@ class BookmarkCest $this->clickBookmarkDropdownToggleInTopbar($I); $firstShortcutSelector = self::$topBarModuleSelector . ' .t3js-topbar-shortcut'; $I->click('.t3js-shortcut-edit', $firstShortcutSelector); - $secondShortcutSelector = self::$topBarModuleSelector . ' form.shortcut-form'; + $secondShortcutSelector = self::$topBarModuleSelector . ' form.t3js-shortcut-form'; $I->fillField($secondShortcutSelector . ' input[name="shortcut-title"]', 'Scheduled tasks renamed'); - $I->click('.shortcut-form-save', $secondShortcutSelector); + $I->click('.t3js-shortcut-form-save', $secondShortcutSelector); // searching in a specific context fails with an "Stale Element Reference Exception" // see http://docs.seleniumhq.org/exceptions/stale_element_reference.jsp