Betaimport {
Command,
Expression,
LimeObjectBulkAction,
LimeObjectBulkCommand,
LimeTypeContext,
Operator,
} from '@limetech/lime-web-components';
@Command({ id: 'bulk-export' })
class BulkExportCommand implements LimeObjectBulkCommand {
public context: LimeTypeContext;
public filter: Expression | null;
}
@Command({ id: 'bulk-delete' })
class BulkDeleteCommand implements LimeObjectBulkCommand {
public context: LimeTypeContext;
public filter: Expression | null;
}
@Command({ id: 'bulk-send-email' })
class BulkSendEmailCommand implements LimeObjectBulkCommand {
public context: LimeTypeContext;
public filter: Expression | null;
}
const contacts: LimeTypeContext = { limetype: 'contact', id: null };
const selectedObjects: Expression = {
key: 'id',
op: Operator.IN,
exp: [1, 2, 3],
};
const exportCommand = new BulkExportCommand();
exportCommand.context = contacts;
exportCommand.filter = selectedObjects;
const deleteCommand = new BulkDeleteCommand();
deleteCommand.context = contacts;
deleteCommand.filter = selectedObjects;
const sendEmailCommand = new BulkSendEmailCommand();
sendEmailCommand.context = contacts;
sendEmailCommand.filter = selectedObjects;
const bulkActions: LimeObjectBulkAction[] = [
{
label: 'Export to Excel',
icon: 'file-excel',
description: 'Download selected records as Excel spreadsheet',
command: exportCommand,
},
{
label: 'Delete Selected',
icon: 'trash',
description: 'Permanently delete all selected records',
command: deleteCommand,
},
{
label: 'Send Email',
icon: 'envelope',
description: 'Send email to all selected contacts',
command: sendEmailCommand,
},
];
import {
Command,
Expression,
LimeObjectBulkAction,
LimeObjectBulkCommand,
LimeTypeContext,
} from '@limetech/lime-web-components';
@Command({ id: 'bulk-update-status' })
class BulkUpdateStatusCommand implements LimeObjectBulkCommand {
public context: LimeTypeContext;
public filter: Expression | null;
public status: string;
}
class DealListToolbar {
// `null` while nothing is selected, which is also what the bulk command
// reads as "every object of the limetype".
private selectedObjects: Expression | null = null;
private getUpdateStatusAction(): LimeObjectBulkAction {
const command = new BulkUpdateStatusCommand();
command.context = { limetype: 'deal', id: null };
command.filter = this.selectedObjects;
return {
label: 'Update Status',
icon: 'edit',
description: 'Change status for all selected records',
command: command,
disabled: !this.selectedObjects,
};
}
}
Specialized action type for bulk operations on multiple LimeObjects.
Bulk actions are used when the user selects multiple objects and wants to perform the same operation on all of them. These actions typically appear in:
The command associated with this action type is LimeObjectBulkCommand, which uses a filter expression to specify which objects to operate on.
Common use cases include: