[BUGFIX] Deleting an IRRE relation does now trigger a modal 07/43607/3
authorMichael Oehlhof <typo3@oehlhof.de>
Sun, 27 Sep 2015 22:32:20 +0000 (00:32 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Mon, 28 Sep 2015 07:49:26 +0000 (09:49 +0200)
Resolves: #70127
Releases: master
Change-Id: I3e7f3576f32414ac418adf470cae267550070a78
Reviewed-on: http://review.typo3.org/43607
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js

index c0c7db7..57569d6 100644 (file)
@@ -603,14 +603,9 @@ class InlineRecordContainer extends AbstractContainer {
                                        || !$isPagesTable && $calcPerms & Permission::CONTENT_EDIT
                                        || $isSysFileReferenceTable && $calcPerms & Permission::PAGE_EDIT)
                        ) {
-                               $onClick = htmlspecialchars(('if (confirm('
-                                       . GeneralUtility::quoteJSvalue($languageService->getLL('deleteWarning')) . ')) {        '
-                                       . 'inline.deleteRecord(' . GeneralUtility::quoteJSvalue($nameObjectFtId) . ');'
-                                       . ' } return false;'));
                                $title = $languageService->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:delete', TRUE);
                                $icon = $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL);
-                               $cells['delete'] = '<a class="btn btn-default" href="#" onclick="' . $onClick . '" title="' . $title
-                                       . '">' . $icon . '</a>';
+                               $cells['delete'] = '<a href="#" class="btn btn-default t3js-editform-delete-inline-record" data-objectid="' . htmlspecialchars($nameObjectFtId) . '" title="' . $title . '">' . $icon . '</a>';
                        }
 
                        // "Hide/Unhide" links:
index 183648d..caa63f5 100644 (file)
@@ -595,7 +595,7 @@ define('TYPO3/CMS/Backend/FormEngine', ['jquery'], function ($) {
                        var title = TYPO3.lang['label.confirm.delete_record.title'] || 'Delete this record?';
                        var content = TYPO3.lang['label.confirm.delete_record.content'] || 'Are you sure you want to delete this record?';
                        var $anchorElement = $(this);
-                       $modal = top.TYPO3.Modal.confirm(title, content, top.TYPO3.Severity.warning, [
+                       var $modal = top.TYPO3.Modal.confirm(title, content, top.TYPO3.Severity.warning, [
                                {
                                        text: TYPO3.lang['buttons.confirm.delete_record.no'] || 'No, I will continue editing',
                                        active: true,
@@ -617,6 +617,34 @@ define('TYPO3/CMS/Backend/FormEngine', ['jquery'], function ($) {
                        });
                });
 
+               $(document).on('click', '.t3js-editform-delete-inline-record', function(e) {
+                       e.preventDefault();
+                       var title = TYPO3.lang['label.confirm.delete_record.title'] || 'Delete this record?';
+                       var content = TYPO3.lang['label.confirm.delete_record.content'] || 'Are you sure you want to delete this record?';
+                       var $anchorElement = $(this);
+                       var $modal = top.TYPO3.Modal.confirm(title, content, top.TYPO3.Severity.warning, [
+                               {
+                                       text: TYPO3.lang['buttons.confirm.delete_record.no'] || 'No, I will continue editing',
+                                       active: true,
+                                       name: 'no'
+                               },
+                               {
+                                       text: TYPO3.lang['buttons.confirm.delete_record.yes'] || 'Yes, delete this record',
+                                       btnClass: 'btn-warning',
+                                       name: 'yes'
+                               }
+                       ]);
+                       $modal.on('button.clicked', function(e) {
+                               if (e.target.name === 'no') {
+                                       top.TYPO3.Modal.dismiss();
+                               } else if (e.target.name === 'yes') {
+                                       var objectId = $anchorElement.data('objectid');
+                                       inline.deleteRecord(objectId);
+                                       top.TYPO3.Modal.dismiss();
+                               }
+                       });
+               });
+
                // remember the clicked submit button. we need to know that in TBE_EDITOR.submitForm();
                $(document).on('click', '.t3js-editform-submitButton', function(event) {
                        var $elem = $('<input />').attr('type', 'hidden').attr('name', this.name).attr('value', '1');