PHP 8.2.30
Preview: bulk-delete-action.js Size: 1.75 KB
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/adminjs/lib/backend/actions/bulk-delete/bulk-delete-action.js

import NotFoundError from '../../utils/errors/not-found-error.js';

/**
 * @implements Action
 * @category Actions
 * @module BulkDeleteAction
 * @description
 * Removes given records from the database.
 * @private
 */
export const BulkDeleteAction = {
  name: 'bulkDelete',
  isVisible: true,
  actionType: 'bulk',
  icon: 'Trash2',
  showInDrawer: true,
  variant: 'danger',
  /**
   * Responsible for deleting existing records.
   *
   * To invoke this action use {@link ApiClient#bulkAction}
   * with {actionName: _bulkDelete_}
   *
   * @return  {Promise<BulkActionResponse>}
   * @implements ActionHandler
   * @memberof module:BulkDeleteAction
   */
  handler: async (request, response, context) => {
    const {
      records,
      resource,
      h
    } = context;
    if (!records || !records.length) {
      throw new NotFoundError('no records were selected.', 'Action#handler');
    }
    if (request.method === 'get') {
      const recordsInJSON = records.map(record => record.toJSON(context.currentAdmin));
      return {
        records: recordsInJSON
      };
    }
    if (request.method === 'post') {
      await Promise.all(records.map(record => resource.delete(record.id(), context)));
      return {
        records: records.map(record => record.toJSON(context.currentAdmin)),
        notice: {
          message: records.length > 1 ? 'successfullyBulkDeleted_plural' : 'successfullyBulkDeleted',
          options: {
            count: records.length
          },
          resourceId: resource.id(),
          type: 'success'
        },
        redirectUrl: h.resourceUrl({
          resourceId: resource._decorated?.id() || resource.id()
        })
      };
    }
    throw new Error('method should be either "post" or "get"');
  }
};
export default BulkDeleteAction;

Directory Contents

Dirs: 0 × Files: 2

Name Size Perms Modified Actions
1.75 KB lrw-r--r-- 2026-02-28 00:31:24
Edit Download
2.50 KB lrw-r--r-- 2026-02-28 00:31:24
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).