[TASK] Replace JavaScript confirm dialog in User settings 20/46820/2
authorFrank Naegler <frank.naegler@typo3.org>
Mon, 22 Feb 2016 14:36:34 +0000 (15:36 +0100)
committerBenni Mack <benni@typo3.org>
Tue, 23 Feb 2016 06:03:36 +0000 (07:03 +0100)
This patch replaces the old JavaScript confirm dialog in user settings
module, which was used on the button "Reset Configuration and
Clear Temporary Data".

Resolves: #73600
Releases: master, 7.6
Change-Id: I24f872c5828aebfa08b2936e64abf57713182fbc
Reviewed-on: https://review.typo3.org/46820
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/setup/Classes/Controller/SetupModuleController.php
typo3/sysext/setup/ext_tables.php

index 8d55910..401b6a3 100644 (file)
@@ -171,6 +171,7 @@ class SetupModuleController extends AbstractModule
     {
         parent::__construct();
         $this->formProtection = FormProtectionFactory::get();
+        $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
     }
 
     /**
@@ -597,6 +598,15 @@ class SetupModuleController extends AbstractModule
                             value="' . $this->getLabel($config['buttonlabel'], '', false) . '"
                             onclick="' . $onClick . '" />';
                     }
+                    if (!empty($config['confirm'])) {
+                        $confirmData = $config['confirmData'];
+                        $html = '<br><input class="btn btn-default t3js-modal-trigger" type="button"'
+                            . ' value="' . $this->getLabel($config['buttonlabel'], '', false) . '"'
+                            . ' data-href="javascript:' . htmlspecialchars($confirmData['jsCodeAfterOk']) . '"'
+                            . ' data-severity="warning"'
+                            . ' data-title="' . $this->getLabel($config['label'], '', false) . '"'
+                            . ' data-content="' . $this->getLabel($confirmData['message'], '', false) . '" />';
+                    }
                     break;
                 case 'avatar':
                     // Get current avatar image
index 1c2c5c0..6147e76 100644 (file)
@@ -119,9 +119,10 @@ if (TYPO3_MODE === 'BE') {
                 'label' => 'LLL:EXT:setup/Resources/Private/Language/locallang.xlf:resetConfiguration',
                 'buttonlabel' => 'LLL:EXT:setup/Resources/Private/Language/locallang.xlf:resetConfigurationButton',
                 'csh' => 'reset',
-                'onClick' => 'if (confirm(\'%s\')) { document.getElementById(\'setValuesToDefault\').value = 1; this.form.submit(); }',
-                'onClickLabels' => array(
-                    'LLL:EXT:setup/Resources/Private/Language/locallang.xlf:setToStandardQuestion'
+                'confirm' => true,
+                'confirmData' => array(
+                    'message' => 'LLL:EXT:setup/Resources/Private/Language/locallang.xlf:setToStandardQuestion',
+                    'jsCodeAfterOk' => 'document.getElementById(\'setValuesToDefault\').value = 1; document.getElementById(\'SetupModuleController\').submit();'
                 )
             ),
             'resizeTextareas_Flexible' => array(