[TASK] Replace confirm for delete record in DocHeader 24/41424/2
authorFrank Nägler <typo3@naegler.net>
Thu, 16 Jul 2015 10:10:33 +0000 (12:10 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 16 Jul 2015 11:15:38 +0000 (13:15 +0200)
Resolves: #68212
Releases: master
Change-Id: I9bd840c014bec704d8e16faab0cca7abce4cc330
Reviewed-on: http://review.typo3.org/41424
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>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Controller/EditDocumentController.php
typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js
typo3/sysext/lang/locallang_alt_doc.xlf

index e2695c4..ac06cdf 100644 (file)
@@ -730,12 +730,7 @@ class EditDocumentController {
                                }
                        }
                        function deleteRecord(table,id,url) {   //
-                               if (
-                                       ' . ($beUser->jsConfirmation(JsConfirmation::DELETE) ? 'confirm(' . GeneralUtility::quoteJSvalue($this->getLanguageService()->getLL('deleteWarning')) . ')' : '1==1') . '
-                               )       {
-                                       window.location.href = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_db') . '&cmd[') . '+table+"]["+id+"][delete]=1' . BackendUtility::getUrlToken('tceAction') . '&redirect="+escape(url)+"&vC=' . $beUser->veriCode() . '&prErr=1&uPT=1";
-                               }
-                               return false;
+                               window.location.href = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_db') . '&cmd[') . '+table+"]["+id+"][delete]=1' . BackendUtility::getUrlToken('tceAction') . '&redirect="+escape(url)+"&vC=' . $beUser->veriCode() . '&prErr=1&uPT=1";
                        }
                ';
 
@@ -1146,8 +1141,7 @@ class EditDocumentController {
                        if ($this->firstEl['cmd'] != 'new' && MathUtility::canBeInterpretedAsInteger($this->firstEl['uid'])) {
                                // Delete:
                                if ($this->firstEl['deleteAccess'] && !$GLOBALS['TCA'][$this->firstEl['table']]['ctrl']['readOnly'] && !$this->getNewIconMode($this->firstEl['table'], 'disableDelete')) {
-                                       $aOnClick = 'return deleteRecord(' . GeneralUtility::quoteJSvalue($this->firstEl['table']) . ',' . GeneralUtility::quoteJSvalue($this->firstEl['uid']) . ', ' . GeneralUtility::quoteJSvalue($this->retUrl) . ');';
-                                       $buttons['delete'] = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '" title="' . $lang->getLL('deleteItem', TRUE) . '">' . IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
+                                       $buttons['delete'] = '<a href="#" class="t3js-editform-delete-record" data-return-url="' . htmlspecialchars($this->retUrl) . '" data-uid="' . htmlspecialchars($this->firstEl['uid']) . '" data-table="' . htmlspecialchars($this->firstEl['table']) . '" title="' . $lang->getLL('deleteItem', TRUE) . '">' . IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
                                }
                                // Undo:
                                $undoRes = $this->getDatabaseConnection()->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $this->getDatabaseConnection()->fullQuoteStr($this->firstEl['table'], 'sys_history') . ' AND recuid=' . (int)$this->firstEl['uid'], '', 'tstamp DESC', '1');
index fa31ca4..95d82a0 100644 (file)
@@ -580,6 +580,33 @@ define('TYPO3/CMS/Backend/FormEngine', ['jquery'], function ($) {
                        e.preventDefault();
                        FormEngine.preventExitIfNotSaved();
                });
+
+               $(document).on('click', '.t3js-editform-delete-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);
+                       $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') {
+                                       deleteRecord($anchorElement.data('table'), $anchorElement.data('uid'), $anchorElement.data('return-url'));
+                                       top.TYPO3.Modal.dismiss();
+                               }
+                       });
+               });
        };
 
        /**
index 820b300..302f87a 100644 (file)
                        <trans-unit id="label.confirm.close_without_save.content">
                                <source>You have currently unsaved changes. Are you sure that you want to discard all changes?</source>
                        </trans-unit>
+                       <trans-unit id="buttons.confirm.delete_record.no">
+                               <source>No, I will continue editing</source>
+                       </trans-unit>
+                       <trans-unit id="buttons.confirm.delete_record.yes">
+                               <source>Yes, delete this record</source>
+                       </trans-unit>
+                       <trans-unit id="label.confirm.delete_record.title">
+                               <source>Delete this record?</source>
+                       </trans-unit>
+                       <trans-unit id="label.confirm.delete_record.content">
+                               <source>Are you sure you want to delete this record?</source>
+                       </trans-unit>
                </body>
        </file>
 </xliff>