[TASK] Replace confirm ActionTask::action_linkUserName 80/42280/3
authorFrank Nägler <frank.naegler@typo3.org>
Wed, 5 Aug 2015 15:35:40 +0000 (17:35 +0200)
committerSusanne Moog <typo3@susannemoog.de>
Wed, 5 Aug 2015 15:55:58 +0000 (17:55 +0200)
Resolves: #68252
Releases: master
Change-Id: I04b8fe9e2135bbb28201d33acd114f8e87bfe1b9
Reviewed-on: http://review.typo3.org/42280
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
typo3/sysext/sys_action/Classes/ActionTask.php
typo3/sysext/sys_action/Resources/Public/JavaScript/ActionTask.js [new file with mode: 0644]
typo3/sysext/taskcenter/Resources/Private/Language/locallang_task.xlf

index fe2c6eb..aec5a7e 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\SysAction;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 
@@ -84,6 +85,8 @@ class ActionTask implements \TYPO3\CMS\Taskcenter\TaskInterface {
                                // Output depends on the type
                                switch ($record['type']) {
                                        case 1:
+                                               $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
+                                               $pageRenderer->loadRequireJsModule('TYPO3/CMS/SysAction/ActionTask');
                                                $content .= $this->viewNewBackendUser($record);
                                                break;
                                        case 2:
@@ -401,9 +404,8 @@ class ActionTask implements \TYPO3\CMS\Taskcenter\TaskInterface {
                $href = $this->moduleUrl . '&SET[function]=sys_action.TYPO3\\CMS\\SysAction\\ActionTask&show=' . (int)$sysActionUid . '&be_users_uid=' . (int)$userId;
                $link = '<a href="' . htmlspecialchars($href) . '">' . htmlspecialchars($username) . '</a>';
                // Link to delete the user record
-               $onClick = ' onClick="return confirm(' . GeneralUtility::quoteJSvalue($this->getLanguageService()->getLL('lDelete_warning')) . ');"';
                $link .= '
-                               <a href="' . htmlspecialchars(($href . '&delete=1')) . '" ' . $onClick . '>'
+                               <a href="' . htmlspecialchars(($href . '&delete=1')) . '" class="t3js-confirm-trigger" data-title="' . $this->getLanguageService()->getLL('lDelete_warning_title', TRUE) . '" data-message="' . $this->getLanguageService()->getLL('lDelete_warning', TRUE) . '">'
                                        . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-delete') .
                                '</a>';
                return $link;
diff --git a/typo3/sysext/sys_action/Resources/Public/JavaScript/ActionTask.js b/typo3/sysext/sys_action/Resources/Public/JavaScript/ActionTask.js
new file mode 100644 (file)
index 0000000..c0efec6
--- /dev/null
@@ -0,0 +1,33 @@
+/**
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * JavaScript to handle confirm windows in the task center module
+ */
+define('TYPO3/CMS/SysAction/ActionTask', ['jquery'], function ($) {
+       $(function() {
+               $(document).on('click', '.t3js-confirm-trigger', function(e) {
+                       e.preventDefault();
+                       var $link = $(this);
+                       top.TYPO3.Modal.confirm($link.data('title'), $link.data('message'))
+                               .on('confirm.button.ok', function() {
+                                       self.location.href = $link.attr('href');
+                                       top.TYPO3.Modal.currentModal.trigger('modal-dismiss');
+                               })
+                               .on('confirm.button.cancel', function() {
+                                       top.TYPO3.Modal.currentModal.trigger('modal-dismiss');
+                               });
+                       return false;
+               });
+       });
+});
index 3d58488..b3f8252 100644 (file)
@@ -48,6 +48,9 @@
                        <trans-unit id="lCancel">
                                <source>Cancel</source>
                        </trans-unit>
+                       <trans-unit id="lDelete_warning_title">
+                               <source>Please confirm</source>
+                       </trans-unit>
                        <trans-unit id="lDelete_warning">
                                <source>Are you sure you want to delete this user?</source>
                        </trans-unit>