[TASK] Replace confirm in import / export module 78/42278/5
authorFrank Nägler <frank.naegler@typo3.org>
Wed, 5 Aug 2015 14:28:06 +0000 (16:28 +0200)
committerSusanne Moog <typo3@susannemoog.de>
Wed, 5 Aug 2015 15:32:05 +0000 (17:32 +0200)
Resolves: #68249
Releases: master
Change-Id: I9fb6fba5479059877ee650c567f20d77f711ef17
Reviewed-on: http://review.typo3.org/42278
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/impexp/Classes/Controller/ImportExportController.php
typo3/sysext/impexp/Resources/Private/Language/locallang.xlf
typo3/sysext/impexp/Resources/Public/JavaScript/ImportExport.js [new file with mode: 0644]

index e5caff3..15574aa 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Impexp\Controller;
 
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
@@ -96,6 +97,8 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
                // Setting up the context sensitive menu:
                $this->doc->getContextMenuCode();
+               $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
+               $pageRenderer->loadRequireJsModule('TYPO3/CMS/Impexp/ImportExport');
                $this->doc->postCode = $this->doc->wrapScriptTags('if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';');
                $this->doc->form = '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('xMOD_tximpexp')) . '" method="post" enctype="multipart/form-data">'
                        . '<input type="hidden" name="id" value="' . $this->id . '" />';
@@ -764,10 +767,11 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                                                ' . $this->lang->getLL('makesavefo_selectPreset', TRUE) . '<br/>
                                                ' . $this->renderSelectBox('preset[select]', '', $opt) . '
                                                <br/>
+                                               <input type="hidden" name="not-set" value="1" id="t3js-submit-field" />
                                                <input class="btn btn-default" type="submit" value="' . $this->lang->getLL('makesavefo_load', TRUE) . '" name="preset[load]" />
-                                               <input class="btn btn-default" type="submit" value="' . $this->lang->getLL('makesavefo_save', TRUE) . '" name="preset[save]" onclick="return confirm(\'' . $this->lang->getLL('makesavefo_areYouSure', TRUE) . '\');" />
-                                               <input class="btn btn-default" type="submit" value="' . $this->lang->getLL('makesavefo_delete', TRUE) . '" name="preset[delete]" onclick="return confirm(\'' . $this->lang->getLL('makesavefo_areYouSure', TRUE) . '\');" />
-                                               <input class="btn btn-default" type="submit" value="' . $this->lang->getLL('makesavefo_merge', TRUE) . '" name="preset[merge]" onclick="return confirm(\'' . $this->lang->getLL('makesavefo_areYouSure', TRUE) . '\');" />
+                                               <input class="btn btn-default t3js-confirm-trigger" type="button" value="' . $this->lang->getLL('makesavefo_save', TRUE) . '" name="preset[save]" data-title="' . $this->lang->getLL('pleaseConfirm', TRUE) . '" data-message="' . $this->lang->getLL('makesavefo_areYouSure', TRUE) . '" />
+                                               <input class="btn btn-default t3js-confirm-trigger" type="button" value="' . $this->lang->getLL('makesavefo_delete', TRUE) . '" name="preset[delete]" data-title="' . $this->lang->getLL('pleaseConfirm', TRUE) . '" data-message="' . $this->lang->getLL('makesavefo_areYouSure', TRUE) . '" />
+                                               <input class="btn btn-default t3js-confirm-trigger" type="button" value="' . $this->lang->getLL('makesavefo_merge', TRUE) . '" name="preset[merge]" data-title="' . $this->lang->getLL('pleaseConfirm', TRUE) . '" data-message="' . $this->lang->getLL('makesavefo_areYouSure', TRUE) . '" />
                                                <br/>
                                                ' . $this->lang->getLL('makesavefo_titleOfNewPreset', TRUE) . '
                                                <input type="text" name="tx_impexp[preset][title]" value="'
@@ -978,10 +982,9 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                                </tr>';
                        $newImport = !$inData['import_file']
                                ? '<input class="btn btn-default" type="submit" value="' . $this->lang->getLL('importdata_preview', TRUE) . '" />' . ($inData['file']
-                                       ? ' - <input class="btn btn-default" type="submit" value="' . ($inData['do_update']
+                                       ? ' - <input type="hidden" name="not-set" value="1" id="t3js-submit-field" /><input class="btn btn-default t3js-confirm-trigger" type="button" value="' . ($inData['do_update']
                                                ? $this->lang->getLL('importdata_update_299e', TRUE)
-                                               : $this->lang->getLL('importdata_import', TRUE)) . '" name="tx_impexp[import_file]" onclick="return confirm(\''
-                                                       . $this->lang->getLL('importdata_areYouSure', TRUE) . '\');" />'
+                                               : $this->lang->getLL('importdata_import', TRUE)) . '" name="tx_impexp[import_file]" data-title="' . $this->lang->getLL('pleaseConfirm', TRUE) . '" data-message="' . $this->lang->getLL('importdata_areYouSure', TRUE) . '" />'
                                        : '')
                                : '<input class="btn btn-default" type="submit" name="tx_impexp[new_import]" value="' . $this->lang->getLL('importdata_newImport', TRUE) . '" />';
                        $row[] = '<tr>
index 46875c6..8e3b434 100644 (file)
                        <trans-unit id="makesavefo_save">
                                <source>Save</source>
                        </trans-unit>
+                       <trans-unit id="pleaseConfirm">
+                               <source>Please confirm</source>
+                       </trans-unit>
                        <trans-unit id="makesavefo_areYouSure">
                                <source>Are you sure?</source>
                        </trans-unit>
diff --git a/typo3/sysext/impexp/Resources/Public/JavaScript/ImportExport.js b/typo3/sysext/impexp/Resources/Public/JavaScript/ImportExport.js
new file mode 100644 (file)
index 0000000..e8cbc6e
--- /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 Import/Export module
+ */
+define('TYPO3/CMS/Impexp/ImportExport', ['jquery'], function ($) {
+       $(function() {
+               $(document).on('click', '.t3js-confirm-trigger', function() {
+                       $button = $(this);
+                       top.TYPO3.Modal.confirm($button.data('title'), $button.data('message'))
+                               .on('confirm.button.ok', function() {
+                                       $('#t3js-submit-field')
+                                               .attr('name', $button.attr('name'))
+                                               .closest('form').submit();
+                                       top.TYPO3.Modal.currentModal.trigger('modal-dismiss');
+                               })
+                               .on('confirm.button.cancel', function() {
+                                       top.TYPO3.Modal.currentModal.trigger('modal-dismiss');
+                               });
+               });
+       });
+});