From 4eb0fcd14cd2ea3c0a245ee14ade7beb721a0f95 Mon Sep 17 00:00:00 2001
From: Sascha Wilking <sascha.wilking@hmmh.de>
Date: Fri, 7 Aug 2015 11:10:56 +0200
Subject: [PATCH] [BUGFIX] Async broken dialog message for adding new shortcut
 entry

With adding a new entry to the shortcut list the new fancy dialog
window stuff will open. but your choice cannot be "respected"
because the adding action was already done before the dialog
window is open.

Resolves: #68824
Releases: master
Change-Id: I13192f08b110226a563db200209e8d7ea0b3c600
Reviewed-on: http://review.typo3.org/42349
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
---
 .../Public/JavaScript/Toolbar/ShortcutMenu.js | 38 +++++++++----------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/ShortcutMenu.js b/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/ShortcutMenu.js
index 3e83ba0b4b88..d2e8cd80fd59 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/ShortcutMenu.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/ShortcutMenu.js
@@ -103,12 +103,27 @@ define('TYPO3/CMS/Backend/Toolbar/ShortcutMenu', ['jquery'], function($) {
 	 * when finished it reloads the menu
 	 */
 	ShortcutMenu.createShortcut = function(moduleName, url, confirmationText, motherModule) {
-		var shouldCreateShortcut = true;
 		if (typeof confirmationText !== 'undefined') {
 			// @todo: translations
 			top.TYPO3.Modal.confirm('Create bookmark', confirmationText)
 				.on('confirm.button.ok', function() {
-					shouldCreateShortcut = true;
+					var $toolbarItemIcon = $(ShortcutMenu.options.toolbarIconSelector, ShortcutMenu.options.containerSelector);
+					var $spinner = ShortcutMenu.$spinnerElement.clone();
+					var $existingItem = $toolbarItemIcon.replaceWith($spinner);
+
+					$.ajax({
+						url: TYPO3.settings.ajaxUrls['ShortcutMenu::create'],
+						type: 'post',
+						data: {
+							module: moduleName,
+							url: url,
+							motherModName: motherModule
+						},
+						cache: false
+					}).done(function() {
+						ShortcutMenu.refreshMenu();
+						$spinner.replaceWith($existingItem);
+					});
 					$(this).trigger('modal-dismiss');
 				})
 				.on('confirm.button.cancel', function() {
@@ -116,25 +131,6 @@ define('TYPO3/CMS/Backend/Toolbar/ShortcutMenu', ['jquery'], function($) {
 				});
 		}
 
-		if (shouldCreateShortcut) {
-			var $toolbarItemIcon = $(ShortcutMenu.options.toolbarIconSelector, ShortcutMenu.options.containerSelector);
-			var $spinner = ShortcutMenu.$spinnerElement.clone();
-			var $existingItem = $toolbarItemIcon.replaceWith($spinner);
-
-			$.ajax({
-				url: TYPO3.settings.ajaxUrls['ShortcutMenu::create'],
-				type: 'post',
-				data: {
-					module: moduleName,
-					url: url,
-					motherModName: motherModule
-				},
-				cache: false
-			}).done(function() {
-				ShortcutMenu.refreshMenu();
-				$spinner.replaceWith($existingItem);
-			});
-		}
 	};
 
 	/**
-- 
GitLab