Commit 377e5440 authored by Frank Nägler's avatar Frank Nägler Committed by Christian Kuhn
Browse files

[TASK] Replace confirm for delete record in DocHeader

Resolves: #68212
Releases: master
Change-Id: I9bd840c014bec704d8e16faab0cca7abce4cc330
Reviewed-on: http://review.typo3.org/41424


Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: default avatarSusanne Moog <typo3@susannemoog.de>
Tested-by: default avatarSusanne Moog <typo3@susannemoog.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 8830ba39
......@@ -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');
......
......@@ -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();
}
});
});
};
/**
......
......@@ -54,6 +54,18 @@
<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>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment