Skip to content

Commit

Permalink
[BUGFIX] Enable multi deletion of records
Browse files Browse the repository at this point in the history
By constructing a correct command object, it's now
possible to delete multiple records using multi
record selection in the backend modules, using
the corresponding JavaScript component, which
are currently redirects, reactions and webhooks.

Resolves: #102475
Releases: main, 12.4
Change-Id: Iee0a88e062df042f5835ecc8e984532b3ca940d9
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81936
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Oliver Bartsch <bo@cedev.de>
  • Loading branch information
o-ba committed Nov 23, 2023
1 parent 13cfbc7 commit 297df49
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
Expand Up @@ -21,7 +21,6 @@ import Modal, { ModalElement } from '@typo3/backend/modal';
import { SeverityEnum } from '@typo3/backend/enum/severity';
import Severity from '@typo3/backend/severity';
import AjaxDataHandler from '@typo3/backend/ajax-data-handler';
import ResponseInterface from '@typo3/backend/ajax-data-handler/response-interface';
import Notification from '@typo3/backend/notification';

interface DeleteActionConfiguration extends ActionConfiguration {
Expand All @@ -33,6 +32,10 @@ interface DeleteActionConfiguration extends ActionConfiguration {
cancel: string;
}

interface DatahandlerCommand {
delete?: number
}

/**
* Module: @typo3/backend/multi-record-selection-delete-action
* @exports @typo3/backend/multi-record-selection-delete-action
Expand Down Expand Up @@ -75,21 +78,26 @@ class MultiRecordSelectionDeleteAction {
text: configuration.ok || TYPO3.lang['button.delete'] || 'OK',
btnClass: 'btn-' + Severity.getCssClass(SeverityEnum.warning),
name: 'delete',
trigger: (e: Event, modal: ModalElement) => {
trigger: async (e: Event, modal: ModalElement): Promise<void> => {
modal.hideModal();
AjaxDataHandler.process('cmd[' + tableName + '][' + entityIdentifiers.join(',') + '][delete]=1')
.then((result: ResponseInterface): void => {
if (result.hasErrors) {
throw result.messages;
} else if (returnUrl !== '') {
window.location.href = returnUrl;
} else {
modal.ownerDocument.location.reload();
try {
const result = await AjaxDataHandler.process({
cmd: {
[tableName]: Object.fromEntries(entityIdentifiers.map((identifier: string): [string, DatahandlerCommand] => [
identifier, { delete: 1 }
]))
}
})
.catch((): void => {
Notification.error('Could not delete records');
});
if (result.hasErrors) {
throw result.messages;
} else if (returnUrl !== '') {
window.location.href = returnUrl;
} else {
modal.ownerDocument.location.reload();
}
} catch {
Notification.error('Could not delete records');
}
}
}
]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 297df49

Please sign in to comment.